@@ -5,7 +5,8 @@
55, zlib, glxinfo, xkeyboardconfig
66, includeSources
77}:
8−{ platformVersions, abiVersions, useGoogleAPIs, useExtraSupportLibs ? false, useGooglePlayServices ? false }:
8+{ platformVersions, abiVersions, useGoogleAPIs, useExtraSupportLibs ? false
9+, useGooglePlayServices ? false, useInstantApps ? false }:
910
1011let inherit (stdenv.lib) makeLibraryPath; in
1112
@@ -38,7 +39,7 @@ stdenv.mkDerivation rec {
3839 ${stdenv.lib.optionalString (stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux")
3940 ''
4041 # There are a number of native binaries. We must patch them to let them find the interpreter and libstdc++
41−
42+
4243 for i in mksdcard
4344 do
4445 patchelf --set-interpreter ${stdenv_32bit.cc.libc.out}/lib/ld-linux.so.2 $i
@@ -55,29 +56,29 @@ stdenv.mkDerivation rec {
5556
5657 ${stdenv.lib.optionalString (stdenv.system == "x86_64-linux") ''
5758 # We must also patch the 64-bit emulator instances, if needed
58−
59+
5960 for i in emulator emulator64-arm emulator64-mips emulator64-x86 emulator64-crash-service emulator-check qemu/linux-x86_64/qemu-system-*
6061 do
6162 patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 $i
6263 patchelf --set-rpath ${stdenv.cc.cc.lib}/lib64 $i
6364 done
6465 ''}
65−
66+
6667 # The following scripts used SWT and wants to dynamically load some GTK+ stuff.
6768 # Creating these wrappers ensure that they can be found:
68−
69+
6970 wrapProgram `pwd`/android \
7071 --prefix PATH : ${jdk}/bin \
7172 --prefix LD_LIBRARY_PATH : ${makeLibraryPath [ glib gtk2 libXtst ]}
72−
73+
7374 wrapProgram `pwd`/uiautomatorviewer \
7475 --prefix PATH : ${jdk}/bin \
7576 --prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ glib gtk2 libXtst ]}
76−
77+
7778 wrapProgram `pwd`/hierarchyviewer \
7879 --prefix PATH : ${jdk}/bin \
7980 --prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ glib gtk2 libXtst ]}
80−
81+
8182 # The emulators need additional libraries, which are dynamically loaded => let's wrap them
8283
8384 ${stdenv.lib.optionalString (stdenv.system == "x86_64-linux") ''
@@ -92,15 +93,15 @@ stdenv.mkDerivation rec {
9293 ''}
9394
9495 patchShebangs .
95−
96+
9697 ${if stdenv.system == "i686-linux" then
9798 ''
9899 # The monitor requires some more patching
99−
100+
100101 cd lib/monitor-x86
101102 patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux.so.2 monitor
102103 patchelf --set-rpath ${makeLibraryPath [ libX11 libXext libXrender freetype fontconfig ]} libcairo-swt.so
103−
104+
104105 wrapProgram `pwd`/monitor \
105106 --prefix LD_LIBRARY_PATH : ${makeLibraryPath [ gtk2 atk stdenv.cc.cc libXtst ]}
106107
@@ -109,30 +110,30 @@ stdenv.mkDerivation rec {
109110 else if stdenv.system == "x86_64-linux" then
110111 ''
111112 # The monitor requires some more patching
112−
113+
113114 cd lib/monitor-x86_64
114115 patchelf --set-interpreter ${stdenv.cc.libc.out}/lib/ld-linux-x86-64.so.2 monitor
115116 patchelf --set-rpath ${makeLibraryPath [ libX11 libXext libXrender freetype fontconfig ]} libcairo-swt.so
116−
117+
117118 wrapProgram `pwd`/monitor \
118119 --prefix LD_LIBRARY_PATH : ${makeLibraryPath [ gtk2 atk stdenv.cc.cc libXtst ]}
119120
120121 cd ../..
121122 ''
122123 else ""}
123−
124+
124125 # Symlink the other sub packages
125−
126+
126127 cd ..
127128 ln -s ${platformTools}/platform-tools
128129 ln -s ${buildTools}/build-tools
129130 ln -s ${support}/support
130−
131+
131132 # Symlink required Google API add-ons
132−
133+
133134 mkdir -p add-ons
134135 cd add-ons
135−
136+
136137 ${if useGoogleAPIs then
137138 stdenv.lib.concatMapStrings (platformVersion:
138139 if (builtins.hasAttr ("google_apis_"+platformVersion) addons) then
@@ -142,7 +143,7 @@ stdenv.mkDerivation rec {
142143 "ln -s ${googleApis}/* addon-google_apis-${platformVersion}\n"
143144 else "") platformVersions
144145 else ""}
145−
146+
146147 cd ..
147148
148149 # Symlink required extras
@@ -163,7 +164,10 @@ stdenv.mkDerivation rec {
163164 ${if useGooglePlayServices then
164165 "ln -s ${addons.google_play_services}/google-play-services google_play_services"
165166 else ""}
166−
167+
168+ ${stdenv.lib.optionalString useInstantApps
169+ "ln -s ${addons.instant_apps}/whsdk instantapps"}
170+
167171 cd ../..
168172
169173 # Symlink required sources
@@ -183,10 +187,10 @@ stdenv.mkDerivation rec {
183187 cd ..
184188
185189 # Symlink required platforms
186−
190+
187191 mkdir -p platforms
188192 cd platforms
189−
193+
190194 ${stdenv.lib.concatMapStrings (platformVersion:
191195 if (builtins.hasAttr ("platform_"+platformVersion) platforms) then
192196 let
@@ -195,14 +199,14 @@ stdenv.mkDerivation rec {
195199 "ln -s ${platform}/* android-${platformVersion}\n"
196200 else ""
197201 ) platformVersions}
198−
202+
199203 cd ..
200−
204+
201205 # Symlink required system images
202−
206+
203207 mkdir -p system-images
204208 cd system-images
205−
209+
206210 ${stdenv.lib.concatMapStrings (abiVersion:
207211 stdenv.lib.concatMapStrings (platformVersion:
208212 if (builtins.hasAttr ("sysimg_" + abiVersion + "_" + platformVersion) sysimages) then
@@ -218,9 +222,9 @@ stdenv.mkDerivation rec {
218222 else ""
219223 ) platformVersions
220224 ) abiVersions}
221−
225+
222226 # Create wrappers to the most important tools and platform tools so that we can run them if the SDK is in our PATH
223−
227+
224228 mkdir -p $out/bin
225229
226230 for i in $out/libexec/tools/*
@@ -230,7 +234,7 @@ stdenv.mkDerivation rec {
230234 ln -sf $i $out/bin/$(basename $i)
231235 fi
232236 done
233−
237+
234238 for i in $out/libexec/platform-tools/*
235239 do
236240 if [ ! -d $i ] && [ -x $i ]
@@ -247,7 +251,7 @@ stdenv.mkDerivation rec {
247251 fi
248252 done
249253 '';
250−
254+
251255 buildInputs = [ unzip makeWrapper ];
252256
253257 meta = {