2020-09-25 04:45:31 +00:00
|
|
|
{ lib, pkgs, pkgsHostHost, makeWrapper, autoPatchelfHook
|
|
|
|
, deployAndroidPackage, package, os, platform-tools
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
2020-09-25 04:45:31 +00:00
|
|
|
runtime_paths = lib.makeBinPath (with pkgsHostHost; [
|
|
|
|
coreutils file findutils gawk gnugrep gnused jdk python3 which
|
|
|
|
]) + ":${platform-tools}/platform-tools";
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
deployAndroidPackage {
|
|
|
|
inherit package os;
|
2021-01-15 22:18:51 +00:00
|
|
|
nativeBuildInputs = [ autoPatchelfHook makeWrapper ];
|
2021-12-06 16:07:01 +00:00
|
|
|
autoPatchelfIgnoreMissingDeps = true;
|
2021-01-15 22:18:51 +00:00
|
|
|
buildInputs = lib.optional (os == "linux") [ pkgs.glibc pkgs.stdenv.cc.cc pkgs.python2 pkgs.ncurses5 pkgs.zlib pkgs.libcxx.out pkgs.libxml2 ];
|
2020-09-25 04:45:31 +00:00
|
|
|
patchInstructions = lib.optionalString (os == "linux") (''
|
2020-04-24 23:36:52 +00:00
|
|
|
patchShebangs .
|
|
|
|
|
2021-04-05 15:23:46 +00:00
|
|
|
# Fix the shebangs of the auto-generated scripts.
|
|
|
|
substituteInPlace ./build/tools/make_standalone_toolchain.py \
|
|
|
|
--replace '#!/bin/bash' '#!${pkgs.bash}/bin/bash'
|
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
'' + lib.optionalString (builtins.compareVersions (lib.getVersion package) "21" > 0) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
patch -p1 \
|
2021-01-15 22:18:51 +00:00
|
|
|
--no-backup-if-mismatch < ${./make_standalone_toolchain.py_18.patch} || true
|
2021-04-05 15:23:46 +00:00
|
|
|
wrapProgram ./build/tools/make_standalone_toolchain.py --prefix PATH : "${runtime_paths}"
|
2020-09-25 04:45:31 +00:00
|
|
|
'' + ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# TODO: allow this stuff
|
|
|
|
rm -rf docs tests
|
|
|
|
|
|
|
|
# Patch the executables of the toolchains, but not the libraries -- they are needed for crosscompiling
|
2021-01-15 22:18:51 +00:00
|
|
|
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
|
|
|
|
fi
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
if [ -d $out/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib64 ]; then
|
|
|
|
addAutoPatchelfSearchPath $out/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/lib64
|
|
|
|
fi
|
|
|
|
|
|
|
|
find toolchains -type d -name bin -or -name lib64 | while read dir; do
|
2020-04-24 23:36:52 +00:00
|
|
|
autoPatchelf "$dir"
|
|
|
|
done
|
|
|
|
|
|
|
|
# fix ineffective PROGDIR / MYNDKDIR determination
|
2021-01-15 22:18:51 +00:00
|
|
|
for progname in ndk-build; do
|
|
|
|
sed -i -e 's|^PROGDIR=`dirname $0`|PROGDIR=`dirname $(readlink -f $(which $0))`|' $progname
|
2020-04-24 23:36:52 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# Patch executables
|
|
|
|
autoPatchelf prebuilt/linux-x86_64
|
|
|
|
|
|
|
|
# wrap
|
2021-01-15 22:18:51 +00:00
|
|
|
for progname in ndk-build; do
|
|
|
|
wrapProgram "$(pwd)/$progname" --prefix PATH : "${runtime_paths}"
|
2020-04-24 23:36:52 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# make some executables available in PATH
|
|
|
|
mkdir -p $out/bin
|
2021-01-15 22:18:51 +00:00
|
|
|
for progname in ndk-build; do
|
|
|
|
ln -sf ../libexec/android-sdk/ndk-bundle/$progname $out/bin/$progname
|
2020-04-24 23:36:52 +00:00
|
|
|
done
|
2020-09-25 04:45:31 +00:00
|
|
|
'');
|
2020-04-24 23:36:52 +00:00
|
|
|
noAuditTmpdir = true; # Audit script gets invoked by the build/ component in the path for the make standalone script
|
|
|
|
}
|