diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 9c43d9b1bbc7..4c7dd9917919 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -45,7 +45,7 @@ rec { aarch64-android-prebuilt = rec { config = "aarch64-unknown-linux-android"; - sdkVer = "21"; + sdkVer = "24"; platform = platforms.aarch64-multiplatform; useAndroidPrebuilt = true; }; diff --git a/pkgs/development/mobile/androidenv/androidndk-pkgs.nix b/pkgs/development/mobile/androidenv/androidndk-pkgs.nix index 663a1f1ee8f4..1323466ea865 100644 --- a/pkgs/development/mobile/androidenv/androidndk-pkgs.nix +++ b/pkgs/development/mobile/androidenv/androidndk-pkgs.nix @@ -98,10 +98,19 @@ rec { # We use androidndk from the previous stage, else we waste time or get cycles # cross-compiling packages to wrap incorrectly wrap binaries we don't include # anyways. - libraries = { - name = "bionic-prebuilt"; - type = "derivation"; - outPath = "${buildAndroidndk}/libexec/${buildAndroidndk.name}/platforms/android-${hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/"; - drvPath = throw "fake derivation, build ${buildAndroidndk} to use"; - }; + libraries = + let + includePath = if buildAndroidndk.version == "10e" then + "${buildAndroidndk}/libexec/${buildAndroidndk.name}/platforms/android-${hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/include/" + else + "${buildAndroidndk}/libexec/${buildAndroidndk.name}/sysroot/usr/include"; + libPath = "${buildAndroidndk}/libexec/${buildAndroidndk.name}/platforms/android-${hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/lib/"; + in + runCommand "bionic-prebuilt" {} '' + mkdir -p $out + cp -r ${includePath} $out/include + chmod +w $out/include + ${lib.optionalString (lib.versionOlder buildAndroidndk.version "10e") "ln -s $out/include/${targetInfo.triple}/asm $out/include/asm"} + ln -s ${libPath} $out/lib + ''; } diff --git a/pkgs/development/mobile/androidenv/androidndk.nix b/pkgs/development/mobile/androidenv/androidndk.nix index d0bfe6c8100c..78e278be2376 100644 --- a/pkgs/development/mobile/androidenv/androidndk.nix +++ b/pkgs/development/mobile/androidenv/androidndk.nix @@ -5,6 +5,7 @@ stdenv.mkDerivation rec { name = "android-ndk-r${version}"; + inherit version; src = if stdenv.system == "x86_64-linux" then fetchurl { url = "https://dl.google.com/android/repository/${name}-linux-x86_64.zip"; diff --git a/pkgs/development/mobile/androidenv/default.nix b/pkgs/development/mobile/androidenv/default.nix index d122ffe241ea..3978ae1aeb7b 100644 --- a/pkgs/development/mobile/androidenv/default.nix +++ b/pkgs/development/mobile/androidenv/default.nix @@ -281,4 +281,19 @@ rec { inherit androidndk; targetAndroidndkPkgs = targetPackages.androidenv.androidndkPkgs; }; + + androidndkPkgs_10e = import ./androidndk-pkgs.nix { + inherit (buildPackages) + makeWrapper; + inherit (pkgs) + lib hostPlatform targetPlatform + 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 = buildPackages.buildPackages.androidenv.androidndk_10e; + androidndk = androidndk_10e; + targetAndroidndkPkgs = targetPackages.androidenv.androidndkPkgs_10e; + }; } diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix index 973be9831861..41b5fd99504d 100644 --- a/pkgs/stdenv/cross/default.nix +++ b/pkgs/stdenv/cross/default.nix @@ -41,7 +41,9 @@ in lib.init bootStages ++ [ targetPlatform = crossSystem; cc = if crossSystem.useiOSPrebuilt or false then buildPackages.darwin.iosSdkPkgs.clang - else if crossSystem.useAndroidPrebuilt + else if (crossSystem.useAndroidPrebuilt && crossSystem.is32bit) + then buildPackages.androidenv.androidndkPkgs_10e.gcc + else if (crossSystem.useAndroidPrebuilt && crossSystem.is64bit) then buildPackages.androidenv.androidndkPkgs.gcc else buildPackages.gcc; };