2012-11-08 16:49:36 +01:00
|
|
|
{ stdenv, stdenv_32bit, fetchurl, unzip, makeWrapper
|
2014-08-02 03:26:21 +02:00
|
|
|
, platformTools, buildTools, support, supportRepository, platforms, sysimages, addons
|
2013-08-07 22:12:44 +02:00
|
|
|
, libX11, libXext, libXrender, libxcb, libXau, libXdmcp, libXtst, mesa, alsaLib
|
2016-09-01 15:56:35 +02:00
|
|
|
, freetype, fontconfig, glib, gtk, atk, file, jdk, coreutils, libpulseaudio, dbus
|
2016-07-25 21:47:39 +02:00
|
|
|
, zlib, glxinfo, xkeyboardconfig
|
2012-11-07 21:10:39 +01:00
|
|
|
}:
|
2015-10-06 14:27:49 +02:00
|
|
|
{ platformVersions, abiVersions, useGoogleAPIs, useExtraSupportLibs ? false, useGooglePlayServices ? false }:
|
2012-11-07 21:10:39 +01:00
|
|
|
|
2015-10-05 12:23:02 +02:00
|
|
|
with { inherit (stdenv.lib) makeLibraryPath; };
|
|
|
|
|
2014-05-08 00:49:19 +02:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "android-sdk-${version}";
|
2016-07-25 21:47:39 +02:00
|
|
|
version = "25.1.7";
|
2014-12-16 08:22:55 +01:00
|
|
|
|
2012-11-07 21:10:39 +01:00
|
|
|
src = if (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
|
|
|
|
then fetchurl {
|
2016-07-25 21:47:39 +02:00
|
|
|
url = "http://dl.google.com/android/repository/tools_r${version}-linux.zip";
|
|
|
|
sha1 = "p03br08zfq0j7aar5638z8fdh5n9x1in";
|
2012-11-07 21:10:39 +01:00
|
|
|
}
|
|
|
|
else if stdenv.system == "x86_64-darwin" then fetchurl {
|
2016-07-25 21:47:39 +02:00
|
|
|
url = "http://dl.google.com/android/repository/tools_r${version}-macosx.zip";
|
|
|
|
sha1 = "7fzlfms37cfk25kk4f9zriy63djmbi8g";
|
2012-11-07 21:10:39 +01:00
|
|
|
}
|
|
|
|
else throw "platform not ${stdenv.system} supported!";
|
2014-12-16 08:22:55 +01:00
|
|
|
|
2012-11-07 21:10:39 +01:00
|
|
|
buildCommand = ''
|
2012-11-08 15:01:06 +01:00
|
|
|
mkdir -p $out/libexec
|
|
|
|
cd $out/libexec
|
2014-09-02 19:18:30 +02:00
|
|
|
unpackFile $src
|
2016-07-25 21:47:39 +02:00
|
|
|
cd tools
|
2015-05-03 16:03:36 +02:00
|
|
|
|
|
|
|
for f in android traceview draw9patch hierarchyviewer monitor ddms screenshot2 uiautomatorviewer monkeyrunner jobb lint
|
|
|
|
do
|
|
|
|
sed -i -e "s|/bin/ls|${coreutils}/bin/ls|" "$f"
|
|
|
|
done
|
|
|
|
|
2012-11-07 21:10:39 +01:00
|
|
|
${stdenv.lib.optionalString (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
|
|
|
|
''
|
|
|
|
# There are a number of native binaries. We must patch them to let them find the interpreter and libstdc++
|
2014-09-02 19:18:30 +02:00
|
|
|
|
2016-07-25 21:47:39 +02:00
|
|
|
for i in mksdcard
|
2012-11-07 21:10:39 +01:00
|
|
|
do
|
2015-04-26 19:54:51 +02:00
|
|
|
patchelf --set-interpreter ${stdenv_32bit.cc.libc.out}/lib/ld-linux.so.2 $i
|
2016-07-01 21:39:04 +02:00
|
|
|
patchelf --set-rpath ${stdenv_32bit.cc.cc.lib}/lib $i
|
2012-11-07 21:10:39 +01:00
|
|
|
done
|
2016-07-25 21:47:39 +02:00
|
|
|
|
|
|
|
${stdenv.lib.optionalString (stdenv.system == "x86_64-linux") ''
|
|
|
|
for i in bin64/{mkfs.ext4,fsck.ext4,e2fsck,tune2fs,resize2fs}
|
|
|
|
do
|
|
|
|
patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 $i
|
|
|
|
patchelf --set-rpath ${stdenv.cc.cc.lib}/lib64 $i
|
|
|
|
done
|
|
|
|
''}
|
|
|
|
|
2012-12-20 14:04:52 +01:00
|
|
|
${stdenv.lib.optionalString (stdenv.system == "x86_64-linux") ''
|
|
|
|
# We must also patch the 64-bit emulator instances, if needed
|
|
|
|
|
2016-07-25 21:47:39 +02:00
|
|
|
for i in emulator emulator64-arm emulator64-mips emulator64-x86 emulator64-crash-service emulator-check qemu/linux-x86_64/qemu-system-*
|
2012-12-20 14:04:52 +01:00
|
|
|
do
|
2015-04-26 19:54:51 +02:00
|
|
|
patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 $i
|
2016-04-30 22:56:43 +02:00
|
|
|
patchelf --set-rpath ${stdenv.cc.cc.lib}/lib64 $i
|
2012-12-20 14:04:52 +01:00
|
|
|
done
|
|
|
|
''}
|
|
|
|
|
2015-10-15 16:42:24 +02:00
|
|
|
# The following scripts used SWT and wants to dynamically load some GTK+ stuff.
|
|
|
|
# Creating these wrappers ensure that they can be found:
|
|
|
|
|
2013-08-07 22:12:44 +02:00
|
|
|
wrapProgram `pwd`/android \
|
2013-08-08 10:40:09 +02:00
|
|
|
--prefix PATH : ${jdk}/bin \
|
2015-10-05 12:23:02 +02:00
|
|
|
--prefix LD_LIBRARY_PATH : ${makeLibraryPath [ glib gtk libXtst ]}
|
2013-08-07 22:12:44 +02:00
|
|
|
|
2015-10-15 16:42:24 +02:00
|
|
|
wrapProgram `pwd`/uiautomatorviewer \
|
|
|
|
--prefix PATH : ${jdk}/bin \
|
2016-08-23 01:13:46 +02:00
|
|
|
--prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ glib gtk libXtst ]}
|
2015-10-15 16:42:24 +02:00
|
|
|
|
|
|
|
wrapProgram `pwd`/hierarchyviewer \
|
|
|
|
--prefix PATH : ${jdk}/bin \
|
2016-08-23 01:13:46 +02:00
|
|
|
--prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ glib gtk libXtst ]}
|
2015-10-15 16:42:24 +02:00
|
|
|
|
2013-08-07 22:12:44 +02:00
|
|
|
# The emulators need additional libraries, which are dynamically loaded => let's wrap them
|
2016-07-25 21:47:39 +02:00
|
|
|
|
2012-12-20 14:04:52 +01:00
|
|
|
${stdenv.lib.optionalString (stdenv.system == "x86_64-linux") ''
|
2016-07-25 21:47:39 +02:00
|
|
|
for i in emulator emulator64-arm emulator64-mips emulator64-x86 emulator64-crash-service
|
2012-12-20 14:04:52 +01:00
|
|
|
do
|
|
|
|
wrapProgram `pwd`/$i \
|
2016-08-23 00:06:51 +02:00
|
|
|
--prefix PATH : ${stdenv.lib.makeBinPath [ file glxinfo ]} \
|
2016-09-01 15:56:35 +02:00
|
|
|
--suffix LD_LIBRARY_PATH : `pwd`/lib64:`pwd`/lib64/qt/lib:${makeLibraryPath [ stdenv.cc.cc libX11 libxcb libXau libXdmcp libXext mesa alsaLib zlib libpulseaudio dbus.lib ]} \
|
2016-07-25 21:47:39 +02:00
|
|
|
--suffix QT_XKB_CONFIG_ROOT : ${xkeyboardconfig}/share/X11/xkb
|
2012-12-20 14:04:52 +01:00
|
|
|
done
|
|
|
|
''}
|
2012-11-07 21:10:39 +01:00
|
|
|
''}
|
|
|
|
|
2012-11-08 16:49:36 +01:00
|
|
|
patchShebangs .
|
|
|
|
|
2012-11-07 21:10:39 +01:00
|
|
|
${if stdenv.system == "i686-linux" then
|
|
|
|
''
|
|
|
|
# The monitor requires some more patching
|
|
|
|
|
|
|
|
cd lib/monitor-x86
|
2015-04-26 19:54:51 +02:00
|
|
|
patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux.so.2 monitor
|
2015-10-05 12:23:02 +02:00
|
|
|
patchelf --set-rpath ${makeLibraryPath [ libX11 libXext libXrender freetype fontconfig ]} libcairo-swt.so
|
2012-11-07 21:10:39 +01:00
|
|
|
|
|
|
|
wrapProgram `pwd`/monitor \
|
2015-10-05 12:23:02 +02:00
|
|
|
--prefix LD_LIBRARY_PATH : ${makeLibraryPath [ gtk atk stdenv.cc.cc libXtst ]}
|
2012-11-07 21:10:39 +01:00
|
|
|
|
|
|
|
cd ../..
|
|
|
|
''
|
|
|
|
else if stdenv.system == "x86_64-linux" then
|
|
|
|
''
|
|
|
|
# The monitor requires some more patching
|
|
|
|
|
|
|
|
cd lib/monitor-x86_64
|
2015-04-26 19:54:51 +02:00
|
|
|
patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 monitor
|
2015-10-05 12:23:02 +02:00
|
|
|
patchelf --set-rpath ${makeLibraryPath [ libX11 libXext libXrender freetype fontconfig ]} libcairo-swt.so
|
2012-11-07 21:10:39 +01:00
|
|
|
|
|
|
|
wrapProgram `pwd`/monitor \
|
2015-10-05 12:23:02 +02:00
|
|
|
--prefix LD_LIBRARY_PATH : ${makeLibraryPath [ gtk atk stdenv.cc.cc libXtst ]}
|
2012-11-07 21:10:39 +01:00
|
|
|
|
|
|
|
cd ../..
|
|
|
|
''
|
|
|
|
else ""}
|
|
|
|
|
|
|
|
# Symlink the other sub packages
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
ln -s ${platformTools}/platform-tools
|
2013-07-31 16:00:57 +02:00
|
|
|
ln -s ${buildTools}/build-tools
|
2012-11-07 21:10:39 +01:00
|
|
|
ln -s ${support}/support
|
|
|
|
|
|
|
|
# Symlink required Google API add-ons
|
|
|
|
|
|
|
|
mkdir -p add-ons
|
|
|
|
cd add-ons
|
|
|
|
|
|
|
|
${if useGoogleAPIs then
|
|
|
|
stdenv.lib.concatMapStrings (platformVersion:
|
|
|
|
if (builtins.hasAttr ("google_apis_"+platformVersion) addons) then
|
|
|
|
let
|
|
|
|
googleApis = builtins.getAttr ("google_apis_"+platformVersion) addons;
|
|
|
|
in
|
2013-12-03 02:27:53 +01:00
|
|
|
"ln -s ${googleApis}/* addon-google_apis-${platformVersion}\n"
|
2012-11-07 21:10:39 +01:00
|
|
|
else "") platformVersions
|
|
|
|
else ""}
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
2014-08-02 03:26:21 +02:00
|
|
|
# Symlink required extras
|
|
|
|
|
|
|
|
mkdir -p extras/android
|
|
|
|
cd extras/android
|
|
|
|
|
|
|
|
ln -s ${supportRepository}/m2repository
|
|
|
|
|
2015-03-01 21:31:41 +01:00
|
|
|
${if useExtraSupportLibs then
|
|
|
|
"ln -s ${addons.android_support_extra}/support ."
|
|
|
|
else ""}
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
mkdir -p google
|
|
|
|
cd google
|
|
|
|
|
|
|
|
${if useGooglePlayServices then
|
|
|
|
"ln -s ${addons.google_play_services}/google-play-services google_play_services"
|
|
|
|
else ""}
|
|
|
|
|
2014-08-02 03:26:21 +02:00
|
|
|
cd ../..
|
|
|
|
|
2012-11-07 21:10:39 +01:00
|
|
|
# Symlink required platforms
|
|
|
|
|
|
|
|
mkdir -p platforms
|
|
|
|
cd platforms
|
|
|
|
|
|
|
|
${stdenv.lib.concatMapStrings (platformVersion:
|
|
|
|
if (builtins.hasAttr ("platform_"+platformVersion) platforms) then
|
|
|
|
let
|
|
|
|
platform = builtins.getAttr ("platform_"+platformVersion) platforms;
|
|
|
|
in
|
2013-12-03 02:27:53 +01:00
|
|
|
"ln -s ${platform}/* android-${platformVersion}\n"
|
2012-11-07 21:10:39 +01:00
|
|
|
else ""
|
|
|
|
) platformVersions}
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
# Symlink required system images
|
|
|
|
|
|
|
|
mkdir -p system-images
|
|
|
|
cd system-images
|
|
|
|
|
2013-07-31 18:56:27 +02:00
|
|
|
${stdenv.lib.concatMapStrings (abiVersion:
|
|
|
|
stdenv.lib.concatMapStrings (platformVersion:
|
|
|
|
if (builtins.hasAttr ("sysimg_" + abiVersion + "_" + platformVersion) sysimages) then
|
|
|
|
let
|
|
|
|
sysimg = builtins.getAttr ("sysimg_" + abiVersion + "_" + platformVersion) sysimages;
|
|
|
|
in
|
|
|
|
''
|
|
|
|
mkdir -p android-${platformVersion}
|
|
|
|
cd android-${platformVersion}
|
|
|
|
ln -s ${sysimg}/*
|
|
|
|
cd ..
|
|
|
|
''
|
|
|
|
else ""
|
|
|
|
) platformVersions
|
|
|
|
) abiVersions}
|
2012-11-08 15:01:06 +01:00
|
|
|
|
|
|
|
# Create wrappers to the most important tools and platform tools so that we can run them if the SDK is in our PATH
|
|
|
|
|
2014-06-30 14:56:10 +02:00
|
|
|
mkdir -p $out/bin
|
2012-11-08 15:01:06 +01:00
|
|
|
|
2016-07-25 21:47:39 +02:00
|
|
|
for i in $out/libexec/tools/*
|
2012-11-08 15:01:06 +01:00
|
|
|
do
|
|
|
|
if [ ! -d $i ] && [ -x $i ]
|
|
|
|
then
|
2013-08-07 22:12:44 +02:00
|
|
|
ln -sf $i $out/bin/$(basename $i)
|
2012-11-08 15:01:06 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2016-07-25 21:47:39 +02:00
|
|
|
for i in $out/libexec/platform-tools/*
|
2012-11-08 15:01:06 +01:00
|
|
|
do
|
|
|
|
if [ ! -d $i ] && [ -x $i ]
|
|
|
|
then
|
2013-08-07 22:12:44 +02:00
|
|
|
ln -sf $i $out/bin/$(basename $i)
|
2012-11-08 15:01:06 +01:00
|
|
|
fi
|
|
|
|
done
|
2014-11-24 09:46:09 +01:00
|
|
|
|
2016-07-25 21:47:39 +02:00
|
|
|
for i in $out/libexec/build-tools/*/*
|
2014-11-24 09:46:09 +01:00
|
|
|
do
|
|
|
|
if [ ! -d $i ] && [ -x $i ]
|
|
|
|
then
|
|
|
|
ln -sf $i $out/bin/$(basename $i)
|
|
|
|
fi
|
|
|
|
done
|
2012-11-07 21:10:39 +01:00
|
|
|
'';
|
|
|
|
|
2012-11-08 16:49:36 +01:00
|
|
|
buildInputs = [ unzip makeWrapper ];
|
2016-08-02 18:06:29 +02:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
platforms = stdenv.lib.platforms.unix;
|
2016-08-02 21:55:43 +02:00
|
|
|
hydraPlatforms = [];
|
2016-08-02 18:06:29 +02:00
|
|
|
};
|
2012-11-07 21:10:39 +01:00
|
|
|
}
|