From 5f1923d67e1ecdc2176f017d7d2008aa1c908baf Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Wed, 29 Jun 2022 18:24:19 +0900 Subject: [PATCH 1/5] androidenv: fix android cross-compilers These were completely broken. Even if they managed to output a binary, it wouldn't actually run on the actual device. --- .../androidndk-pkgs/androidndk-pkgs.nix | 143 ++++++++++++++---- pkgs/development/androidndk-pkgs/default.nix | 4 +- .../mobile/androidenv/ndk-bundle/default.nix | 11 +- 3 files changed, 125 insertions(+), 33 deletions(-) diff --git a/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix b/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix index 736e088454e7..dc9802ea7f9e 100644 --- a/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix +++ b/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix @@ -1,6 +1,6 @@ { lib, stdenv -, makeWrapper -, runCommand, wrapBintoolsWith, wrapCCWith +, makeWrapper, python +, runCommand, wrapBintoolsWith, wrapCCWith, autoPatchelfHook , buildAndroidndk, androidndk, targetAndroidndkPkgs }: @@ -11,6 +11,9 @@ let # N.B. The Android NDK uses slightly different LLVM-style platform triples # than we do. We don't just use theirs because ours are less ambiguous and # some builds need that clarity. + # + # FIXME: + # There's some dragons here. Build host and target concepts are being mixed up. ndkInfoFun = { config, ... }: { x86_64-apple-darwin = { double = "darwin-x86_64"; @@ -21,65 +24,123 @@ 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"); + buildInfo = ndkInfoFun stdenv.buildPlatform; hostInfo = ndkInfoFun stdenv.hostPlatform; targetInfo = ndkInfoFun stdenv.targetPlatform; - prefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) (stdenv.targetPlatform.config + "-"); + inherit (stdenv.targetPlatform) sdkVer; + suffixSalt = lib.replaceStrings ["-" "."] ["_" "_"] stdenv.targetPlatform.config; + + # targetInfo.triple is what Google thinks the toolchain should be, this is a little + # different from what we use. We make it four parts to conform with the existing + # standard more properly. + targetConfig = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) (stdenv.targetPlatform.config); in rec { # Misc tools - binaries = runCommand "ndk-toolchain-binutils" { - pname = "ndk-toolchain-binutils"; + binaries = stdenv.mkDerivation { + pname = "${targetConfig}-ndk-toolchain"; inherit (androidndk) version; - nativeBuildInputs = [ makeWrapper ]; + nativeBuildInputs = [ makeWrapper python autoPatchelfHook ]; propagatedBuildInputs = [ androidndk ]; passthru = { - targetPrefix = prefix; isClang = true; # clang based cc, but bintools ld }; - } '' - mkdir -p $out/bin + dontUnpack = true; + dontBuild = true; + dontStrip = true; + dontConfigure = true; + 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 - # llvm toolchain - for prog in ${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${hostInfo.double}/bin/*; do - ln -s $prog $out/bin/$(basename $prog) - ln -s $prog $out/bin/${prefix}$(basename $prog) - done + if [ ! -d $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${sdkVer} ]; then + echo "NDK does not contain libraries for SDK version ${sdkVer}"; + exit 1 + fi - # bintools toolchain - for prog in ${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/${targetInfo.toolchain}-${targetInfo.gccVer}/prebuilt/${hostInfo.double}/bin/*; do - prog_suffix=$(basename $prog | sed 's/${targetInfo.triple}-//') - ln -s $prog $out/bin/${stdenv.targetPlatform.config}-$prog_suffix - done + ln -vfs $out/toolchain/sysroot/usr/lib $out/lib + ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/*.so $out/lib/ + ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/*.a $out/lib/ + chmod +w $out/lib/* + ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${sdkVer}/*.so $out/lib/ + ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${sdkVer}/*.o $out/lib/ - # shitty googly wrappers - rm -f $out/bin/${stdenv.targetPlatform.config}-gcc $out/bin/${stdenv.targetPlatform.config}-g++ - ''; + echo "INPUT(-lc++_static)" > $out/lib/libc++.a + + ln -s $out/toolchain/bin $out/bin + ln -s $out/toolchain/${targetInfo.triple}/bin/* $out/bin/ + for f in $out/bin/${targetInfo.triple}-*; do + ln -s $f ''${f/${targetInfo.triple}-/${targetConfig}-} + done + for f in $(find $out/toolchain -type d -name ${targetInfo.triple}); do + 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 + + (cd $out/bin; + for tool in llvm-*; do + ln -sf $tool ${targetConfig}-$(echo $tool | sed 's/llvm-//') + ln -sf $tool $(echo $tool | sed 's/llvm-//') + done) + + # handle last, as llvm-as is for llvm bytecode + ln -sf $out/bin/${targetInfo.triple}-as $out/bin/${targetConfig}-as + ln -sf $out/bin/${targetInfo.triple}-as $out/bin/as + + patchShebangs $out/bin + ''; + }; binutils = wrapBintoolsWith { bintools = binaries; @@ -95,9 +156,22 @@ rec { libc = targetAndroidndkPkgs.libraries; extraBuildCommands = '' echo "-D__ANDROID_API__=${stdenv.targetPlatform.sdkVer}" >> $out/nix-support/cc-cflags - echo "-target ${stdenv.targetPlatform.config}" >> $out/nix-support/cc-cflags - echo "-resource-dir=$(echo ${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${hostInfo.double}/lib*/clang/*)" >> $out/nix-support/cc-cflags - echo "--gcc-toolchain=${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/${targetInfo.toolchain}-${targetInfo.gccVer}/prebuilt/${hostInfo.double}" >> $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 + 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 + fi ''; }; @@ -107,10 +181,19 @@ rec { # cross-compiling packages to wrap incorrectly wrap binaries we don't include # anyways. libraries = runCommand "bionic-prebuilt" {} '' - mkdir -p $out - cp -r ${buildAndroidndk}/libexec/android-sdk/ndk-bundle/sysroot/usr/include $out/include - chmod +w $out/include - cp -r ${buildAndroidndk}/libexec/android-sdk/ndk-bundle/sysroot/usr/include/${targetInfo.triple}/* $out/include - ln -s ${buildAndroidndk}/libexec/android-sdk/ndk-bundle/platforms/android-${stdenv.hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/${if hostInfo.arch == "x86_64" then "lib64" else "lib"} $out/lib + 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 + if [ ! -d $lpath ]; then + echo "NDK does not contain libraries for SDK version ${sdkVer} <$lpath>" + exit 1 + fi + mkdir -p $out/lib + cp $lpath/*.so $lpath/*.a $out/lib + chmod +w $out/lib/* + cp $lpath/* $out/lib ''; } diff --git a/pkgs/development/androidndk-pkgs/default.nix b/pkgs/development/androidndk-pkgs/default.nix index 5f71304d3855..1648a918b87b 100644 --- a/pkgs/development/androidndk-pkgs/default.nix +++ b/pkgs/development/androidndk-pkgs/default.nix @@ -19,7 +19,7 @@ import ./androidndk-pkgs.nix { inherit lib; inherit (buildPackages) - makeWrapper; + makeWrapper python autoPatchelfHook; inherit (pkgs) stdenv runCommand wrapBintoolsWith wrapCCWith; @@ -49,7 +49,7 @@ import ./androidndk-pkgs.nix { inherit lib; inherit (buildPackages) - makeWrapper; + makeWrapper python 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 58cc8f9d5709..28c7ca62b26d 100644 --- a/pkgs/development/mobile/androidenv/ndk-bundle/default.nix +++ b/pkgs/development/mobile/androidenv/ndk-bundle/default.nix @@ -16,7 +16,7 @@ deployAndroidPackage { patchInstructions = lib.optionalString (os == "linux") ('' patchShebangs . - # Fix the shebangs of the auto-generated scripts. + # LEGACY: Fix the shebangs of the auto-generated scripts. substituteInPlace ./build/tools/make_standalone_toolchain.py \ --replace '#!/bin/bash' '#!${pkgs.bash}/bin/bash' @@ -29,6 +29,15 @@ deployAndroidPackage { # TODO: allow this stuff rm -rf docs tests + # Ndk now has a prebuilt toolchains inside, the file layout has changed, we do a symlink + # to still support the old standalone toolchains builds. + if [ -d $out/libexec/android-sdk/ndk ] && [ ! -d $out/libexec/android-sdk/ndk-bundle ]; then + ln -sf $out/libexec/android-sdk/ndk/${package.revision} $out/libexec/android-sdk/ndk-bundle + else + echo "The ndk-bundle layout has changed. The nix expressions have to be updated!" + exit 1 + fi + # Patch the executables of the toolchains, but not the libraries -- they are needed for crosscompiling if [ -d $out/libexec/android-sdk/ndk-bundle/toolchains/renderscript/prebuilt/linux-x86_64/lib64 ]; then addAutoPatchelfSearchPath $out/libexec/android-sdk/ndk-bundle/toolchains/renderscript/prebuilt/linux-x86_64/lib64 From 0aded46f0838502361356497fc37825a9c3f9410 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Sun, 26 Jun 2022 03:20:13 +0900 Subject: [PATCH 2/5] androidenv: update packages --- pkgs/development/androidndk-pkgs/default.nix | 60 +++ .../androidenv/compose-android-packages.nix | 6 +- pkgs/development/mobile/androidenv/repo.json | 412 ++++++++++++++---- pkgs/top-level/all-packages.nix | 2 + 4 files changed, 398 insertions(+), 82 deletions(-) diff --git a/pkgs/development/androidndk-pkgs/default.nix b/pkgs/development/androidndk-pkgs/default.nix index 1648a918b87b..cd076653ebd7 100644 --- a/pkgs/development/androidndk-pkgs/default.nix +++ b/pkgs/development/androidndk-pkgs/default.nix @@ -62,4 +62,64 @@ targetAndroidndkPkgs = targetPackages.androidndkPkgs_21; }; + "23b" = + let + ndkVersion = "23.1.7779620"; + + 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_23b; + }; + + "24" = + let + ndkVersion = "24.0.8215888"; + + 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_24; + }; + } diff --git a/pkgs/development/mobile/androidenv/compose-android-packages.nix b/pkgs/development/mobile/androidenv/compose-android-packages.nix index 8270960d9b99..c6d838544e9c 100644 --- a/pkgs/development/mobile/androidenv/compose-android-packages.nix +++ b/pkgs/development/mobile/androidenv/compose-android-packages.nix @@ -3,7 +3,7 @@ }: { toolsVersion ? "26.1.1" -, platformToolsVersion ? "33.0.1" +, platformToolsVersion ? "33.0.2" , buildToolsVersions ? [ "32.0.0" ] , includeEmulator ? false , emulatorVersion ? "31.3.7" @@ -11,7 +11,7 @@ , includeSources ? false , includeSystemImages ? false , systemImageTypes ? [ "google_apis_playstore" ] -, abiVersions ? [ "armeabi-v7a" ] +, abiVersions ? [ "armeabi-v7a" "arm64-v8a" ] , cmakeVersions ? [ ] , includeNDK ? false , ndkVersion ? "24.0.8215888" @@ -181,7 +181,7 @@ rec { makeNdkBundle = ndkVersion: import ./ndk-bundle { inherit deployAndroidPackage os autoPatchelfHook makeWrapper pkgs pkgsHostHost lib platform-tools stdenv; - package = packages.ndk-bundle.${ndkVersion}; + package = packages.ndk-bundle.${ndkVersion} or packages.ndk.${ndkVersion}; }; # All NDK bundles. diff --git a/pkgs/development/mobile/androidenv/repo.json b/pkgs/development/mobile/androidenv/repo.json index 5ccbc430fce6..bf69c67820b0 100644 --- a/pkgs/development/mobile/androidenv/repo.json +++ b/pkgs/development/mobile/androidenv/repo.json @@ -1241,6 +1241,21 @@ }, "23": { "google_apis": { + "arm64-v8a": { + "archives": [ + { + "os": "all", + "sha1": "2d1ae21b1978e202917b7c6a5f49ab8bc87c6417", + "size": 493891214, + "url": "https://dl.google.com/android/repository/sys-img/google_apis/arm64-v8a-23_r33.zip" + } + ], + "displayName": "Google APIs ARM 64 v8a System Image", + "license": "android-sdk-license", + "name": "system-image-23-google_apis-arm64-v8a", + "path": "system-images/android-23/google_apis/arm64-v8a", + "revision": "23-google_apis-arm64-v8a" + }, "armeabi-v7a": { "archives": [ { @@ -1663,43 +1678,117 @@ } } }, - "Tiramisu": { + "33": { "google_apis_playstore": { "arm64-v8a": { "archives": [ { "os": "macosx", - "sha1": "2b6d4dc0af98b2b4d3ed4ac82b6d8ee0bfe38383", - "size": 1457296537, - "url": "https://dl.google.com/android/repository/sys-img/google_apis_playstore/arm64-v8a-Tiramisu_r02-darwin.zip" + "sha1": "0b850a4f317d7a6abe854a6845705c9ca4437764", + "size": 1492105537, + "url": "https://dl.google.com/android/repository/sys-img/google_apis_playstore/arm64-v8a-33_r05-darwin.zip" }, { "os": "linux", - "sha1": "2b6d4dc0af98b2b4d3ed4ac82b6d8ee0bfe38383", - "size": 1457296537, - "url": "https://dl.google.com/android/repository/sys-img/google_apis_playstore/arm64-v8a-Tiramisu_r02-linux.zip" + "sha1": "0b850a4f317d7a6abe854a6845705c9ca4437764", + "size": 1492105537, + "url": "https://dl.google.com/android/repository/sys-img/google_apis_playstore/arm64-v8a-33_r05-linux.zip" } ], "displayName": "Google Play ARM 64 v8a System Image", "license": "android-sdk-arm-dbt-license", - "name": "system-image-Tiramisu-google_apis_playstore-arm64-v8a", - "path": "system-images/android-Tiramisu/google_apis_playstore/arm64-v8a", - "revision": "Tiramisu-google_apis_playstore-arm64-v8a" + "name": "system-image-33-google_apis_playstore-arm64-v8a", + "path": "system-images/android-33/google_apis_playstore/arm64-v8a", + "revision": "33-google_apis_playstore-arm64-v8a" }, "x86_64": { "archives": [ { "os": "all", - "sha1": "2d2fb4c36efa836f348d6acbfc588f9eed70934e", - "size": 1438511715, - "url": "https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86_64-Tiramisu_r02.zip" + "sha1": "ed2931ebef4f7bedff8610254748d6496ce5d3c4", + "size": 1496628942, + "url": "https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86_64-33_r05.zip" } ], "displayName": "Google Play Intel x86 Atom_64 System Image", "license": "android-sdk-preview-license", - "name": "system-image-Tiramisu-google_apis_playstore-x86_64", - "path": "system-images/android-Tiramisu/google_apis_playstore/x86_64", - "revision": "Tiramisu-google_apis_playstore-x86_64" + "name": "system-image-33-google_apis_playstore-x86_64", + "path": "system-images/android-33/google_apis_playstore/x86_64", + "revision": "33-google_apis_playstore-x86_64" + } + } + }, + "Tiramisu": { + "android-tv": { + "arm64-v8a": { + "archives": [ + { + "os": "all", + "sha1": "4b70bed5ffb28162cdde7852e0597d957910270d", + "size": 840304267, + "url": "https://dl.google.com/android/repository/sys-img/android-tv/arm64-v8a-Tiramisu_r03.zip" + } + ], + "displayName": "Android TV ARM 64 v8a System Image", + "license": "android-sdk-license", + "name": "system-image-Tiramisu-android-tv-arm64-v8a", + "path": "system-images/android-Tiramisu/android-tv/arm64-v8a", + "revision": "Tiramisu-android-tv-arm64-v8a" + }, + "x86": { + "archives": [ + { + "os": "all", + "sha1": "547a24d9dec83e11486ef4ea45848d9fa99f35c2", + "size": 832895525, + "url": "https://dl.google.com/android/repository/sys-img/android-tv/x86-Tiramisu_r03.zip" + } + ], + "displayName": "Android TV Intel x86 Atom System Image", + "license": "android-sdk-license", + "name": "system-image-Tiramisu-android-tv-x86", + "path": "system-images/android-Tiramisu/android-tv/x86", + "revision": "Tiramisu-android-tv-x86" + } + } + }, + "TiramisuPrivacySandbox": { + "google_apis_playstore": { + "arm64-v8a": { + "archives": [ + { + "os": "macosx", + "sha1": "4653d7aa2dbd2629c3afc1c700284de0f7791bb2", + "size": 1514681298, + "url": "https://dl.google.com/android/repository/sys-img/google_apis_playstore/arm64-v8a-TiramisuPrivacySandbox_r05-darwin.zip" + }, + { + "os": "linux", + "sha1": "4653d7aa2dbd2629c3afc1c700284de0f7791bb2", + "size": 1514681298, + "url": "https://dl.google.com/android/repository/sys-img/google_apis_playstore/arm64-v8a-TiramisuPrivacySandbox_r05-linux.zip" + } + ], + "displayName": "Google Play ARM 64 v8a System Image", + "license": "android-sdk-arm-dbt-license", + "name": "system-image-TiramisuPrivacySandbox-google_apis_playstore-arm64-v8a", + "path": "system-images/android-TiramisuPrivacySandbox/google_apis_playstore/arm64-v8a", + "revision": "TiramisuPrivacySandbox-google_apis_playstore-arm64-v8a" + }, + "x86_64": { + "archives": [ + { + "os": "all", + "sha1": "2a4ea6ce714155ea8ddfea26cf61ad219f32c02a", + "size": 1519169526, + "url": "https://dl.google.com/android/repository/sys-img/google_apis_playstore/x86_64-TiramisuPrivacySandbox_r05.zip" + } + ], + "displayName": "Google Play Intel x86 Atom_64 System Image", + "license": "android-sdk-preview-license", + "name": "system-image-TiramisuPrivacySandbox-google_apis_playstore-x86_64", + "path": "system-images/android-TiramisuPrivacySandbox/google_apis_playstore/x86_64", + "revision": "TiramisuPrivacySandbox-google_apis_playstore-x86_64" } } } @@ -3298,32 +3387,32 @@ "path": "build-tools/32.1.0-rc1", "revision": "32.1.0-rc1" }, - "33.0.0-rc2": { + "33.0.0": { "archives": [ - { - "os": "windows", - "sha1": "789aa6dfb2155b81e073108c70982f73c890a95b", - "size": 55466255, - "url": "https://dl.google.com/android/repository/830151c9e0c410f6148390f0de30bd349ba91efd.build-tools_r33-rc2-windows.zip" - }, { "os": "linux", - "sha1": "013f98217b7af4f5677ab1a47e98da18ad57721c", - "size": 57876882, - "url": "https://dl.google.com/android/repository/build-tools_r33-rc2-linux.zip" + "sha1": "c561971600d4ce682b128b0bd5d4ab71c5f2ad35", + "size": 56000182, + "url": "https://dl.google.com/android/repository/build-tools_r33-linux.zip" }, { "os": "macosx", - "sha1": "586f8f77847ba3899b7652d6514e8c6a78ab673a", - "size": 59910819, - "url": "https://dl.google.com/android/repository/f8baa248444f0a5aca1119b48e897908a3da49d5.build-tools_r33-rc2-macosx.zip" + "sha1": "3693851532ba9640710d2dd360d85aa5b04c5151", + "size": 60023096, + "url": "https://dl.google.com/android/repository/build-tools_r33-macosx.zip" + }, + { + "os": "windows", + "sha1": "f4ef853e5e755ea5ffc50de73a9e420fc76c662e", + "size": 55610532, + "url": "https://dl.google.com/android/repository/build-tools_r33-windows.zip" } ], - "displayName": "Android SDK Build-Tools 33-rc2", - "license": "android-sdk-preview-license", + "displayName": "Android SDK Build-Tools 33", + "license": "android-sdk-license", "name": "build-tools", - "path": "build-tools/33.0.0-rc2", - "revision": "33.0.0-rc2" + "path": "build-tools/33.0.0", + "revision": "33.0.0" } }, "cmake": { @@ -3625,62 +3714,116 @@ "name": "cmdline-tools", "path": "cmdline-tools/6.0", "revision": "6.0" - } - }, - "emulator": { - "31.2.9": { + }, + "7.0": { "archives": [ { "os": "linux", - "sha1": "164b759748b3d2ee2616da74173867b11b18f64f", - "size": 276337192, - "url": "https://dl.google.com/android/repository/emulator-linux_x64-8316981.zip" - }, - { - "os": "windows", - "sha1": "2b6768485a8e6492823a9156fa43c55092afd533", - "size": 345298639, - "url": "https://dl.google.com/android/repository/emulator-windows_x64-8316981.zip" + "sha1": "5e7bf2dd563d34917d32f3c5920a85562a795c93", + "size": 114168525, + "url": "https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip" }, { "os": "macosx", - "sha1": "af2d950318d8ae8cc516a1401a94f888f615aca6", - "size": 313877066, - "url": "https://dl.google.com/android/repository/emulator-darwin_x64-8316981.zip" + "sha1": "9a663c49dbd3709fc2b7d49db2814b383d811b4a", + "size": 114168511, + "url": "https://dl.google.com/android/repository/commandlinetools-mac-8512546_latest.zip" + }, + { + "os": "windows", + "sha1": "1bdd32ac4b9fffea04f5bc341108e8b4fea6f32c", + "size": 114147385, + "url": "https://dl.google.com/android/repository/commandlinetools-win-8512546_latest.zip" + } + ], + "displayName": "Android SDK Command-line Tools", + "license": "android-sdk-license", + "name": "cmdline-tools", + "path": "cmdline-tools/7.0", + "revision": "7.0" + } + }, + "emulator": { + "31.2.10": { + "archives": [ + { + "os": "linux", + "sha1": "1f2c3ddeb2c9ac4feef5946098a0a710d08e9c6d", + "size": 276337904, + "url": "https://dl.google.com/android/repository/emulator-linux_x64-8420304.zip" + }, + { + "os": "windows", + "sha1": "206491b5c4e531b2c66dc80402702b9fa1a64c2a", + "size": 345300871, + "url": "https://dl.google.com/android/repository/emulator-windows_x64-8420304.zip" + }, + { + "os": "macosx", + "sha1": "677b6a00c145eb8bf4306daeb2231c8efd507177", + "size": 313876814, + "url": "https://dl.google.com/android/repository/emulator-darwin_x64-8420304.zip" } ], "displayName": "Android Emulator", "license": "android-sdk-license", "name": "emulator", "path": "emulator", - "revision": "31.2.9" + "revision": "31.2.10" }, - "31.3.7": { + "31.3.8": { "archives": [ { "os": "macosx", - "sha1": "0020b44623995a5a9a5b0d114f8fd942e9d3cbed", - "size": 347204784, - "url": "https://dl.google.com/android/repository/emulator-darwin_x64-8408431.zip" + "sha1": "7214e8384c97a7c9875142149d3bf9c940e9b5a0", + "size": 347222379, + "url": "https://dl.google.com/android/repository/emulator-darwin_x64-8598121.zip" }, { "os": "linux", - "sha1": "46ba0c398fcd2704bee015c95e44d8f317b7b720", - "size": 293765376, - "url": "https://dl.google.com/android/repository/emulator-linux_x64-8408431.zip" + "sha1": "0f781977a6cc5377b64444121ff75a513841a4fa", + "size": 293782881, + "url": "https://dl.google.com/android/repository/emulator-linux_x64-8598121.zip" }, { "os": "windows", - "sha1": "c09a35dd8c7eb7d8c53bf89c86019f5dbcd89b9d", - "size": 380137986, - "url": "https://dl.google.com/android/repository/emulator-windows_x64-8408431.zip" + "sha1": "b4f30bad4e68da41cc9bd44965259b2111a011a1", + "size": 380151866, + "url": "https://dl.google.com/android/repository/emulator-windows_x64-8598121.zip" } ], "displayName": "Android Emulator", "license": "android-sdk-preview-license", "name": "emulator", "path": "emulator", - "revision": "31.3.7" + "revision": "31.3.8" + }, + "31.3.9": { + "archives": [ + { + "os": "macosx", + "sha1": "6e7b549113252728cfe0992d58e8cb1790dce9d6", + "size": 347241742, + "url": "https://dl.google.com/android/repository/emulator-darwin_x64-8700579.zip" + }, + { + "os": "linux", + "sha1": "1c1a7ef65476d3de34f19455a0093cb68e8e90f7", + "size": 293801439, + "url": "https://dl.google.com/android/repository/emulator-linux_x64-8700579.zip" + }, + { + "os": "windows", + "sha1": "ea834211b199a7fcf6b6758a53c4594d01b44ab9", + "size": 380168712, + "url": "https://dl.google.com/android/repository/emulator-windows_x64-8700579.zip" + } + ], + "displayName": "Android Emulator", + "license": "android-sdk-license", + "name": "emulator", + "path": "emulator", + "revision": "31.3.9" } }, "extras": { @@ -4523,6 +4666,33 @@ "path": "ndk/23.1.7779620", "revision": "23.1.7779620" }, + "23.2.8568313": { + "archives": [ + { + "os": "macosx", + "sha1": "1fc65d8f6083f3f5cd01e0cf97c6adc10f4f076f", + "size": 982917530, + "url": "https://dl.google.com/android/repository/android-ndk-r23c-darwin.zip" + }, + { + "os": "linux", + "sha1": "e5053c126a47e84726d9f7173a04686a71f9a67a", + "size": 724733960, + "url": "https://dl.google.com/android/repository/android-ndk-r23c-linux.zip" + }, + { + "os": "windows", + "sha1": "f2c5def76a9de371f27d028864fe301ab4fe0cf8", + "size": 788336993, + "url": "https://dl.google.com/android/repository/android-ndk-r23c-windows.zip" + } + ], + "displayName": "NDK (Side by side) 23.2.8568313", + "license": "android-sdk-license", + "name": "ndk", + "path": "ndk/23.2.8568313", + "revision": "23.2.8568313" + }, "24.0.7856742-rc1": { "archives": [ { @@ -4684,6 +4854,60 @@ "name": "ndk", "path": "ndk/25.0.8221429", "revision": "25.0.8221429-rc2" + }, + "25.0.8355429-rc3": { + "archives": [ + { + "os": "macosx", + "sha1": "224594abb41357c20cb4a9f4a732c484b2e743ba", + "size": 748047157, + "url": "https://dl.google.com/android/repository/android-ndk-r25-beta3-darwin.zip" + }, + { + "os": "linux", + "sha1": "79c8db05e20edde0cbb02d2326e7b8405f7eb977", + "size": 510520692, + "url": "https://dl.google.com/android/repository/android-ndk-r25-beta3-linux.zip" + }, + { + "os": "windows", + "sha1": "7d2c398045f6bbad03f6fb2f2ba419a2a48ab1e7", + "size": 506142216, + "url": "https://dl.google.com/android/repository/android-ndk-r25-beta3-windows.zip" + } + ], + "displayName": "NDK (Side by side) 25.0.8355429", + "license": "android-sdk-preview-license", + "name": "ndk", + "path": "ndk/25.0.8355429", + "revision": "25.0.8355429-rc3" + }, + "25.0.8528842-rc4": { + "archives": [ + { + "os": "macosx", + "sha1": "d7f344ecc68518a8178d15b1b80e27bc5c69f00d", + "size": 716633626, + "url": "https://dl.google.com/android/repository/android-ndk-r25-beta4-darwin.zip" + }, + { + "os": "linux", + "sha1": "d13f688fd286709f0d950c75119ec9fcad8a47ff", + "size": 531018178, + "url": "https://dl.google.com/android/repository/android-ndk-r25-beta4-linux.zip" + }, + { + "os": "windows", + "sha1": "668b063c7c535c4f8be52c84acebb5779935203b", + "size": 464031742, + "url": "https://dl.google.com/android/repository/android-ndk-r25-beta4-windows.zip" + } + ], + "displayName": "NDK (Side by side) 25.0.8528842", + "license": "android-sdk-preview-license", + "name": "ndk", + "path": "ndk/25.0.8528842", + "revision": "25.0.8528842-rc4" } }, "ndk-bundle": { @@ -5381,32 +5605,32 @@ } }, "platform-tools": { - "33.0.1": { + "33.0.2": { "archives": [ { "os": "macosx", - "sha1": "82f7c23e9e4acf6c86991bb23cd5d9f861f7819f", - "size": 13131422, - "url": "https://dl.google.com/android/repository/platform-tools_r33.0.1-darwin.zip" + "sha1": "9b5661e0c18a2e5b6935e2b96bcc7be580cd6dcd", + "size": 13038676, + "url": "https://dl.google.com/android/repository/platform-tools_r33.0.2-darwin.zip" }, { "os": "linux", - "sha1": "4792ee4593e8e2395ddb87a3e82d60629eb0e977", - "size": 7449306, - "url": "https://dl.google.com/android/repository/platform-tools_r33.0.1-linux.zip" + "sha1": "6bf4f747ad929b02378b44ce083b4502d26109c7", + "size": 7406632, + "url": "https://dl.google.com/android/repository/platform-tools_r33.0.2-linux.zip" }, { "os": "windows", - "sha1": "e91ab59b5ddc5e387c5171b37c3813eaa2fa3846", - "size": 6331279, - "url": "https://dl.google.com/android/repository/platform-tools_r33.0.1-windows.zip" + "sha1": "2d7599f59b54f02c4ecd33d656091a3c1e55ad9c", + "size": 6304111, + "url": "https://dl.google.com/android/repository/platform-tools_r33.0.2-windows.zip" } ], "displayName": "Android SDK Platform-Tools", "license": "android-sdk-license", "name": "platform-tools", "path": "platform-tools", - "revision": "33.0.1" + "revision": "33.0.2" } }, "platforms": { @@ -5809,6 +6033,21 @@ "path": "platforms/android-32", "revision": "32" }, + "33": { + "archives": [ + { + "os": "all", + "sha1": "298f5800e37f3c089ab0eb58d4f6aef4058b689b", + "size": 67324871, + "url": "https://dl.google.com/android/repository/platform-33_r01.zip" + } + ], + "displayName": "Android SDK Platform 33", + "license": "android-sdk-license", + "name": "platforms", + "path": "platforms/android-33", + "revision": "33" + }, "4": { "archives": [ { @@ -5935,20 +6174,20 @@ "path": "platforms/android-9", "revision": "9" }, - "Tiramisu": { + "TiramisuPrivacySandbox": { "archives": [ { "os": "all", - "sha1": "2ac79862a909392d68d8ad503c45809e725d71f6", - "size": 67290653, - "url": "https://dl.google.com/android/repository/platform-Tiramisu_r02.zip" + "sha1": "8dd74a564f71c8381f5230682c5da291d230cc81", + "size": 67918949, + "url": "https://dl.google.com/android/repository/platform-TiramisuPrivacySandbox_r03.zip" } ], - "displayName": "Android SDK Platform Tiramisu", + "displayName": "Android SDK Platform TiramisuPrivacySandbox", "license": "android-sdk-license", "name": "platforms", - "path": "platforms/android-Tiramisu", - "revision": "Tiramisu" + "path": "platforms/android-TiramisuPrivacySandbox", + "revision": "TiramisuPrivacySandbox" } }, "skiaparser": { @@ -6304,6 +6543,21 @@ "name": "sources", "path": "sources/android-31", "revision": "31" + }, + "32": { + "archives": [ + { + "os": "all", + "sha1": "d7195c6de611b99d7ec3565eabe2fd21268b7f98", + "size": 46933291, + "url": "https://dl.google.com/android/repository/sources-32_r01.zip" + } + ], + "displayName": "Sources for Android 32", + "license": "android-sdk-license", + "name": "sources", + "path": "sources/android-32", + "revision": "32" } }, "tools": { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 92c47cbd5be2..ace695a85ddd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2659,6 +2659,8 @@ with pkgs; androidndkPkgs = androidndkPkgs_18b; androidndkPkgs_18b = (callPackage ../development/androidndk-pkgs {})."18b"; androidndkPkgs_21 = (callPackage ../development/androidndk-pkgs {})."21"; + androidndkPkgs_23b = (callPackage ../development/androidndk-pkgs {})."23b"; + androidndkPkgs_24 = (callPackage ../development/androidndk-pkgs {})."24"; androidsdk_9_0 = androidenv.androidPkgs_9_0.androidsdk; From 2a914f022c533d78a86a23d99fe72952af1be990 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Fri, 18 Feb 2022 12:22:09 +0900 Subject: [PATCH 3/5] update android targets to recommended ones --- lib/systems/examples.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index b26407117c85..03e8c6cb5382 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -57,23 +57,23 @@ rec { armv7a-android-prebuilt = { config = "armv7a-unknown-linux-androideabi"; rustc.config = "armv7-linux-androideabi"; - sdkVer = "29"; - ndkVer = "21"; + sdkVer = "28"; + ndkVer = "24"; useAndroidPrebuilt = true; } // platforms.armv7a-android; aarch64-android-prebuilt = { config = "aarch64-unknown-linux-android"; rustc.config = "aarch64-linux-android"; - sdkVer = "29"; - ndkVer = "21"; + sdkVer = "28"; + ndkVer = "24"; useAndroidPrebuilt = true; }; aarch64-android = { config = "aarch64-unknown-linux-android"; sdkVer = "30"; - ndkVer = "21"; + ndkVer = "24"; libc = "bionic"; useAndroidPrebuilt = false; useLLVM = true; From 539222e8d4bafaf783814c747e0ace40affa3761 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Sun, 26 Jun 2022 07:05:23 +0900 Subject: [PATCH 4/5] canExecute: check for android --- lib/systems/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/systems/default.nix b/lib/systems/default.nix index d9d0918c1cc6..25340825c4b5 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -36,6 +36,7 @@ rec { config = parse.tripleFromSystem final.parsed; # Determine whether we can execute binaries built for the provided platform. canExecute = platform: + final.isAndroid == platform.isAndroid && parse.isCompatible final.parsed.cpu platform.parsed.cpu && final.parsed.kernel == platform.parsed.kernel; isCompatible = _: throw "2022-05-23: isCompatible has been removed in favor of canExecute, refer to the 22.11 changelog for details"; From 2408ef3c6faa0ba0d513257378563ddc886f1020 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Wed, 29 Jun 2022 18:24:50 +0900 Subject: [PATCH 5/5] androidndk: remove legacy ndks allows us to remove python2 dependencies and lot more --- .../androidndk-pkgs/androidndk-pkgs.nix | 67 ++++--------------- pkgs/development/androidndk-pkgs/default.nix | 36 +--------- .../mobile/androidenv/ndk-bundle/default.nix | 12 +--- .../make_standalone_toolchain.py_18.patch | 44 ------------ pkgs/top-level/all-packages.nix | 3 +- 5 files changed, 19 insertions(+), 143 deletions(-) delete mode 100644 pkgs/development/mobile/androidenv/ndk-bundle/make_standalone_toolchain.py_18.patch diff --git a/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix b/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix index dc9802ea7f9e..2d5619620417 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 cd076653ebd7..a7001ce1d4a6 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 28c7ca62b26d..5d0e2c2b171f 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 7af2d44a0f20..000000000000 --- 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 ace695a85ddd..eb9b50788856 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";