2014-11-24 09:16:08 +01:00
|
|
|
{ stdenv, fetchurl, zlib, ncurses, p7zip, lib, makeWrapper
|
|
|
|
, coreutils, file, findutils, gawk, gnugrep, gnused, jdk, which
|
|
|
|
, platformTools
|
2014-04-20 11:29:10 +02:00
|
|
|
}:
|
|
|
|
|
2014-11-24 08:57:18 +01:00
|
|
|
assert stdenv.isLinux;
|
|
|
|
|
2014-04-20 11:29:10 +02:00
|
|
|
stdenv.mkDerivation rec {
|
2015-10-18 12:02:23 +02:00
|
|
|
name = "android-ndk-r10e";
|
2014-04-20 11:29:10 +02:00
|
|
|
|
|
|
|
src = if stdenv.system == "i686-linux"
|
|
|
|
then fetchurl {
|
2014-11-10 23:54:44 +01:00
|
|
|
url = "http://dl.google.com/android/ndk/${name}-linux-x86.bin";
|
2015-10-18 12:02:23 +02:00
|
|
|
sha256 = "1xbxra5v3bm6cmxyx8yyya5r93jh5m064aibgwd396xdm8jpvc4j";
|
2014-04-20 11:29:10 +02:00
|
|
|
}
|
|
|
|
else if stdenv.system == "x86_64-linux" then fetchurl {
|
2014-11-10 23:54:44 +01:00
|
|
|
url = "http://dl.google.com/android/ndk/${name}-linux-x86_64.bin";
|
2015-10-18 12:02:23 +02:00
|
|
|
sha256 = "0nhxixd0mq4ib176ya0hclnlbmhm8f2lab6i611kiwbzyqinfb8h";
|
2014-04-20 11:29:10 +02:00
|
|
|
}
|
2014-11-10 23:54:44 +01:00
|
|
|
else throw "platform ${stdenv.system} not supported!";
|
2014-04-20 11:29:10 +02:00
|
|
|
|
2014-11-24 09:16:08 +01:00
|
|
|
phases = "buildPhase";
|
2014-04-20 11:29:10 +02:00
|
|
|
|
2018-02-21 00:31:16 +01:00
|
|
|
nativeBuildInputs = [ p7zip makeWrapper ];
|
2014-11-10 23:54:44 +01:00
|
|
|
|
2014-11-24 09:16:08 +01:00
|
|
|
buildCommand = let
|
|
|
|
bin_path = "$out/bin";
|
|
|
|
pkg_path = "$out/libexec/${name}";
|
|
|
|
sed_script_1 =
|
|
|
|
"'s|^PROGDIR=`dirname $0`" +
|
|
|
|
"|PROGDIR=`dirname $(readlink -f $(which $0))`|'";
|
|
|
|
sed_script_2 =
|
|
|
|
"'s|^MYNDKDIR=`dirname $0`" +
|
|
|
|
"|MYNDKDIR=`dirname $(readlink -f $(which $0))`|'";
|
2016-04-13 14:53:51 +02:00
|
|
|
runtime_paths = (lib.makeBinPath [
|
2014-11-24 09:16:08 +01:00
|
|
|
coreutils file findutils
|
|
|
|
gawk gnugrep gnused
|
|
|
|
jdk
|
|
|
|
which
|
|
|
|
]) + ":${platformTools}/platform-tools";
|
|
|
|
in ''
|
2014-04-20 11:29:10 +02:00
|
|
|
set -x
|
2014-11-24 09:16:08 +01:00
|
|
|
mkdir -pv $out/libexec
|
|
|
|
cd $out/libexec
|
2014-11-10 23:54:44 +01:00
|
|
|
7z x $src
|
2014-09-25 11:59:16 +02:00
|
|
|
|
|
|
|
# so that it doesn't fail because of read-only permissions set
|
2014-11-24 09:16:08 +01:00
|
|
|
cd -
|
|
|
|
patch -p1 \
|
|
|
|
--no-backup-if-mismatch \
|
|
|
|
-d $out/libexec/${name} < ${ ./make-standalone-toolchain.patch }
|
|
|
|
cd ${pkg_path}
|
2014-09-25 11:59:16 +02:00
|
|
|
|
2014-04-20 11:29:10 +02:00
|
|
|
find $out \( \
|
|
|
|
\( -type f -a -name "*.so*" \) -o \
|
2015-09-06 10:21:43 +02:00
|
|
|
\( -type f -a -perm -0100 \) \
|
2015-04-26 19:54:51 +02:00
|
|
|
\) -exec patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-*so.? \
|
2016-07-07 18:23:25 +02:00
|
|
|
--set-rpath ${stdenv.lib.makeLibraryPath [ zlib.out ncurses ]} {} \;
|
2014-11-24 09:16:08 +01:00
|
|
|
# fix ineffective PROGDIR / MYNDKDIR determination
|
|
|
|
for i in ndk-build ndk-gdb ndk-gdb-py
|
|
|
|
do
|
|
|
|
sed -i -e ${sed_script_1} $i
|
|
|
|
done
|
|
|
|
sed -i -e ${sed_script_2} ndk-which
|
|
|
|
# a bash script
|
|
|
|
patchShebangs ndk-which
|
2017-08-17 17:46:01 +02:00
|
|
|
# wrap
|
|
|
|
for i in ndk-build ndk-gdb ndk-gdb-py ndk-which
|
|
|
|
do
|
|
|
|
wrapProgram "$(pwd)/$i" --prefix PATH : "${runtime_paths}"
|
|
|
|
done
|
2014-11-24 09:16:08 +01:00
|
|
|
# make some executables available in PATH
|
|
|
|
mkdir -pv ${bin_path}
|
|
|
|
for i in \
|
|
|
|
ndk-build ndk-depends ndk-gdb ndk-gdb-py ndk-gdb.py ndk-stack ndk-which
|
|
|
|
do
|
|
|
|
ln -sf ${pkg_path}/$i ${bin_path}/$i
|
|
|
|
done
|
2014-04-20 11:29:10 +02:00
|
|
|
'';
|
2016-08-02 18:06:29 +02:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
platforms = stdenv.lib.platforms.linux;
|
2016-08-02 21:55:43 +02:00
|
|
|
hydraPlatforms = [];
|
2016-08-02 18:06:29 +02:00
|
|
|
};
|
2014-04-20 11:29:10 +02:00
|
|
|
}
|