···77 coreutils file findutils gawk gnugrep gnused jdk python3 which
88 ]) + ":${platform-tools}/platform-tools";
99in
1010-deployAndroidPackage {
1010+deployAndroidPackage rec {
1111 inherit package os;
1212 nativeBuildInputs = [ makeWrapper ]
1313 ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ];
1414 autoPatchelfIgnoreMissingDeps = true;
1515 buildInputs = lib.optionals (os == "linux") [ pkgs.zlib ];
1616- patchInstructions = ''
1616+1717+ patchElfBnaries = ''
1818+ # Patch the executables of the toolchains, but not the libraries -- they are needed for crosscompiling
1919+ if [ -d $out/libexec/android-sdk/ndk-bundle/toolchains/renderscript/prebuilt/linux-x86_64/lib64 ]; then
2020+ addAutoPatchelfSearchPath $out/libexec/android-sdk/ndk-bundle/toolchains/renderscript/prebuilt/linux-x86_64/lib64
2121+ fi
2222+2323+ if [ -d $out/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib64 ]; then
2424+ addAutoPatchelfSearchPath $out/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib64
2525+ fi
2626+2727+ find toolchains -type d -name bin -or -name lib64 | while read dir; do
2828+ autoPatchelf "$dir"
2929+ done
3030+3131+ # Patch executables
3232+ if [ -d prebuilt/linux-x86_64 ]; then
3333+ autoPatchelf prebuilt/linux-x86_64
3434+ fi
3535+ '';
3636+3737+ patchOsAgnostic = ''
1738 patchShebangs .
18391940 # TODO: allow this stuff
···2243 # Ndk now has a prebuilt toolchains inside, the file layout has changed, we do a symlink
2344 # to still support the old standalone toolchains builds.
2445 if [ -d $out/libexec/android-sdk/ndk ] && [ ! -d $out/libexec/android-sdk/ndk-bundle ]; then
2525- ln -sf $out/libexec/android-sdk/ndk/${package.revision} $out/libexec/android-sdk/ndk-bundle
4646+ ln -sf $out/libexec/android-sdk/ndk/${package.revision} $out/libexec/android-sdk/ndk-bundle
2647 elif [ ! -d $out/libexec/android-sdk/ndk-bundle ]; then
2727- echo "The ndk-bundle layout has changed. The nix expressions have to be updated!"
2828- exit 1
2929- fi
3030-3131- # Patch the executables of the toolchains, but not the libraries -- they are needed for crosscompiling
3232- if [ -d $out/libexec/android-sdk/ndk-bundle/toolchains/renderscript/prebuilt/linux-x86_64/lib64 ]; then
3333- addAutoPatchelfSearchPath $out/libexec/android-sdk/ndk-bundle/toolchains/renderscript/prebuilt/linux-x86_64/lib64
3434- fi
3535-3636- if [ -d $out/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib64 ]; then
3737- addAutoPatchelfSearchPath $out/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib64
3838- fi
3939-4040- if [ -d toolchains/llvm/prebuilt/linux-x86_64 ]; then
4141- find toolchains/llvm/prebuilt/linux-x86_64 -type d -name bin -or -name lib64 | while read dir; do
4242- autoPatchelf "$dir"
4343- done
4848+ echo "The ndk-bundle layout has changed. The nix expressions have to be updated!"
4949+ exit 1
4450 fi
45514652 # fix ineffective PROGDIR / MYNDKDIR determination
4753 for progname in ndk-build; do
4848- sed -i -e 's|^PROGDIR=`dirname $0`|PROGDIR=`dirname $(readlink -f $(which $0))`|' $progname
5454+ sed -i -e 's|^PROGDIR=`dirname $0`|PROGDIR=`dirname $(readlink -f $(which $0))`|' $progname
4955 done
50565151- # Patch executables
5252- if [ -d prebuilt/linux-x86_64 ]; then
5353- autoPatchelf prebuilt/linux-x86_64
5454- fi
5555-5657 # wrap
5758 for progname in ndk-build; do
5858- wrapProgram "$(pwd)/$progname" --prefix PATH : "${runtime_paths}"
5959+ wrapProgram "$(pwd)/$progname" --prefix PATH : "${runtime_paths}"
5960 done
60616162 # make some executables available in PATH
6263 mkdir -p $out/bin
6364 for progname in ndk-build; do
6464- ln -sf ../libexec/android-sdk/ndk-bundle/$progname $out/bin/$progname
6565+ ln -sf ../libexec/android-sdk/ndk-bundle/$progname $out/bin/$progname
6566 done
6667 '';
6868+6969+ patchInstructions = patchOsAgnostic
7070+ + lib.optionalString stdenv.isLinux patchElfBnaries;
7171+6772 noAuditTmpdir = true; # Audit script gets invoked by the build/ component in the path for the make standalone script
6873}