You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/06/16 03:40:06 UTC
[4/4] android commit: adding bash helper scripts
adding bash helper scripts
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/c86b618a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/c86b618a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/c86b618a
Branch: refs/heads/master
Commit: c86b618aaaa2575eb47565127d7ebb7153daee82
Parents: 0a4d218
Author: Anis Kadri <an...@gmail.com>
Authored: Fri Jun 15 18:35:34 2012 -0700
Committer: Anis Kadri <an...@gmail.com>
Committed: Fri Jun 15 18:35:34 2012 -0700
----------------------------------------------------------------------
bin/templates/cordova/BOOM | 7 +++
bin/templates/cordova/appinfo.jar | Bin 0 -> 1527 bytes
bin/templates/cordova/clean | 7 +++
bin/templates/cordova/cordova | 91 ++++++++++++++++++++++++++++++++
bin/templates/cordova/debug | 7 +++
bin/templates/cordova/emulate | 7 +++
bin/templates/cordova/log | 7 +++
7 files changed, 126 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c86b618a/bin/templates/cordova/BOOM
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/BOOM b/bin/templates/cordova/BOOM
new file mode 100644
index 0000000..37c623c
--- /dev/null
+++ b/bin/templates/cordova/BOOM
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -e
+
+CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
+
+bash $CORDOVA_PATH/cordova BOOM
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c86b618a/bin/templates/cordova/appinfo.jar
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/appinfo.jar b/bin/templates/cordova/appinfo.jar
new file mode 100644
index 0000000..4116f48
Binary files /dev/null and b/bin/templates/cordova/appinfo.jar differ
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c86b618a/bin/templates/cordova/clean
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/clean b/bin/templates/cordova/clean
new file mode 100644
index 0000000..daa8442
--- /dev/null
+++ b/bin/templates/cordova/clean
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -e
+
+CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
+
+bash $CORDOVA_PATH/cordova clean
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c86b618a/bin/templates/cordova/cordova
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/cordova b/bin/templates/cordova/cordova
new file mode 100644
index 0000000..0f3e452
--- /dev/null
+++ b/bin/templates/cordova/cordova
@@ -0,0 +1,91 @@
+#!/bin/bash
+
+set -e
+
+PROJECT_PATH=$( cd "$( dirname "$0" )/.." && pwd )
+
+function check_devices {
+ local devices=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}'`
+ if [ -z "$devices" ] ; then
+ echo "1"
+ else
+ echo "0"
+ fi
+}
+
+function emulate {
+ declare -a avd_list=($(android list avd | grep "Name:" | cut -f 2 -d ":" | xargs))
+ # we need to start adb-server
+ adb start-server 1>/dev/null
+
+ # Do not launch an emulator if there is already one running or if a device is attached
+ if [ $(check_devices) == 0 ] ; then
+ echo "Device attached or emulator already running"
+ return
+ fi
+
+ local avd_id="1000" #FIXME: hopefully user does not have 1000 AVDs
+ # User has no AVDs
+ if [ ${#avd_list[@]} == 0 ]
+ then
+ echo "You don't have any Android Virtual Devices. Please create at least one AVD."
+ echo "android"
+ fi
+ # User has only one AVD
+ if [ ${#avd_list[@]} == 1 ]
+ then
+ emulator -cpu-delay 0 -no-boot-anim -cache /tmp/cache -avd ${avd_list[0]} 1> /dev/null 2>&1 &
+ # User has more than 1 AVD
+ elif [ ${#avd_list[@]} -gt 1 ]
+ then
+ while [ -z ${avd_list[$avd_id]} ]
+ do
+ echo "Choose from one of the following Android Virtual Devices [0 to $((${#avd_list[@]}-1))]:"
+ for(( i = 0 ; i < ${#avd_list[@]} ; i++ ))
+ do
+ echo "$i) ${avd_list[$i]}"
+ done
+ echo -n "> "
+ read avd_id
+ done
+ emulator -cpu-delay 0 -no-boot-anim -cache /tmp/cache -avd ${avd_list[$avd_id]} 1> /dev/null 2>&1 &
+ fi
+
+}
+
+function clean {
+ ant clean
+}
+# has to be used independently and not in conjuction with other commands
+function log {
+ adb logcat
+}
+
+function debug_install {
+ ant debug install
+}
+
+function debug {
+ ant debug
+}
+
+function launch {
+ local launch_str=$(java -jar $PROJECT_PATH/cordova/appinfo.jar $PROJECT_PATH/AndroidManifest.xml)
+ adb shell am start -n $launch_str
+}
+
+function BOOM {
+ clean
+ if [ $(check_devices) == 0 ] ; then
+ debug_install && launch
+ return
+ else
+ debug
+ echo "##################################################################"
+ echo "# Plug in your device or launch an emulator with cordova/emulate #"
+ echo "##################################################################"
+ fi
+}
+
+# TODO parse arguments
+(cd $PROJECT_PATH && $1)
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c86b618a/bin/templates/cordova/debug
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/debug b/bin/templates/cordova/debug
new file mode 100644
index 0000000..5d63a39
--- /dev/null
+++ b/bin/templates/cordova/debug
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -e
+
+CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
+
+bash $CORDOVA_PATH/cordova debug
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c86b618a/bin/templates/cordova/emulate
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/emulate b/bin/templates/cordova/emulate
new file mode 100644
index 0000000..6c4fab2
--- /dev/null
+++ b/bin/templates/cordova/emulate
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -e
+
+CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd )
+
+bash $CORDOVA_PATH/cordova emulate
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c86b618a/bin/templates/cordova/log
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/log b/bin/templates/cordova/log
new file mode 100644
index 0000000..ab3622e
--- /dev/null
+++ b/bin/templates/cordova/log
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -e
+
+PROJECT_PATH=$( cd "$( dirname "$0" )/.." && pwd )
+
+bash $PROJECT_PATH/cordova/cordova log