2022-06-16 17:23:12 +00:00
|
|
|
{ stdenv, lib, pkgs, pkgsHostHost, makeWrapper, autoPatchelfHook
|
2020-09-25 04:45:31 +00:00
|
|
|
, 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;
|
2022-06-16 17:23:12 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ]
|
|
|
|
++ lib.optionals stdenv.isLinux [ autoPatchelfHook ];
|
2021-12-06 16:07:01 +00:00
|
|
|
autoPatchelfIgnoreMissingDeps = true;
|
2022-10-30 15:09:59 +00:00
|
|
|
buildInputs = lib.optionals (os == "linux") [ pkgs.zlib ];
|
2020-09-25 04:45:31 +00:00
|
|
|
patchInstructions = lib.optionalString (os == "linux") (''
|
2020-04-24 23:36:52 +00:00
|
|
|
patchShebangs .
|
|
|
|
|
|
|
|
# TODO: allow this stuff
|
|
|
|
rm -rf docs tests
|
|
|
|
|
2022-07-18 16:21:45 +00:00
|
|
|
# Ndk now has a prebuilt toolchains inside, the file layout has changed, we do a symlink
|
|
|
|
# to still support the old standalone toolchains builds.
|
|
|
|
if [ -d $out/libexec/android-sdk/ndk ] && [ ! -d $out/libexec/android-sdk/ndk-bundle ]; then
|
|
|
|
ln -sf $out/libexec/android-sdk/ndk/${package.revision} $out/libexec/android-sdk/ndk-bundle
|
2022-08-12 12:06:08 +00:00
|
|
|
elif [ ! -d $out/libexec/android-sdk/ndk-bundle ]; then
|
2022-07-18 16:21:45 +00:00
|
|
|
echo "The ndk-bundle layout has changed. The nix expressions have to be updated!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# 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
|
|
|
|
}
|