androidenv: Add the Android Instant Apps SDK

This commit is contained in:
Michael Weiss 2017-09-09 16:23:20 +02:00
parent 84e34d4d5d
commit af78d76718
4 changed files with 66 additions and 30 deletions

View File

@ -305,4 +305,16 @@ in
}; };
}; };
instant_apps = buildGoogleApis {
name = "instant_apps_sdk";
src = fetchurl {
url = https://dl.google.com/android/repository/aiasdk-1.0.0.zip;
sha1 = "50074a0f0312ee1d0d81d2cddc3d84a8a9e97a53";
};
meta = {
description = "Android Instant Apps Development SDK";
url = "https://developer.android.com/";
};
};
} }

View File

@ -5,7 +5,8 @@
, zlib, glxinfo, xkeyboardconfig , zlib, glxinfo, xkeyboardconfig
, includeSources , includeSources
}: }:
{ platformVersions, abiVersions, useGoogleAPIs, useExtraSupportLibs ? false, useGooglePlayServices ? false }: { platformVersions, abiVersions, useGoogleAPIs, useExtraSupportLibs ? false
, useGooglePlayServices ? false, useInstantApps ? false }:
let inherit (stdenv.lib) makeLibraryPath; in let inherit (stdenv.lib) makeLibraryPath; in
@ -38,7 +39,7 @@ stdenv.mkDerivation rec {
${stdenv.lib.optionalString (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux") ${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++ # There are a number of native binaries. We must patch them to let them find the interpreter and libstdc++
for i in mksdcard for i in mksdcard
do do
patchelf --set-interpreter ${stdenv_32bit.cc.libc.out}/lib/ld-linux.so.2 $i patchelf --set-interpreter ${stdenv_32bit.cc.libc.out}/lib/ld-linux.so.2 $i
@ -55,29 +56,29 @@ stdenv.mkDerivation rec {
${stdenv.lib.optionalString (stdenv.system == "x86_64-linux") '' ${stdenv.lib.optionalString (stdenv.system == "x86_64-linux") ''
# We must also patch the 64-bit emulator instances, if needed # We must also patch the 64-bit emulator instances, if needed
for i in emulator emulator64-arm emulator64-mips emulator64-x86 emulator64-crash-service emulator-check qemu/linux-x86_64/qemu-system-* for i in emulator emulator64-arm emulator64-mips emulator64-x86 emulator64-crash-service emulator-check qemu/linux-x86_64/qemu-system-*
do do
patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 $i patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 $i
patchelf --set-rpath ${stdenv.cc.cc.lib}/lib64 $i patchelf --set-rpath ${stdenv.cc.cc.lib}/lib64 $i
done done
''} ''}
# The following scripts used SWT and wants to dynamically load some GTK+ stuff. # The following scripts used SWT and wants to dynamically load some GTK+ stuff.
# Creating these wrappers ensure that they can be found: # Creating these wrappers ensure that they can be found:
wrapProgram `pwd`/android \ wrapProgram `pwd`/android \
--prefix PATH : ${jdk}/bin \ --prefix PATH : ${jdk}/bin \
--prefix LD_LIBRARY_PATH : ${makeLibraryPath [ glib gtk2 libXtst ]} --prefix LD_LIBRARY_PATH : ${makeLibraryPath [ glib gtk2 libXtst ]}
wrapProgram `pwd`/uiautomatorviewer \ wrapProgram `pwd`/uiautomatorviewer \
--prefix PATH : ${jdk}/bin \ --prefix PATH : ${jdk}/bin \
--prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ glib gtk2 libXtst ]} --prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ glib gtk2 libXtst ]}
wrapProgram `pwd`/hierarchyviewer \ wrapProgram `pwd`/hierarchyviewer \
--prefix PATH : ${jdk}/bin \ --prefix PATH : ${jdk}/bin \
--prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ glib gtk2 libXtst ]} --prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ glib gtk2 libXtst ]}
# The emulators need additional libraries, which are dynamically loaded => let's wrap them # The emulators need additional libraries, which are dynamically loaded => let's wrap them
${stdenv.lib.optionalString (stdenv.system == "x86_64-linux") '' ${stdenv.lib.optionalString (stdenv.system == "x86_64-linux") ''
@ -92,15 +93,15 @@ stdenv.mkDerivation rec {
''} ''}
patchShebangs . patchShebangs .
${if stdenv.system == "i686-linux" then ${if stdenv.system == "i686-linux" then
'' ''
# The monitor requires some more patching # The monitor requires some more patching
cd lib/monitor-x86 cd lib/monitor-x86
patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux.so.2 monitor patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux.so.2 monitor
patchelf --set-rpath ${makeLibraryPath [ libX11 libXext libXrender freetype fontconfig ]} libcairo-swt.so patchelf --set-rpath ${makeLibraryPath [ libX11 libXext libXrender freetype fontconfig ]} libcairo-swt.so
wrapProgram `pwd`/monitor \ wrapProgram `pwd`/monitor \
--prefix LD_LIBRARY_PATH : ${makeLibraryPath [ gtk2 atk stdenv.cc.cc libXtst ]} --prefix LD_LIBRARY_PATH : ${makeLibraryPath [ gtk2 atk stdenv.cc.cc libXtst ]}
@ -109,30 +110,30 @@ stdenv.mkDerivation rec {
else if stdenv.system == "x86_64-linux" then else if stdenv.system == "x86_64-linux" then
'' ''
# The monitor requires some more patching # The monitor requires some more patching
cd lib/monitor-x86_64 cd lib/monitor-x86_64
patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 monitor patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 monitor
patchelf --set-rpath ${makeLibraryPath [ libX11 libXext libXrender freetype fontconfig ]} libcairo-swt.so patchelf --set-rpath ${makeLibraryPath [ libX11 libXext libXrender freetype fontconfig ]} libcairo-swt.so
wrapProgram `pwd`/monitor \ wrapProgram `pwd`/monitor \
--prefix LD_LIBRARY_PATH : ${makeLibraryPath [ gtk2 atk stdenv.cc.cc libXtst ]} --prefix LD_LIBRARY_PATH : ${makeLibraryPath [ gtk2 atk stdenv.cc.cc libXtst ]}
cd ../.. cd ../..
'' ''
else ""} else ""}
# Symlink the other sub packages # Symlink the other sub packages
cd .. cd ..
ln -s ${platformTools}/platform-tools ln -s ${platformTools}/platform-tools
ln -s ${buildTools}/build-tools ln -s ${buildTools}/build-tools
ln -s ${support}/support ln -s ${support}/support
# Symlink required Google API add-ons # Symlink required Google API add-ons
mkdir -p add-ons mkdir -p add-ons
cd add-ons cd add-ons
${if useGoogleAPIs then ${if useGoogleAPIs then
stdenv.lib.concatMapStrings (platformVersion: stdenv.lib.concatMapStrings (platformVersion:
if (builtins.hasAttr ("google_apis_"+platformVersion) addons) then if (builtins.hasAttr ("google_apis_"+platformVersion) addons) then
@ -142,7 +143,7 @@ stdenv.mkDerivation rec {
"ln -s ${googleApis}/* addon-google_apis-${platformVersion}\n" "ln -s ${googleApis}/* addon-google_apis-${platformVersion}\n"
else "") platformVersions else "") platformVersions
else ""} else ""}
cd .. cd ..
# Symlink required extras # Symlink required extras
@ -163,7 +164,10 @@ stdenv.mkDerivation rec {
${if useGooglePlayServices then ${if useGooglePlayServices then
"ln -s ${addons.google_play_services}/google-play-services google_play_services" "ln -s ${addons.google_play_services}/google-play-services google_play_services"
else ""} else ""}
${stdenv.lib.optionalString useInstantApps
"ln -s ${addons.instant_apps}/whsdk instantapps"}
cd ../.. cd ../..
# Symlink required sources # Symlink required sources
@ -183,10 +187,10 @@ stdenv.mkDerivation rec {
cd .. cd ..
# Symlink required platforms # Symlink required platforms
mkdir -p platforms mkdir -p platforms
cd platforms cd platforms
${stdenv.lib.concatMapStrings (platformVersion: ${stdenv.lib.concatMapStrings (platformVersion:
if (builtins.hasAttr ("platform_"+platformVersion) platforms) then if (builtins.hasAttr ("platform_"+platformVersion) platforms) then
let let
@ -195,14 +199,14 @@ stdenv.mkDerivation rec {
"ln -s ${platform}/* android-${platformVersion}\n" "ln -s ${platform}/* android-${platformVersion}\n"
else "" else ""
) platformVersions} ) platformVersions}
cd .. cd ..
# Symlink required system images # Symlink required system images
mkdir -p system-images mkdir -p system-images
cd system-images cd system-images
${stdenv.lib.concatMapStrings (abiVersion: ${stdenv.lib.concatMapStrings (abiVersion:
stdenv.lib.concatMapStrings (platformVersion: stdenv.lib.concatMapStrings (platformVersion:
if (builtins.hasAttr ("sysimg_" + abiVersion + "_" + platformVersion) sysimages) then if (builtins.hasAttr ("sysimg_" + abiVersion + "_" + platformVersion) sysimages) then
@ -218,9 +222,9 @@ stdenv.mkDerivation rec {
else "" else ""
) platformVersions ) platformVersions
) abiVersions} ) abiVersions}
# Create wrappers to the most important tools and platform tools so that we can run them if the SDK is in our PATH # Create wrappers to the most important tools and platform tools so that we can run them if the SDK is in our PATH
mkdir -p $out/bin mkdir -p $out/bin
for i in $out/libexec/tools/* for i in $out/libexec/tools/*
@ -230,7 +234,7 @@ stdenv.mkDerivation rec {
ln -sf $i $out/bin/$(basename $i) ln -sf $i $out/bin/$(basename $i)
fi fi
done done
for i in $out/libexec/platform-tools/* for i in $out/libexec/platform-tools/*
do do
if [ ! -d $i ] && [ -x $i ] if [ ! -d $i ] && [ -x $i ]
@ -247,7 +251,7 @@ stdenv.mkDerivation rec {
fi fi
done done
''; '';
buildInputs = [ unzip makeWrapper ]; buildInputs = [ unzip makeWrapper ];
meta = { meta = {

View File

@ -165,6 +165,7 @@ rec {
useGoogleAPIs = true; useGoogleAPIs = true;
useExtraSupportLibs = true; useExtraSupportLibs = true;
useGooglePlayServices = true; useGooglePlayServices = true;
useInstantApps = true;
}; };
androidsdk_7_0 = androidsdk { androidsdk_7_0 = androidsdk {
@ -179,6 +180,7 @@ rec {
useGoogleAPIs = true; useGoogleAPIs = true;
useExtraSupportLibs = true; useExtraSupportLibs = true;
useGooglePlayServices = true; useGooglePlayServices = true;
useInstantApps = true;
}; };
androidsdk_7_1_1 = androidsdk { androidsdk_7_1_1 = androidsdk {
@ -193,6 +195,7 @@ rec {
useGoogleAPIs = true; useGoogleAPIs = true;
useExtraSupportLibs = true; useExtraSupportLibs = true;
useGooglePlayServices = true; useGooglePlayServices = true;
useInstantApps = true;
}; };
androidsdk_8_0 = androidsdk { androidsdk_8_0 = androidsdk {
@ -207,6 +210,7 @@ rec {
useGoogleAPIs = true; useGoogleAPIs = true;
useExtraSupportLibs = true; useExtraSupportLibs = true;
useGooglePlayServices = true; useGooglePlayServices = true;
useInstantApps = true;
}; };
androidndk = import ./androidndk.nix { androidndk = import ./androidndk.nix {

View File

@ -60,6 +60,22 @@ in
}; };
}; };
</xsl:for-each> </xsl:for-each>
<!-- Instant apps -->
<xsl:for-each select="sdk:extra[sdk:path='instantapps']">
instant_apps = buildGoogleApis {
name = "instant_apps_sdk";
src = fetchurl {
url = https://dl.google.com/android/repository/<xsl:value-of select="sdk:archives/sdk:archive/sdk:url"/>;
sha1 = "<xsl:value-of select="sdk:archives/sdk:archive/sdk:checksum[@type='sha1']" />";
};
meta = {
description = "Android Instant Apps Development SDK";
url = "https://developer.android.com/";
};
};
</xsl:for-each>
} }
</xsl:template> </xsl:template>