mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-22 14:45:27 +00:00
Initial attempt to restore Android NDK cross building
This commit is contained in:
parent
8122431953
commit
51428627eb
|
@ -47,7 +47,7 @@ rec {
|
|||
armv5te-android-prebuilt = rec {
|
||||
config = "armv5tel-unknown-linux-androideabi";
|
||||
sdkVer = "21";
|
||||
ndkVer = "10e";
|
||||
ndkVer = "18b";
|
||||
platform = platforms.armv5te-android;
|
||||
useAndroidPrebuilt = true;
|
||||
};
|
||||
|
@ -55,7 +55,7 @@ rec {
|
|||
armv7a-android-prebuilt = rec {
|
||||
config = "armv7a-unknown-linux-androideabi";
|
||||
sdkVer = "24";
|
||||
ndkVer = "17c";
|
||||
ndkVer = "18b";
|
||||
platform = platforms.armv7a-android;
|
||||
useAndroidPrebuilt = true;
|
||||
};
|
||||
|
@ -63,7 +63,7 @@ rec {
|
|||
aarch64-android-prebuilt = rec {
|
||||
config = "aarch64-unknown-linux-android";
|
||||
sdkVer = "24";
|
||||
ndkVer = "17c";
|
||||
ndkVer = "18b";
|
||||
platform = platforms.aarch64-multiplatform;
|
||||
useAndroidPrebuilt = true;
|
||||
};
|
||||
|
|
|
@ -38,14 +38,16 @@ let
|
|||
|
||||
hostInfo = ndkInfoFun stdenv.hostPlatform;
|
||||
targetInfo = ndkInfoFun stdenv.targetPlatform;
|
||||
|
||||
in
|
||||
|
||||
rec {
|
||||
# Misc tools
|
||||
binaries = let
|
||||
ndkBinDir =
|
||||
"${androidndk}/libexec/${androidndk.name}/toolchains/${targetInfo.triple}-${targetInfo.gccVer}/prebuilt/${hostInfo.double}/bin";
|
||||
"${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/${targetInfo.triple}-${targetInfo.gccVer}/prebuilt/${hostInfo.double}/bin";
|
||||
ndkGCCLibDir =
|
||||
"${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/${targetInfo.triple}-${targetInfo.gccVer}/prebuilt/${hostInfo.double}/lib/gcc/${targetInfo.triple}/4.9.x";
|
||||
|
||||
in runCommand "ndk-gcc-binutils" {
|
||||
isGNU = true; # for cc-wrapper
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
@ -54,8 +56,15 @@ rec {
|
|||
mkdir -p $out/bin
|
||||
for prog in ${ndkBinDir}/${targetInfo.triple}-*; do
|
||||
prog_suffix=$(basename $prog | sed 's/${targetInfo.triple}-//')
|
||||
ln -s $prog $out/bin/${stdenv.targetPlatform.config}-$prog_suffix
|
||||
cat > $out/bin/${stdenv.targetPlatform.config}-$prog_suffix <<EOF
|
||||
#! ${stdenv.shell} -e
|
||||
$prog "\$@"
|
||||
EOF
|
||||
chmod +x $out/bin/${stdenv.targetPlatform.config}-$prog_suffix
|
||||
done
|
||||
|
||||
ln -s $out/bin/${stdenv.targetPlatform.config}-ld $out/bin/ld
|
||||
ln -s ${ndkGCCLibDir} $out/lib
|
||||
'';
|
||||
|
||||
binutils = wrapBintoolsWith {
|
||||
|
@ -109,18 +118,16 @@ rec {
|
|||
# anyways.
|
||||
libraries =
|
||||
let
|
||||
includePath = if buildAndroidndk.version == "10e" then
|
||||
"${buildAndroidndk}/libexec/${buildAndroidndk.name}/platforms/android-${stdenv.hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/include/"
|
||||
else
|
||||
"${buildAndroidndk}/libexec/${buildAndroidndk.name}/sysroot/usr/include";
|
||||
libPath = "${buildAndroidndk}/libexec/${buildAndroidndk.name}/platforms/android-${stdenv.hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/lib/";
|
||||
includePath = "${buildAndroidndk}/libexec/android-sdk/ndk-bundle/sysroot/usr/include";
|
||||
asmIncludePath = "${buildAndroidndk}/libexec/android-sdk/ndk-bundle/sysroot/usr/include/${targetInfo.triple}";
|
||||
libPath = "${buildAndroidndk}/libexec/android-sdk/ndk-bundle/platforms/android-${stdenv.hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/lib/";
|
||||
in
|
||||
runCommand "bionic-prebuilt" {} ''
|
||||
mkdir -p $out
|
||||
cp -r ${includePath} $out/include
|
||||
chmod u+w $out/include
|
||||
cp -r ${asmIncludePath}/* $out/include
|
||||
chmod +w $out/include
|
||||
${lib.optionalString (lib.versionOlder "10e" buildAndroidndk.version)
|
||||
"ln -s $out/include/${hostInfo.triple}/asm $out/include/asm"}
|
||||
ln -s ${libPath} $out/lib
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -3,34 +3,32 @@
|
|||
}:
|
||||
|
||||
rec {
|
||||
"18b" =
|
||||
let
|
||||
ndkVersion = "18.1.5063045";
|
||||
|
||||
"17c" = import ./androidndk-pkgs.nix {
|
||||
inherit (buildPackages)
|
||||
makeWrapper;
|
||||
inherit (pkgs)
|
||||
lib 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 = buildPackages.buildPackages.androidenv.androidndk_17c;
|
||||
androidndk = androidenv.androidndk_17c;
|
||||
targetAndroidndkPkgs = targetPackages.androidndkPkgs_17c;
|
||||
};
|
||||
buildAndroidComposition = buildPackages.buildPackages.androidenv.composeAndroidPackages {
|
||||
includeNDK = true;
|
||||
inherit ndkVersion;
|
||||
};
|
||||
|
||||
"10e" = import ./androidndk-pkgs.nix {
|
||||
inherit (buildPackages)
|
||||
makeWrapper;
|
||||
inherit (pkgs)
|
||||
lib 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 = buildPackages.buildPackages.androidenv.androidndk_10e;
|
||||
androidndk = androidenv.androidndk_10e;
|
||||
targetAndroidndkPkgs = targetPackages.androidndkPkgs_10e;
|
||||
};
|
||||
androidComposition = androidenv.composeAndroidPackages {
|
||||
includeNDK = true;
|
||||
inherit ndkVersion;
|
||||
};
|
||||
in
|
||||
import ./androidndk-pkgs.nix {
|
||||
inherit (buildPackages)
|
||||
makeWrapper;
|
||||
inherit (pkgs)
|
||||
lib 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;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -834,9 +834,8 @@ in
|
|||
licenseAccepted = config.android_sdk.accept_license or false;
|
||||
};
|
||||
|
||||
androidndkPkgs = androidndkPkgs_17c;
|
||||
androidndkPkgs_17c = (callPackage ../development/androidndk-pkgs {})."17c";
|
||||
androidndkPkgs_10e = (callPackage ../development/androidndk-pkgs {})."10e";
|
||||
androidndkPkgs = androidndkPkgs_18b;
|
||||
androidndkPkgs_18b = (callPackage ../development/androidndk-pkgs {})."18b";
|
||||
|
||||
androidsdk_9_0 = androidenv.androidPkgs_9_0.androidsdk;
|
||||
|
||||
|
@ -9353,7 +9352,7 @@ in
|
|||
|
||||
# TODO(@Ericson2314): Build bionic libc from source
|
||||
bionic = assert stdenv.hostPlatform.useAndroidPrebuilt;
|
||||
androidenv."androidndkPkgs_${stdenv.hostPlatform.ndkVer}".libraries;
|
||||
pkgs."androidndkPkgs_${stdenv.hostPlatform.ndkVer}".libraries;
|
||||
|
||||
bobcat = callPackage ../development/libraries/bobcat { };
|
||||
|
||||
|
|
Loading…
Reference in a new issue