diff --git a/pkgs/development/androidenv/androidsdk.nix b/pkgs/development/androidenv/androidsdk.nix index 5ea05749a0e..535b375231c 100644 --- a/pkgs/development/androidenv/androidsdk.nix +++ b/pkgs/development/androidenv/androidsdk.nix @@ -22,8 +22,8 @@ stdenv.mkDerivation { else throw "platform not ${stdenv.system} supported!"; buildCommand = '' - mkdir -p $out - cd $out + mkdir -p $out/libexec + cd $out/libexec unpackFile $src; cd android-sdk-*/tools @@ -147,6 +147,34 @@ stdenv.mkDerivation { '' else "" ) platformVersions} + + # Create wrappers to the most important tools and platform tools so that we can run them if the SDK is in our PATH + + ensureDir $out/bin + + for i in $out/libexec/android-sdk-*/tools/* + do + if [ ! -d $i ] && [ -x $i ] + then + ( echo '#! ${stdenv.shell} -e' + echo "cd $out/libexec/android-sdk-*/tools" + echo "./$(basename $i) \"\$@\"" ) > $out/bin/$(basename $i) + + chmod +x $out/bin/$(basename $i) + fi + done + + for i in $out/libexec/android-sdk-*/platform-tools/* + do + if [ ! -d $i ] && [ -x $i ] + then + ( echo '#! ${stdenv.shell} -e' + echo "cd $out/libexec/android-sdk-*/platform-tools" + echo "./$(basename $i) \"\$@\"") > $out/bin/$(basename $i) + + chmod +x $out/bin/$(basename $i) + fi + done ''; buildInputs = [ shebangfix unzip makeWrapper ]; diff --git a/pkgs/development/androidenv/build-app.nix b/pkgs/development/androidenv/build-app.nix index c35f7175e3d..571cd2be623 100644 --- a/pkgs/development/androidenv/build-app.nix +++ b/pkgs/development/androidenv/build-app.nix @@ -15,7 +15,7 @@ in stdenv.mkDerivation { inherit name src; - ANDROID_HOME = "${androidsdkComposition}/android-sdk-${platformName}"; + ANDROID_HOME = "${androidsdkComposition}/libexec/android-sdk-${platformName}"; buildInputs = [ jdk ant ]; diff --git a/pkgs/development/androidenv/emulate-app.nix b/pkgs/development/androidenv/emulate-app.nix index df821f300d6..eeac61fe8db 100644 --- a/pkgs/development/androidenv/emulate-app.nix +++ b/pkgs/development/androidenv/emulate-app.nix @@ -28,7 +28,7 @@ stdenv.mkDerivation { for i in $(seq 5554 2 5584) do - if [ -z "$(${androidsdkComposition}/android-sdk-*/platform-tools/adb devices | grep emulator-$i)" ] + if [ -z "$(${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb devices | grep emulator-$i)" ] then port=$i break @@ -46,27 +46,27 @@ stdenv.mkDerivation { export ANDROID_SERIAL="emulator-$port" # Create a virtual android device - ${androidsdkComposition}/android-sdk-*/tools/android create avd -n device -t ${if useGoogleAPIs then "'Google Inc.:Google APIs:"+platformVersion+"'" else "android-"+platformVersion} + ${androidsdkComposition}/libexec/android-sdk-*/tools/android create avd -n device -t ${if useGoogleAPIs then "'Google Inc.:Google APIs:"+platformVersion+"'" else "android-"+platformVersion} # Launch the emulator - ${androidsdkComposition}/android-sdk-*/tools/emulator -avd device -no-boot-anim -port $port & + ${androidsdkComposition}/libexec/android-sdk-*/tools/emulator -avd device -no-boot-anim -port $port & # Wait until the device has completely booted echo "Waiting until the emulator has booted the device and the package manager is ready..." - ${androidsdkComposition}/android-sdk-*/platform-tools/adb -s emulator-$port wait-for-device + ${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port wait-for-device echo "Device state has been reached" - while [ -z "$(${androidsdkComposition}/android-sdk-*/platform-tools/adb -s emulator-$port shell getprop dev.bootcomplete | grep 1)" ] + 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" - #while [ -z "$(${androidsdkComposition}/android-sdk-*/platform-tools/adb -s emulator-$port shell getprop sys.boot_completed | grep 1)" ] + #while [ -z "$(${androidsdkComposition}/libexec/android-sdk-*/platform-tools/adb -s emulator-$port shell getprop sys.boot_completed | grep 1)" ] #do #sleep 5 #done @@ -76,10 +76,10 @@ stdenv.mkDerivation { echo "ready" # Install the App through the debugger - ${androidsdkComposition}/android-sdk-*/platform-tools/adb -s emulator-$port install ${app}/*.apk + ${androidsdkComposition}/android-sdk-*/libexec/platform-tools/adb -s emulator-$port install ${app}/*.apk # Start the application - ${androidsdkComposition}/android-sdk-*/platform-tools/adb -s emulator-$port shell am start -a android.intent.action.MAIN -n ${package}/.${activity} + ${androidsdkComposition}/android-sdk-*/libexec/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