diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2022-06-29 18:24:50 +0900 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2022-06-29 18:27:16 +0900 |
commit | 2408ef3c6faa0ba0d513257378563ddc886f1020 (patch) | |
tree | 3af567a3463e8bee7bcecaf53ac93c6ba3ba16cf | |
parent | 539222e8d4bafaf783814c747e0ace40affa3761 (diff) | |
download | nixpkgs-2408ef3c6faa0ba0d513257378563ddc886f1020.tar nixpkgs-2408ef3c6faa0ba0d513257378563ddc886f1020.tar.gz nixpkgs-2408ef3c6faa0ba0d513257378563ddc886f1020.tar.bz2 nixpkgs-2408ef3c6faa0ba0d513257378563ddc886f1020.tar.lz nixpkgs-2408ef3c6faa0ba0d513257378563ddc886f1020.tar.xz nixpkgs-2408ef3c6faa0ba0d513257378563ddc886f1020.tar.zst nixpkgs-2408ef3c6faa0ba0d513257378563ddc886f1020.zip |
androidndk: remove legacy ndks
allows us to remove python2 dependencies and lot more
5 files changed, 19 insertions, 143 deletions
diff --git a/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix b/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix index dc9802ea7f9..2d561962041 100644 --- a/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix +++ b/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix @@ -1,5 +1,4 @@ -{ lib, stdenv -, makeWrapper, python +{ lib, stdenv, makeWrapper , runCommand, wrapBintoolsWith, wrapCCWith, autoPatchelfHook , buildAndroidndk, androidndk, targetAndroidndkPkgs }: @@ -24,30 +23,18 @@ let i686-unknown-linux-android = { triple = "i686-linux-android"; arch = "x86"; - # LEGACY - toolchain = "x86"; - gccVer = "4.9"; }; x86_64-unknown-linux-android = { triple = "x86_64-linux-android"; arch = "x86_64"; - # LEGACY - toolchain = "x86_64"; - gccVer = "4.9"; }; armv7a-unknown-linux-androideabi = { arch = "arm"; triple = "arm-linux-androideabi"; - # LEGACY - toolchain = "arm-linux-androideabi"; - gccVer = "4.9"; }; aarch64-unknown-linux-android = { arch = "arm64"; triple = "aarch64-linux-android"; - # LEGACY - toolchain = "aarch64-linux-android"; - gccVer = "4.9"; }; }.${config} or (throw "Android NDK doesn't support ${config}, as far as we know"); @@ -70,7 +57,7 @@ rec { binaries = stdenv.mkDerivation { pname = "${targetConfig}-ndk-toolchain"; inherit (androidndk) version; - nativeBuildInputs = [ makeWrapper python autoPatchelfHook ]; + nativeBuildInputs = [ makeWrapper autoPatchelfHook ]; propagatedBuildInputs = [ androidndk ]; passthru = { isClang = true; # clang based cc, but bintools ld @@ -82,16 +69,10 @@ rec { dontPatch = true; autoPatchelfIgnoreMissingDeps = true; installPhase = '' - if [ ! -d ${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${buildInfo.double} ]; then - # LEGACY: make-standalone-toolchain is deprecated - # https://developer.android.com/ndk/guides/standalone_toolchain - ${androidndk}/libexec/android-sdk/ndk-bundle/build/tools/make-standalone-toolchain.sh --arch=${targetInfo.arch} --install-dir=$out/toolchain --platform=${sdkVer} --force - else - # https://developer.android.com/ndk/guides/other_build_systems - mkdir -p $out - cp -r ${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${buildInfo.double} $out/toolchain - find $out/toolchain -type d -exec chmod 777 {} \; - fi + # https://developer.android.com/ndk/guides/other_build_systems + mkdir -p $out + cp -r ${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${buildInfo.double} $out/toolchain + find $out/toolchain -type d -exec chmod 777 {} \; if [ ! -d $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${sdkVer} ]; then echo "NDK does not contain libraries for SDK version ${sdkVer}"; @@ -116,17 +97,8 @@ rec { ln -s $f ''${f/${targetInfo.triple}/${targetConfig}} done - # LEGACY: get rid of gcc and g++, otherwise wrapCCWith will use them instead of clang - rm -f $out/bin/${targetConfig}-gcc $out/bin/${targetConfig}-g++ - - # LEGACY: ld doesn't properly include transitive library dependencies. - # Let's use gold instead rm -f $out/bin/${targetConfig}-ld - if [[ -f $out/bin/${targetConfig}-ld.gold ]]; then - ln -s $out/bin/${targetConfig}-ld.gold $out/bin/${targetConfig}-ld - else - ln -s $out/bin/lld $out/bin/${targetConfig}-ld - fi + ln -s $out/bin/lld $out/bin/${targetConfig}-ld (cd $out/bin; for tool in llvm-*; do @@ -156,18 +128,12 @@ rec { libc = targetAndroidndkPkgs.libraries; extraBuildCommands = '' echo "-D__ANDROID_API__=${stdenv.targetPlatform.sdkVer}" >> $out/nix-support/cc-cflags - if [ ! -d ${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${hostInfo.double} ]; then - # LEGACY: probably won't work for any recent android - echo "--gcc-toolchain=${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/${targetInfo.toolchain}-${targetInfo.gccVer}/prebuilt/${hostInfo.double}" >> $out/nix-support/cc-cflags - echo "-fuse-ld=$out/bin/${targetConfig}-ld.gold -L${binaries}/lib" >> $out/nix-support/cc-ldflags - else - # Android needs executables linked with -pie since version 5.0 - # Use -fPIC for compilation, and link with -pie if no -shared flag used in ldflags - echo "-target ${targetInfo.triple} -fPIC" >> $out/nix-support/cc-cflags - echo "-z,noexecstack -z,relro -z,now" >> $out/nix-support/cc-ldflags - echo 'if [[ ! " $@ " =~ " -shared " ]]; then NIX_LDFLAGS_${suffixSalt}+=" -pie"; fi' >> $out/nix-support/add-flags.sh - echo "-Xclang -mnoexecstack" >> $out/nix-support/cc-cxxflags - fi + # Android needs executables linked with -pie since version 5.0 + # Use -fPIC for compilation, and link with -pie if no -shared flag used in ldflags + echo "-target ${targetInfo.triple} -fPIC" >> $out/nix-support/cc-cflags + echo "-z,noexecstack -z,relro -z,now" >> $out/nix-support/cc-ldflags + echo 'if [[ ! " $@ " =~ " -shared " ]]; then NIX_LDFLAGS_${suffixSalt}+=" -pie"; fi' >> $out/nix-support/add-flags.sh + echo "-Xclang -mnoexecstack" >> $out/nix-support/cc-cxxflags if [ ${targetInfo.triple} == arm-linux-androideabi ]; then # https://android.googlesource.com/platform/external/android-cmake/+/refs/heads/cmake-master-dev/android.toolchain.cmake echo "--fix-cortex-a8" >> $out/nix-support/cc-ldflags @@ -181,12 +147,7 @@ rec { # cross-compiling packages to wrap incorrectly wrap binaries we don't include # anyways. libraries = runCommand "bionic-prebuilt" {} '' - if [ -d ${buildAndroidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt ]; then - lpath=${buildAndroidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${buildInfo.double}/sysroot/usr/lib/${targetInfo.triple}/${sdkVer} - else - # LEGACY - lpath=${buildAndroidndk}/libexec/android-sdk/ndk-bundle/platforms/android-${sdkVer}/arch-${hostInfo.arch}/usr/${if hostInfo.arch == "x86_64" then "lib64" else "lib"} - fi + lpath=${buildAndroidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${buildInfo.double}/sysroot/usr/lib/${targetInfo.triple}/${sdkVer} if [ ! -d $lpath ]; then echo "NDK does not contain libraries for SDK version ${sdkVer} <$lpath>" exit 1 diff --git a/pkgs/development/androidndk-pkgs/default.nix b/pkgs/development/androidndk-pkgs/default.nix index cd076653ebd..a7001ce1d4a 100644 --- a/pkgs/development/androidndk-pkgs/default.nix +++ b/pkgs/development/androidndk-pkgs/default.nix @@ -2,36 +2,6 @@ }: { - "18b" = - let - ndkVersion = "18.1.5063045"; - - buildAndroidComposition = buildPackages.buildPackages.androidenv.composeAndroidPackages { - includeNDK = true; - inherit ndkVersion; - }; - - androidComposition = androidenv.composeAndroidPackages { - includeNDK = true; - inherit ndkVersion; - }; - in - import ./androidndk-pkgs.nix { - inherit lib; - inherit (buildPackages) - makeWrapper python autoPatchelfHook; - inherit (pkgs) - stdenv - runCommand wrapBintoolsWith wrapCCWith; - # buildPackages.foo rather than buildPackages.buildPackages.foo would work, - # but for splicing messing up on infinite recursion for the variants we - # *dont't* use. Using this workaround, but also making a test to ensure - # these two really are the same. - buildAndroidndk = buildAndroidComposition.ndk-bundle; - androidndk = androidComposition.ndk-bundle; - targetAndroidndkPkgs = targetPackages.androidndkPkgs_18b; - }; - "21" = let ndkVersion = "21.0.6113669"; @@ -49,7 +19,7 @@ import ./androidndk-pkgs.nix { inherit lib; inherit (buildPackages) - makeWrapper python autoPatchelfHook; + makeWrapper autoPatchelfHook; inherit (pkgs) stdenv runCommand wrapBintoolsWith wrapCCWith; @@ -79,7 +49,7 @@ import ./androidndk-pkgs.nix { inherit lib; inherit (buildPackages) - makeWrapper python autoPatchelfHook; + makeWrapper autoPatchelfHook; inherit (pkgs) stdenv runCommand wrapBintoolsWith wrapCCWith; @@ -109,7 +79,7 @@ import ./androidndk-pkgs.nix { inherit lib; inherit (buildPackages) - makeWrapper python autoPatchelfHook; + makeWrapper autoPatchelfHook; inherit (pkgs) stdenv runCommand wrapBintoolsWith wrapCCWith; diff --git a/pkgs/development/mobile/androidenv/ndk-bundle/default.nix b/pkgs/development/mobile/androidenv/ndk-bundle/default.nix index 28c7ca62b26..5d0e2c2b171 100644 --- a/pkgs/development/mobile/androidenv/ndk-bundle/default.nix +++ b/pkgs/development/mobile/androidenv/ndk-bundle/default.nix @@ -12,20 +12,10 @@ deployAndroidPackage { nativeBuildInputs = [ makeWrapper ] ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ]; autoPatchelfIgnoreMissingDeps = true; - buildInputs = lib.optional (os == "linux") [ pkgs.glibc pkgs.stdenv.cc.cc pkgs.python2 pkgs.ncurses5 pkgs.zlib pkgs.libcxx.out pkgs.libxml2 ]; + buildInputs = lib.optional (os == "linux") [ pkgs.zlib ]; patchInstructions = lib.optionalString (os == "linux") ('' patchShebangs . - # LEGACY: Fix the shebangs of the auto-generated scripts. - substituteInPlace ./build/tools/make_standalone_toolchain.py \ - --replace '#!/bin/bash' '#!${pkgs.bash}/bin/bash' - - '' + lib.optionalString (builtins.compareVersions (lib.getVersion package) "21" > 0) '' - patch -p1 \ - --no-backup-if-mismatch < ${./make_standalone_toolchain.py_18.patch} || true - wrapProgram ./build/tools/make_standalone_toolchain.py --prefix PATH : "${runtime_paths}" - '' + '' - # TODO: allow this stuff rm -rf docs tests diff --git a/pkgs/development/mobile/androidenv/ndk-bundle/make_standalone_toolchain.py_18.patch b/pkgs/development/mobile/androidenv/ndk-bundle/make_standalone_toolchain.py_18.patch deleted file mode 100644 index 7af2d44a0f2..00000000000 --- a/pkgs/development/mobile/androidenv/ndk-bundle/make_standalone_toolchain.py_18.patch +++ /dev/null @@ -1,44 +0,0 @@ -diff -Naur android-ndk-r18b/build/tools/make_standalone_toolchain.py android-ndk-r18b-new/build/tools/make_standalone_toolchain.py ---- android-ndk-r18b/build/tools/make_standalone_toolchain.py 2018-10-11 12:49:38.000000000 +0200 -+++ android-ndk-r18b-new/build/tools/make_standalone_toolchain.py 2018-11-20 21:55:52.689991420 +0100 -@@ -30,7 +30,7 @@ - import sys - import tempfile - import textwrap -- -+import subprocess - - THIS_DIR = os.path.realpath(os.path.dirname(__file__)) - NDK_DIR = os.path.realpath(os.path.join(THIS_DIR, '../..')) -@@ -173,6 +173,7 @@ - logger().debug('Copying %s', src_file) - shutil.copy2(src_file, dst_dir) - -+ subprocess.check_call(["chmod", "-R", "+w", dst]) - - def make_clang_scripts(install_dir, triple, api, windows): - """Creates Clang wrapper scripts. -@@ -365,6 +366,7 @@ - install_headers = os.path.join(install_sysroot, 'usr/include') - os.makedirs(os.path.dirname(install_headers)) - shutil.copytree(headers, install_headers) -+ subprocess.check_call(["chmod", "-R", "+w", install_path]) - - arch_headers = os.path.join(sysroot, 'usr/include', triple) - copy_directory_contents(arch_headers, os.path.join(install_headers)) -@@ -375,6 +377,7 @@ - install_sysroot, 'usr/lib{}'.format(lib_suffix)) - if os.path.exists(lib_path): - shutil.copytree(lib_path, lib_install) -+ subprocess.check_call(["chmod", "-R", "+w", install_path]) - - static_lib_path = os.path.join(sysroot, 'usr/lib', triple) - static_lib_install = os.path.join(install_sysroot, 'usr/lib') -@@ -389,6 +392,7 @@ - NDK_DIR, 'prebuilt', 'android-' + arch, 'gdbserver') - gdbserver_install = os.path.join(install_path, 'share', 'gdbserver') - shutil.copytree(gdbserver_path, gdbserver_install) -+ subprocess.check_call(["chmod", "-R", "+w", install_path]) - - toolchain_lib_dir = os.path.join(gcc_path, 'lib/gcc', triple) - dirs = os.listdir(toolchain_lib_dir) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ace695a85dd..eb9b5078885 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2656,8 +2656,7 @@ with pkgs; pkgs_i686 = pkgsi686Linux; }; - androidndkPkgs = androidndkPkgs_18b; - androidndkPkgs_18b = (callPackage ../development/androidndk-pkgs {})."18b"; + androidndkPkgs = androidndkPkgs_21; androidndkPkgs_21 = (callPackage ../development/androidndk-pkgs {})."21"; androidndkPkgs_23b = (callPackage ../development/androidndk-pkgs {})."23b"; androidndkPkgs_24 = (callPackage ../development/androidndk-pkgs {})."24"; |