Skip to content

Commit

Permalink
androidenv: Add the Android Instant Apps SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
primeos committed Sep 9, 2017
1 parent 84e34d4 commit af78d76
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 30 deletions.
12 changes: 12 additions & 0 deletions pkgs/development/mobile/androidenv/addons.nix
Expand Up @@ -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/";
};
};

}
64 changes: 34 additions & 30 deletions pkgs/development/mobile/androidenv/androidsdk.nix
Expand Up @@ -5,7 +5,8 @@
, zlib, glxinfo, xkeyboardconfig
, includeSources
}:
{ platformVersions, abiVersions, useGoogleAPIs, useExtraSupportLibs ? false, useGooglePlayServices ? false }:
{ platformVersions, abiVersions, useGoogleAPIs, useExtraSupportLibs ? false
, useGooglePlayServices ? false, useInstantApps ? false }:

let inherit (stdenv.lib) makeLibraryPath; in

Expand Down Expand Up @@ -38,7 +39,7 @@ stdenv.mkDerivation rec {
${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++
for i in mksdcard
do
patchelf --set-interpreter ${stdenv_32bit.cc.libc.out}/lib/ld-linux.so.2 $i
Expand All @@ -55,29 +56,29 @@ stdenv.mkDerivation rec {
${stdenv.lib.optionalString (stdenv.system == "x86_64-linux") ''
# 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-*
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
''}
# The following scripts used SWT and wants to dynamically load some GTK+ stuff.
# Creating these wrappers ensure that they can be found:
wrapProgram `pwd`/android \
--prefix PATH : ${jdk}/bin \
--prefix LD_LIBRARY_PATH : ${makeLibraryPath [ glib gtk2 libXtst ]}
wrapProgram `pwd`/uiautomatorviewer \
--prefix PATH : ${jdk}/bin \
--prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ glib gtk2 libXtst ]}
wrapProgram `pwd`/hierarchyviewer \
--prefix PATH : ${jdk}/bin \
--prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ glib gtk2 libXtst ]}
# The emulators need additional libraries, which are dynamically loaded => let's wrap them
${stdenv.lib.optionalString (stdenv.system == "x86_64-linux") ''
Expand All @@ -92,15 +93,15 @@ stdenv.mkDerivation rec {
''}
patchShebangs .
${if stdenv.system == "i686-linux" then
''
# The monitor requires some more patching
cd lib/monitor-x86
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
wrapProgram `pwd`/monitor \
--prefix LD_LIBRARY_PATH : ${makeLibraryPath [ gtk2 atk stdenv.cc.cc libXtst ]}
Expand All @@ -109,30 +110,30 @@ stdenv.mkDerivation rec {
else if stdenv.system == "x86_64-linux" then
''
# The monitor requires some more patching
cd lib/monitor-x86_64
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
wrapProgram `pwd`/monitor \
--prefix LD_LIBRARY_PATH : ${makeLibraryPath [ gtk2 atk stdenv.cc.cc libXtst ]}
cd ../..
''
else ""}
# Symlink the other sub packages
cd ..
ln -s ${platformTools}/platform-tools
ln -s ${buildTools}/build-tools
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
Expand All @@ -142,7 +143,7 @@ stdenv.mkDerivation rec {
"ln -s ${googleApis}/* addon-google_apis-${platformVersion}\n"
else "") platformVersions
else ""}
cd ..
# Symlink required extras
Expand All @@ -163,7 +164,10 @@ stdenv.mkDerivation rec {
${if useGooglePlayServices then
"ln -s ${addons.google_play_services}/google-play-services google_play_services"
else ""}
${stdenv.lib.optionalString useInstantApps
"ln -s ${addons.instant_apps}/whsdk instantapps"}
cd ../..
# Symlink required sources
Expand All @@ -183,10 +187,10 @@ stdenv.mkDerivation rec {
cd ..
# Symlink required platforms
mkdir -p platforms
cd platforms
${stdenv.lib.concatMapStrings (platformVersion:
if (builtins.hasAttr ("platform_"+platformVersion) platforms) then
let
Expand All @@ -195,14 +199,14 @@ stdenv.mkDerivation rec {
"ln -s ${platform}/* android-${platformVersion}\n"
else ""
) platformVersions}
cd ..
# Symlink required system images
mkdir -p system-images
cd system-images
${stdenv.lib.concatMapStrings (abiVersion:
stdenv.lib.concatMapStrings (platformVersion:
if (builtins.hasAttr ("sysimg_" + abiVersion + "_" + platformVersion) sysimages) then
Expand All @@ -218,9 +222,9 @@ stdenv.mkDerivation rec {
else ""
) platformVersions
) abiVersions}
# 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
for i in $out/libexec/tools/*
Expand All @@ -230,7 +234,7 @@ stdenv.mkDerivation rec {
ln -sf $i $out/bin/$(basename $i)
fi
done
for i in $out/libexec/platform-tools/*
do
if [ ! -d $i ] && [ -x $i ]
Expand All @@ -247,7 +251,7 @@ stdenv.mkDerivation rec {
fi
done
'';

buildInputs = [ unzip makeWrapper ];

meta = {
Expand Down
4 changes: 4 additions & 0 deletions pkgs/development/mobile/androidenv/default.nix
Expand Up @@ -165,6 +165,7 @@ rec {
useGoogleAPIs = true;
useExtraSupportLibs = true;
useGooglePlayServices = true;
useInstantApps = true;
};

androidsdk_7_0 = androidsdk {
Expand All @@ -179,6 +180,7 @@ rec {
useGoogleAPIs = true;
useExtraSupportLibs = true;
useGooglePlayServices = true;
useInstantApps = true;
};

androidsdk_7_1_1 = androidsdk {
Expand All @@ -193,6 +195,7 @@ rec {
useGoogleAPIs = true;
useExtraSupportLibs = true;
useGooglePlayServices = true;
useInstantApps = true;
};

androidsdk_8_0 = androidsdk {
Expand All @@ -207,6 +210,7 @@ rec {
useGoogleAPIs = true;
useExtraSupportLibs = true;
useGooglePlayServices = true;
useInstantApps = true;
};

androidndk = import ./androidndk.nix {
Expand Down
16 changes: 16 additions & 0 deletions pkgs/development/mobile/androidenv/generate-addons.xsl
Expand Up @@ -60,6 +60,22 @@ in
};
};
</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>

Expand Down

0 comments on commit af78d76

Please sign in to comment.