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 {
|
armv5te-android-prebuilt = rec {
|
||||||
config = "armv5tel-unknown-linux-androideabi";
|
config = "armv5tel-unknown-linux-androideabi";
|
||||||
sdkVer = "21";
|
sdkVer = "21";
|
||||||
ndkVer = "10e";
|
ndkVer = "18b";
|
||||||
platform = platforms.armv5te-android;
|
platform = platforms.armv5te-android;
|
||||||
useAndroidPrebuilt = true;
|
useAndroidPrebuilt = true;
|
||||||
};
|
};
|
||||||
@ -55,7 +55,7 @@ rec {
|
|||||||
armv7a-android-prebuilt = rec {
|
armv7a-android-prebuilt = rec {
|
||||||
config = "armv7a-unknown-linux-androideabi";
|
config = "armv7a-unknown-linux-androideabi";
|
||||||
sdkVer = "24";
|
sdkVer = "24";
|
||||||
ndkVer = "17c";
|
ndkVer = "18b";
|
||||||
platform = platforms.armv7a-android;
|
platform = platforms.armv7a-android;
|
||||||
useAndroidPrebuilt = true;
|
useAndroidPrebuilt = true;
|
||||||
};
|
};
|
||||||
@ -63,7 +63,7 @@ rec {
|
|||||||
aarch64-android-prebuilt = rec {
|
aarch64-android-prebuilt = rec {
|
||||||
config = "aarch64-unknown-linux-android";
|
config = "aarch64-unknown-linux-android";
|
||||||
sdkVer = "24";
|
sdkVer = "24";
|
||||||
ndkVer = "17c";
|
ndkVer = "18b";
|
||||||
platform = platforms.aarch64-multiplatform;
|
platform = platforms.aarch64-multiplatform;
|
||||||
useAndroidPrebuilt = true;
|
useAndroidPrebuilt = true;
|
||||||
};
|
};
|
||||||
|
@ -38,14 +38,16 @@ let
|
|||||||
|
|
||||||
hostInfo = ndkInfoFun stdenv.hostPlatform;
|
hostInfo = ndkInfoFun stdenv.hostPlatform;
|
||||||
targetInfo = ndkInfoFun stdenv.targetPlatform;
|
targetInfo = ndkInfoFun stdenv.targetPlatform;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
# Misc tools
|
# Misc tools
|
||||||
binaries = let
|
binaries = let
|
||||||
ndkBinDir =
|
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" {
|
in runCommand "ndk-gcc-binutils" {
|
||||||
isGNU = true; # for cc-wrapper
|
isGNU = true; # for cc-wrapper
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
@ -54,8 +56,15 @@ rec {
|
|||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
for prog in ${ndkBinDir}/${targetInfo.triple}-*; do
|
for prog in ${ndkBinDir}/${targetInfo.triple}-*; do
|
||||||
prog_suffix=$(basename $prog | sed 's/${targetInfo.triple}-//')
|
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
|
done
|
||||||
|
|
||||||
|
ln -s $out/bin/${stdenv.targetPlatform.config}-ld $out/bin/ld
|
||||||
|
ln -s ${ndkGCCLibDir} $out/lib
|
||||||
'';
|
'';
|
||||||
|
|
||||||
binutils = wrapBintoolsWith {
|
binutils = wrapBintoolsWith {
|
||||||
@ -109,18 +118,16 @@ rec {
|
|||||||
# anyways.
|
# anyways.
|
||||||
libraries =
|
libraries =
|
||||||
let
|
let
|
||||||
includePath = if buildAndroidndk.version == "10e" then
|
includePath = "${buildAndroidndk}/libexec/android-sdk/ndk-bundle/sysroot/usr/include";
|
||||||
"${buildAndroidndk}/libexec/${buildAndroidndk.name}/platforms/android-${stdenv.hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/include/"
|
asmIncludePath = "${buildAndroidndk}/libexec/android-sdk/ndk-bundle/sysroot/usr/include/${targetInfo.triple}";
|
||||||
else
|
libPath = "${buildAndroidndk}/libexec/android-sdk/ndk-bundle/platforms/android-${stdenv.hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/lib/";
|
||||||
"${buildAndroidndk}/libexec/${buildAndroidndk.name}/sysroot/usr/include";
|
|
||||||
libPath = "${buildAndroidndk}/libexec/${buildAndroidndk.name}/platforms/android-${stdenv.hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/lib/";
|
|
||||||
in
|
in
|
||||||
runCommand "bionic-prebuilt" {} ''
|
runCommand "bionic-prebuilt" {} ''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
cp -r ${includePath} $out/include
|
cp -r ${includePath} $out/include
|
||||||
|
chmod u+w $out/include
|
||||||
|
cp -r ${asmIncludePath}/* $out/include
|
||||||
chmod +w $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
|
ln -s ${libPath} $out/lib
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
@ -3,34 +3,32 @@
|
|||||||
}:
|
}:
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
"18b" =
|
||||||
|
let
|
||||||
|
ndkVersion = "18.1.5063045";
|
||||||
|
|
||||||
"17c" = import ./androidndk-pkgs.nix {
|
buildAndroidComposition = buildPackages.buildPackages.androidenv.composeAndroidPackages {
|
||||||
inherit (buildPackages)
|
includeNDK = true;
|
||||||
makeWrapper;
|
inherit ndkVersion;
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
"10e" = import ./androidndk-pkgs.nix {
|
androidComposition = androidenv.composeAndroidPackages {
|
||||||
inherit (buildPackages)
|
includeNDK = true;
|
||||||
makeWrapper;
|
inherit ndkVersion;
|
||||||
inherit (pkgs)
|
};
|
||||||
lib stdenv
|
in
|
||||||
runCommand wrapBintoolsWith wrapCCWith;
|
import ./androidndk-pkgs.nix {
|
||||||
# buildPackages.foo rather than buildPackages.buildPackages.foo would work,
|
inherit (buildPackages)
|
||||||
# but for splicing messing up on infinite recursion for the variants we
|
makeWrapper;
|
||||||
# *dont't* use. Using this workaround, but also making a test to ensure
|
inherit (pkgs)
|
||||||
# these two really are the same.
|
lib stdenv
|
||||||
buildAndroidndk = buildPackages.buildPackages.androidenv.androidndk_10e;
|
runCommand wrapBintoolsWith wrapCCWith;
|
||||||
androidndk = androidenv.androidndk_10e;
|
# buildPackages.foo rather than buildPackages.buildPackages.foo would work,
|
||||||
targetAndroidndkPkgs = targetPackages.androidndkPkgs_10e;
|
# 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;
|
licenseAccepted = config.android_sdk.accept_license or false;
|
||||||
};
|
};
|
||||||
|
|
||||||
androidndkPkgs = androidndkPkgs_17c;
|
androidndkPkgs = androidndkPkgs_18b;
|
||||||
androidndkPkgs_17c = (callPackage ../development/androidndk-pkgs {})."17c";
|
androidndkPkgs_18b = (callPackage ../development/androidndk-pkgs {})."18b";
|
||||||
androidndkPkgs_10e = (callPackage ../development/androidndk-pkgs {})."10e";
|
|
||||||
|
|
||||||
androidsdk_9_0 = androidenv.androidPkgs_9_0.androidsdk;
|
androidsdk_9_0 = androidenv.androidPkgs_9_0.androidsdk;
|
||||||
|
|
||||||
@ -9353,7 +9352,7 @@ in
|
|||||||
|
|
||||||
# TODO(@Ericson2314): Build bionic libc from source
|
# TODO(@Ericson2314): Build bionic libc from source
|
||||||
bionic = assert stdenv.hostPlatform.useAndroidPrebuilt;
|
bionic = assert stdenv.hostPlatform.useAndroidPrebuilt;
|
||||||
androidenv."androidndkPkgs_${stdenv.hostPlatform.ndkVer}".libraries;
|
pkgs."androidndkPkgs_${stdenv.hostPlatform.ndkVer}".libraries;
|
||||||
|
|
||||||
bobcat = callPackage ../development/libraries/bobcat { };
|
bobcat = callPackage ../development/libraries/bobcat { };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user