Merge pull request #45757 from bkchr/androidndk_standalone_toolchain

Androidndk standalone toolchain support
This commit is contained in:
Matthew Bauer 2018-09-07 19:34:49 -05:00 committed by GitHub
commit 1acfddb69a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,12 +1,18 @@
{ stdenv, fetchurl, zlib, ncurses5, unzip, lib, makeWrapper
, coreutils, file, findutils, gawk, gnugrep, gnused, jdk, which
, platformTools, python3, libcxx, version, sha256
, platformTools, python3, libcxx, version, sha256, bash, runCommand
, fullNDK ? false # set to true if you want other parts of the NDK
# that is not used by Nixpkgs like sources,
# examples, docs, or LLVM toolchains
}:
stdenv.mkDerivation rec {
let
makeStandaloneToolchain = api: arch: let
full_ndk = (ndk true);
in runCommand "makeStandaloneToolchain-${version}" {} ''
${full_ndk}/libexec/${full_ndk.name}/build/tools/make_standalone_toolchain.py --api ${toString api} --arch ${arch} --install-dir $out
'';
ndk = fullNDK: stdenv.mkDerivation rec {
name = "android-ndk-r${version}";
inherit version;
@ -35,8 +41,6 @@ stdenv.mkDerivation rec {
cd $out/libexec
unzip -qq $src
patchShebangs ${pkg_path}
# so that it doesn't fail because of read-only permissions set
cd -
${if (version == "10e") then
@ -49,10 +53,16 @@ stdenv.mkDerivation rec {
''
patch -p1 \
--no-backup-if-mismatch \
-d $out/libexec/${name} < ${ ./. + "/make_standalone_toolchain.py_${version}.patch" }
-d $out/libexec/${name} < ${ ./. + "/make_standalone_toolchain.py_" + "${version}" + ".patch" }
sed -i 's,#!/usr/bin/env python,#!${python3}/bin/python,g' ${pkg_path}/build/tools/make_standalone_toolchain.py
sed -i 's,#!/bin/bash,#!${bash}/bin/bash,g' ${pkg_path}/build/tools/make_standalone_toolchain.py
wrapProgram ${pkg_path}/build/tools/make_standalone_toolchain.py --prefix PATH : "${runtime_paths}"
''
}
patchShebangs ${pkg_path}
cd ${pkg_path}
'' + lib.optionalString (!fullNDK) ''
@ -93,4 +103,8 @@ stdenv.mkDerivation rec {
hydraPlatforms = [];
license = stdenv.lib.licenses.asl20;
};
}
};
passthru = {
inherit makeStandaloneToolchain;
};
in lib.extendDerivation true passthru (ndk fullNDK)