2013-07-31 15:00:57 +01:00
|
|
|
{stdenv, stdenv_32bit, fetchurl, unzip, zlib_32bit}:
|
|
|
|
|
2015-05-02 14:15:29 +01:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
version="22.0.1";
|
|
|
|
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-05-02 14:15:29 +01:00
|
|
|
url = "https://dl-ssl.google.com/android/repository/build-tools_r${version}-linux.zip";
|
|
|
|
sha1 = "8sb05s9f1h03qa7hdj72jffy7rf9r2ys";
|
2013-07-31 15:00:57 +01:00
|
|
|
}
|
|
|
|
else if stdenv.system == "x86_64-darwin" then fetchurl {
|
2015-05-02 14:15:29 +01:00
|
|
|
url = "https://dl-ssl.google.com/android/repository/build-tools_r${version}-macosx.zip";
|
|
|
|
sha1 = "pxdwrz6bb8b13fknf6qm67g013vdgnjk";
|
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
|
|
|
|
for i in aapt aidl dexdump llvm-rs-cc
|
|
|
|
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
|
|
|
|
for i in aidl libLLVM.so
|
|
|
|
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
|
|
|
|
for i in libbcc.so libbcinfo.so libclang.so llvm-rs-cc
|
|
|
|
do
|
2015-01-15 04:51:58 +00:00
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc}/lib:`pwd` $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++
|
|
|
|
for i in zipalign
|
|
|
|
do
|
2014-12-26 17:33:16 +00:00
|
|
|
patchelf --set-interpreter ${stdenv_32bit.cc.libc}/lib/ld-linux.so.2 $i
|
2015-01-15 04:51:58 +00:00
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc}/lib:${zlib_32bit}/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-01-15 04:51:58 +00:00
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc}/lib:${zlib_32bit}/lib $i
|
2013-07-31 15:00:57 +01:00
|
|
|
done
|
|
|
|
''}
|
|
|
|
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildInputs = [ unzip ];
|
|
|
|
}
|