lol

Merge pull request #216142 from status-im/androidenv/fix-toolchains

authored by

Sandro and committed by
GitHub
7ecf5641 5454044f

+33 -28
+33 -28
pkgs/development/mobile/androidenv/ndk-bundle/default.nix
··· 7 7 coreutils file findutils gawk gnugrep gnused jdk python3 which 8 8 ]) + ":${platform-tools}/platform-tools"; 9 9 in 10 - deployAndroidPackage { 10 + deployAndroidPackage rec { 11 11 inherit package os; 12 12 nativeBuildInputs = [ makeWrapper ] 13 13 ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ]; 14 14 autoPatchelfIgnoreMissingDeps = true; 15 15 buildInputs = lib.optionals (os == "linux") [ pkgs.zlib ]; 16 - patchInstructions = '' 16 + 17 + patchElfBnaries = '' 18 + # Patch the executables of the toolchains, but not the libraries -- they are needed for crosscompiling 19 + if [ -d $out/libexec/android-sdk/ndk-bundle/toolchains/renderscript/prebuilt/linux-x86_64/lib64 ]; then 20 + addAutoPatchelfSearchPath $out/libexec/android-sdk/ndk-bundle/toolchains/renderscript/prebuilt/linux-x86_64/lib64 21 + fi 22 + 23 + if [ -d $out/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib64 ]; then 24 + addAutoPatchelfSearchPath $out/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib64 25 + fi 26 + 27 + find toolchains -type d -name bin -or -name lib64 | while read dir; do 28 + autoPatchelf "$dir" 29 + done 30 + 31 + # Patch executables 32 + if [ -d prebuilt/linux-x86_64 ]; then 33 + autoPatchelf prebuilt/linux-x86_64 34 + fi 35 + ''; 36 + 37 + patchOsAgnostic = '' 17 38 patchShebangs . 18 39 19 40 # TODO: allow this stuff ··· 22 43 # Ndk now has a prebuilt toolchains inside, the file layout has changed, we do a symlink 23 44 # to still support the old standalone toolchains builds. 24 45 if [ -d $out/libexec/android-sdk/ndk ] && [ ! -d $out/libexec/android-sdk/ndk-bundle ]; then 25 - ln -sf $out/libexec/android-sdk/ndk/${package.revision} $out/libexec/android-sdk/ndk-bundle 46 + ln -sf $out/libexec/android-sdk/ndk/${package.revision} $out/libexec/android-sdk/ndk-bundle 26 47 elif [ ! -d $out/libexec/android-sdk/ndk-bundle ]; then 27 - echo "The ndk-bundle layout has changed. The nix expressions have to be updated!" 28 - exit 1 29 - fi 30 - 31 - # Patch the executables of the toolchains, but not the libraries -- they are needed for crosscompiling 32 - if [ -d $out/libexec/android-sdk/ndk-bundle/toolchains/renderscript/prebuilt/linux-x86_64/lib64 ]; then 33 - addAutoPatchelfSearchPath $out/libexec/android-sdk/ndk-bundle/toolchains/renderscript/prebuilt/linux-x86_64/lib64 34 - fi 35 - 36 - if [ -d $out/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib64 ]; then 37 - addAutoPatchelfSearchPath $out/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib64 38 - fi 39 - 40 - if [ -d toolchains/llvm/prebuilt/linux-x86_64 ]; then 41 - find toolchains/llvm/prebuilt/linux-x86_64 -type d -name bin -or -name lib64 | while read dir; do 42 - autoPatchelf "$dir" 43 - done 48 + echo "The ndk-bundle layout has changed. The nix expressions have to be updated!" 49 + exit 1 44 50 fi 45 51 46 52 # fix ineffective PROGDIR / MYNDKDIR determination 47 53 for progname in ndk-build; do 48 - sed -i -e 's|^PROGDIR=`dirname $0`|PROGDIR=`dirname $(readlink -f $(which $0))`|' $progname 54 + sed -i -e 's|^PROGDIR=`dirname $0`|PROGDIR=`dirname $(readlink -f $(which $0))`|' $progname 49 55 done 50 56 51 - # Patch executables 52 - if [ -d prebuilt/linux-x86_64 ]; then 53 - autoPatchelf prebuilt/linux-x86_64 54 - fi 55 - 56 57 # wrap 57 58 for progname in ndk-build; do 58 - wrapProgram "$(pwd)/$progname" --prefix PATH : "${runtime_paths}" 59 + wrapProgram "$(pwd)/$progname" --prefix PATH : "${runtime_paths}" 59 60 done 60 61 61 62 # make some executables available in PATH 62 63 mkdir -p $out/bin 63 64 for progname in ndk-build; do 64 - ln -sf ../libexec/android-sdk/ndk-bundle/$progname $out/bin/$progname 65 + ln -sf ../libexec/android-sdk/ndk-bundle/$progname $out/bin/$progname 65 66 done 66 67 ''; 68 + 69 + patchInstructions = patchOsAgnostic 70 + + lib.optionalString stdenv.isLinux patchElfBnaries; 71 + 67 72 noAuditTmpdir = true; # Audit script gets invoked by the build/ component in the path for the make standalone script 68 73 }