From af78d76718fdea0137940417266082413f121b0b Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Sat, 9 Sep 2017 16:23:20 +0200 Subject: [PATCH] androidenv: Add the Android Instant Apps SDK --- pkgs/development/mobile/androidenv/addons.nix | 12 ++++ .../mobile/androidenv/androidsdk.nix | 64 ++++++++++--------- .../development/mobile/androidenv/default.nix | 4 ++ .../mobile/androidenv/generate-addons.xsl | 16 +++++ 4 files changed, 66 insertions(+), 30 deletions(-) diff --git a/pkgs/development/mobile/androidenv/addons.nix b/pkgs/development/mobile/androidenv/addons.nix index 46feeb99851..ab5d570a327 100644 --- a/pkgs/development/mobile/androidenv/addons.nix +++ b/pkgs/development/mobile/androidenv/addons.nix @@ -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/"; + }; + }; + } diff --git a/pkgs/development/mobile/androidenv/androidsdk.nix b/pkgs/development/mobile/androidenv/androidsdk.nix index 7c4792f560d..b766d9d9c31 100644 --- a/pkgs/development/mobile/androidenv/androidsdk.nix +++ b/pkgs/development/mobile/androidenv/androidsdk.nix @@ -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 @@ -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 @@ -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") '' @@ -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 ]} @@ -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 @@ -142,7 +143,7 @@ stdenv.mkDerivation rec { "ln -s ${googleApis}/* addon-google_apis-${platformVersion}\n" else "") platformVersions else ""} - + cd .. # Symlink required extras @@ -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 @@ -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 @@ -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 @@ -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/* @@ -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 ] @@ -247,7 +251,7 @@ stdenv.mkDerivation rec { fi done ''; - + buildInputs = [ unzip makeWrapper ]; meta = { diff --git a/pkgs/development/mobile/androidenv/default.nix b/pkgs/development/mobile/androidenv/default.nix index 56c810dfc54..470fb31b03b 100644 --- a/pkgs/development/mobile/androidenv/default.nix +++ b/pkgs/development/mobile/androidenv/default.nix @@ -165,6 +165,7 @@ rec { useGoogleAPIs = true; useExtraSupportLibs = true; useGooglePlayServices = true; + useInstantApps = true; }; androidsdk_7_0 = androidsdk { @@ -179,6 +180,7 @@ rec { useGoogleAPIs = true; useExtraSupportLibs = true; useGooglePlayServices = true; + useInstantApps = true; }; androidsdk_7_1_1 = androidsdk { @@ -193,6 +195,7 @@ rec { useGoogleAPIs = true; useExtraSupportLibs = true; useGooglePlayServices = true; + useInstantApps = true; }; androidsdk_8_0 = androidsdk { @@ -207,6 +210,7 @@ rec { useGoogleAPIs = true; useExtraSupportLibs = true; useGooglePlayServices = true; + useInstantApps = true; }; androidndk = import ./androidndk.nix { diff --git a/pkgs/development/mobile/androidenv/generate-addons.xsl b/pkgs/development/mobile/androidenv/generate-addons.xsl index 175fc0531b4..d32ad717cd7 100644 --- a/pkgs/development/mobile/androidenv/generate-addons.xsl +++ b/pkgs/development/mobile/androidenv/generate-addons.xsl @@ -60,6 +60,22 @@ in }; }; + + + + instant_apps = buildGoogleApis { + name = "instant_apps_sdk"; + src = fetchurl { + url = https://dl.google.com/android/repository/; + sha1 = ""; + }; + meta = { + description = "Android Instant Apps Development SDK"; + url = "https://developer.android.com/"; + }; + }; + + }