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