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
|
|
|
|
|
|
|
|
${stdenv.lib.optionalString (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
|
|
|
|
''
|
|
|
|
cd android-*
|
|
|
|
|
|
|
|
# Patch the interpreter
|
2015-10-15 15:42:24 +01:00
|
|
|
for i in aapt aidl bcc_compat dexdump llvm-rs-cc
|
2013-07-31 15:00:57 +01:00
|
|
|
do
|
2014-12-26 17:33:16 +00:00
|
|
|
patchelf --set-interpreter ${stdenv_32bit.cc.libc}/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
|
2015-01-15 04:51:58 +00:00
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc}/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
|
2015-10-06 13:27:49 +01:00
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc}/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
|
|
|
|
ln -s ${ncurses_32bit}/lib/libncurses.so.5 `pwd`/lib/libtinfo.so.5
|
|
|
|
|
|
|
|
# These binaries need to find libstdc++, libgcc_s, ncurses, and libraries in the current folder
|
|
|
|
for i in bcc_compat llvm-rs-cc
|
|
|
|
do
|
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc}/lib:${ncurses_32bit}/lib:`pwd`/lib $i
|
|
|
|
done
|
2014-09-01 07:37:43 +01:00
|
|
|
|
|
|
|
# These binaries also need zlib in addition to libstdc++
|
2015-10-15 15:42:24 +01:00
|
|
|
for i in arm-linux-androideabi-ld i686-linux-android-ld mipsel-linux-android-ld split-select zipalign
|
2014-09-01 07:37:43 +01:00
|
|
|
do
|
2014-12-26 17:33:16 +00:00
|
|
|
patchelf --set-interpreter ${stdenv_32bit.cc.libc}/lib/ld-linux.so.2 $i
|
2015-10-06 13:27:49 +01:00
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc}/lib:${zlib_32bit}/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
|
2015-10-06 13:27:49 +01:00
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc}/lib:${zlib_32bit}/lib:`pwd`/lib $i
|
2013-07-31 15:00:57 +01:00
|
|
|
done
|
|
|
|
''}
|
|
|
|
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildInputs = [ unzip ];
|
|
|
|
}
|