Initial attempt to restore Android NDK cross building

This commit is contained in:
Sander van der Burg
2018-12-18 22:58:12 +01:00
parent 8122431953
commit 51428627eb
4 changed files with 49 additions and 45 deletions
@@ -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
'';
}
+26 -28
View File
@@ -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;
};
}