From c86b618aaaa2575eb47565127d7ebb7153daee82 Mon Sep 17 00:00:00 2001 From: Anis Kadri Date: Fri, 15 Jun 2012 18:35:34 -0700 Subject: [PATCH] adding bash helper scripts --- 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(+) create mode 100644 bin/templates/cordova/BOOM create mode 100644 bin/templates/cordova/appinfo.jar create mode 100644 bin/templates/cordova/clean create mode 100644 bin/templates/cordova/cordova create mode 100644 bin/templates/cordova/debug create mode 100644 bin/templates/cordova/emulate create mode 100644 bin/templates/cordova/log diff --git a/bin/templates/cordova/BOOM b/bin/templates/cordova/BOOM new file mode 100644 index 00000000..37c623c4 --- /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 diff --git a/bin/templates/cordova/appinfo.jar b/bin/templates/cordova/appinfo.jar new file mode 100644 index 0000000000000000000000000000000000000000..4116f48c30d083581fdcc7c08b91c53533cdd08a GIT binary patch literal 1527 zcmWIWW@Zs#-~hsFW#=6jkN_tG3xls~h@-BjpPT-_Qw$8u3<2Kk93T};P-Ou)HH!dM zz%~0i`gyv!28ZbRx_$ONbK1vSSMMUPx31Q?Gv_x48C)@b@U%$J%U8$K_hRWP7S0(j zC67o;Yh_r7i9A`NRq;&qb>^p{pK58(URpg@5fhKrY)~YlzEc= zN{J)ADyOvGPJ5cB+L^ENKkTS!h{zf)m3I++qIX0)o*kFtIP&byF3kygk$sVQw?i*S zo38Tp`W4;we73RQ-Qu;sCOwRhUM9~Gb7Hz#@AI~MCUe^2IBia6`gq$v*J=!`-j=e( zshIV?W`)BN7S9@KegBX@n8UPR)HnPIClul5`$n(LZ=Sl3IK_qw6e za;bgCoq4k(!asN%=C4@uptDW>V~9hhVDm)-Q;8K^D!ow&w%eO>c}=f~2JCBWbD00y z^o#iRtg5?Pzy4g7Ih)V;a*yA-;J!rT#`z`@HZ-n;()`biEpHi8-@+0QRs{AXdZ^zpyEqNdy#2OqxkHBbF~{H~15g>JX6 zGaDAJdfUL^wp+6?vXawm3hO&BWK6F+<=E=;sx&c4d*0E&u?Gfop1T5==u|$ zCDF2$?sZpxc&z({lz#Eg zZl@F3onK<#=}qSTRPj*sh_@cgJ!RjPLvkyME?BKna$D)Na(}x=W{vp8PbrDw8<%$0 z9${UUfe zRlm4<^rtM(H1+a}+neJ~>c3IYto)`Lczi?O@fsHu^Pe3ad7lM4TN=a*=7lUa@x8Hk zN$rWC?3OQl@smqqmVOnO_dsb?%xsBgN2@qz$J}1i)U5p>V*2-&sS+FOSIPuV2sdC` zxS$~Zpv8Y-L#z2N9~V^kOWHWug;o6JzT)&HEtCE5{^WwUqHRXv-wpP3d(S+rvU^96 z)cwPukq`LpF&^iEIL>C_{D_s3=2#t3W2! Vf-S(Cl?|kf83+#mX+>5L4*)4LUN8Uv literal 0 HcmV?d00001 diff --git a/bin/templates/cordova/clean b/bin/templates/cordova/clean new file mode 100644 index 00000000..daa84421 --- /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 diff --git a/bin/templates/cordova/cordova b/bin/templates/cordova/cordova new file mode 100644 index 00000000..0f3e452c --- /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) diff --git a/bin/templates/cordova/debug b/bin/templates/cordova/debug new file mode 100644 index 00000000..5d63a39f --- /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 diff --git a/bin/templates/cordova/emulate b/bin/templates/cordova/emulate new file mode 100644 index 00000000..6c4fab2b --- /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 diff --git a/bin/templates/cordova/log b/bin/templates/cordova/log new file mode 100644 index 00000000..ab3622e5 --- /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