2015-10-15 15:42:24 +01:00
|
|
|
{stdenv, stdenv_32bit, fetchurl, unzip, zlib_32bit, ncurses_32bit}:
|
2013-07-31 15:00:57 +01:00
|
|
|
|
2015-05-02 14:15:29 +01:00
|
|
|
stdenv.mkDerivation rec {
|
2015-10-06 13:27:49 +01:00
|
|
|
version = "23.0.1";
|
2015-05-02 14:15:29 +01:00
|
|
|
name = "android-build-tools-r${version}";
|
2013-07-31 15:00:57 +01:00
|
|
|
src = if (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
|
|
|
|
then fetchurl {
|
2015-10-06 13:27:49 +01:00
|
|
|
url = "https://dl.google.com/android/repository/build-tools_r${version}-linux.zip";
|
|
|
|
sha1 = "b6ba7c399d5fa487d95289d8832e4ad943aed556";
|
2013-07-31 15:00:57 +01:00
|
|
|
}
|
|
|
|
else if stdenv.system == "x86_64-darwin" then fetchurl {
|
2015-10-06 13:27:49 +01:00
|
|
|
url = "https://dl.google.com/android/repository/build-tools_r${version}-macosx.zip";
|
|
|
|
sha1 = "d96ec1522721e9a179ae2c591c99f75d31d39718";
|
2013-07-31 15:00:57 +01:00
|
|
|
}
|
|
|
|
else throw "System ${stdenv.system} not supported!";
|
2014-12-16 07:22:55 +00:00
|
|
|
|
2013-07-31 15:00:57 +01:00
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/build-tools
|
|
|
|
cd $out/build-tools
|
|
|
|
unzip $src
|
2016-01-17 23:42:54 +00:00
|
|
|
mv android-* ${version}
|
2013-07-31 15:00:57 +01:00
|
|
|
|
|
|
|
${stdenv.lib.optionalString (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
|
|
|
|
''
|
2016-01-17 23:42:54 +00:00
|
|
|
cd ${version}
|
2013-07-31 15:00:57 +01:00
|
|
|
|
|
|
|
# Patch the interpreter
|
2016-07-07 17:23:25 +01:00
|
|
|
for i in aidl bcc_compat dexdump llvm-rs-cc
|
2013-07-31 15:00:57 +01:00
|
|
|
do
|
2015-04-26 18:54:51 +01:00
|
|
|
patchelf --set-interpreter ${stdenv_32bit.cc.libc.out}/lib/ld-linux.so.2 $i
|
2013-07-31 15:00:57 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
# These binaries need to find libstdc++ and libgcc_s
|
2015-10-06 13:27:49 +01:00
|
|
|
for i in aidl lib/libLLVM.so
|
2013-07-31 15:00:57 +01:00
|
|
|
do
|
2016-06-19 03:26:34 +01:00
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc.lib}/lib $i
|
2013-07-31 15:00:57 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
# These binaries need to find libstdc++, libgcc_s and libraries in the current folder
|
2015-10-15 15:42:24 +01:00
|
|
|
for i in lib/libbcc.so lib/libbcinfo.so lib/libclang.so aidl
|
2013-07-31 15:00:57 +01:00
|
|
|
do
|
2016-06-19 03:26:34 +01:00
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc.lib}/lib:`pwd`/lib $i
|
2013-07-31 15:00:57 +01:00
|
|
|
done
|
2015-10-15 15:42:24 +01:00
|
|
|
|
|
|
|
# Create link to make libtinfo.so.5 work
|
2016-06-19 03:26:34 +01:00
|
|
|
ln -s ${ncurses_32bit.out}/lib/libncurses.so.5 `pwd`/lib/libtinfo.so.5
|
2015-10-15 15:42:24 +01:00
|
|
|
|
|
|
|
# These binaries need to find libstdc++, libgcc_s, ncurses, and libraries in the current folder
|
|
|
|
for i in bcc_compat llvm-rs-cc
|
|
|
|
do
|
2016-06-19 03:26:34 +01:00
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc.lib}/lib:${ncurses_32bit.out}/lib:`pwd`/lib $i
|
2013-07-31 15:00:57 +01:00
|
|
|
done
|
2014-09-01 07:37:43 +01:00
|
|
|
|
|
|
|
# These binaries also need zlib in addition to libstdc++
|
2016-07-07 17:23:25 +01:00
|
|
|
for i in arm-linux-androideabi-ld i686-linux-android-ld mipsel-linux-android-ld split-select aapt zipalign
|
2014-09-01 07:37:43 +01:00
|
|
|
do
|
2015-04-26 18:54:51 +01:00
|
|
|
patchelf --set-interpreter ${stdenv_32bit.cc.libc.out}/lib/ld-linux.so.2 $i
|
2016-06-19 03:26:34 +01:00
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc.lib}/lib:${zlib_32bit.out}/lib:`pwd`/lib $i
|
2014-09-01 07:37:43 +01:00
|
|
|
done
|
2013-07-31 15:00:57 +01:00
|
|
|
|
|
|
|
# These binaries need to find libstdc++, libgcc_s, and zlib
|
|
|
|
for i in aapt dexdump
|
|
|
|
do
|
2016-06-19 03:26:34 +01:00
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc.lib}/lib:${zlib_32bit.out}/lib:`pwd`/lib $i
|
2013-07-31 15:00:57 +01:00
|
|
|
done
|
|
|
|
''}
|
|
|
|
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildInputs = [ unzip ];
|
|
|
|
}
|