about summary refs log tree commit diff
path: root/pkgs/development/mobile
diff options
context:
space:
mode:
authorSander van der Burg <svanderburg@gmail.com>2013-08-05 19:08:58 +0200
committerSander van der Burg <svanderburg@gmail.com>2013-08-05 19:08:58 +0200
commit7019b685de75b7cec5454d7901744cd92328d271 (patch)
treef1a9ff493b321819780e08fe508ef5732794f474 /pkgs/development/mobile
parent2a294a582b49816d1a7e3bc385226f37beb36a29 (diff)
downloadnixlib-7019b685de75b7cec5454d7901744cd92328d271.tar
nixlib-7019b685de75b7cec5454d7901744cd92328d271.tar.gz
nixlib-7019b685de75b7cec5454d7901744cd92328d271.tar.bz2
nixlib-7019b685de75b7cec5454d7901744cd92328d271.tar.lz
nixlib-7019b685de75b7cec5454d7901744cd92328d271.tar.xz
nixlib-7019b685de75b7cec5454d7901744cd92328d271.tar.zst
nixlib-7019b685de75b7cec5454d7901744cd92328d271.zip
Make the emulator flags configurable at runtime and unimportant messages should go the stderr
Diffstat (limited to 'pkgs/development/mobile')
-rw-r--r--pkgs/development/mobile/androidenv/emulate-app.nix33
1 files changed, 18 insertions, 15 deletions
diff --git a/pkgs/development/mobile/androidenv/emulate-app.nix b/pkgs/development/mobile/androidenv/emulate-app.nix
index eb39d854d1fb..ae8b7f8d1efb 100644
--- a/pkgs/development/mobile/androidenv/emulate-app.nix
+++ b/pkgs/development/mobile/androidenv/emulate-app.nix
@@ -1,5 +1,7 @@
 {stdenv, androidsdk}:
-{name, app, platformVersion ? "8", abiVersion ? "armeabi-v7a", useGoogleAPIs ? false, enableGPU ? false, package, activity}:
+{name, app ? null, platformVersion ? "8", abiVersion ? "armeabi-v7a", useGoogleAPIs ? false, enableGPU ? false, package ? null, activity ? null}:
+
+assert app != null -> package != null && activity != null;
 
 let
   androidsdkComposition = androidsdk {
@@ -28,7 +30,7 @@ stdenv.mkDerivation {
     
     # We have to look for a free TCP port
     
-    echo "Looking for a free TCP port in range 5554-5584"
+    echo "Looking for a free TCP port in range 5554-5584" >&2
     
     for i in $(seq 5554 2 5584)
     do
@@ -41,10 +43,10 @@ stdenv.mkDerivation {
     
     if [ -z "$port" ]
     then
-        echo "Unfortunately, the emulator port space is exhausted!"
+        echo "Unfortunately, the emulator port space is exhausted!" >&2
         exit 1
     else
-        echo "We have a free TCP port: $port"
+        echo "We have a free TCP port: $port" >&2
     fi
     
     export ANDROID_SERIAL="emulator-$port"
@@ -58,39 +60,40 @@ stdenv.mkDerivation {
     ''}
     
     # Launch the emulator
-    ${androidsdkComposition}/libexec/android-sdk-*/tools/emulator -avd device -no-boot-anim -port $port &
+    ${androidsdkComposition}/libexec/android-sdk-*/tools/emulator -avd device -no-boot-anim -port $port $NIX_ANDROID_EMULATOR_FLAGS &
 
     # Wait until the device has completely booted
     
-    echo "Waiting until the emulator has booted the device and the package manager is ready..."
+    echo "Waiting until the emulator has booted the device and the package manager is ready..." >&2
     
     ${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port wait-for-device
     
-    echo "Device state has been reached"
+    echo "Device state has been reached" >&2
     
     while [ -z "$(${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port shell getprop dev.bootcomplete | grep 1)" ]
     do
         sleep 5
     done
     
-    echo "dev.bootcomplete property is 1"
+    echo "dev.bootcomplete property is 1" >&2
     
     #while [ -z "$(${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port shell getprop sys.boot_completed | grep 1)" ]
     #do
         #sleep 5
     #done
     
-    #echo "sys.boot_completed property is 1"
+    #echo "sys.boot_completed property is 1" >&2
     
-    echo "ready"
+    echo "ready" >&2
     
-    # Install the App through the debugger
-    ${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port install ${app}/*.apk
+    ${stdenv.lib.optionalString (app != null) ''
+      # Install the App through the debugger
+      ${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port install ${app}/*.apk
     
-    # Start the application
-    ${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port shell am start -a android.intent.action.MAIN -n ${package}/.${activity}
+      # Start the application
+      ${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port shell am start -a android.intent.action.MAIN -n ${package}/.${activity}
+    ''}
     EOF
-    
     chmod +x $out/bin/run-test-emulator
   '';
 }