From 0084c6f96a3a7d0c7983300a3a73504ea757a44c Mon Sep 17 00:00:00 2001 From: Anis Kadri Date: Tue, 20 Nov 2012 14:39:33 -0800 Subject: [PATCH] refactoring android commands --- bin/create | 7 ++-- .../ApplicationInfo/ApplicationInfo.class | Bin 0 -> 2045 bytes bin/templates/cordova/appinfo.jar | Bin 0 -> 1574 bytes bin/templates/cordova/{debug => build} | 2 +- bin/templates/cordova/{BOOM.bat => build.bat} | 2 +- bin/templates/cordova/cordova | 35 +++++++++++++----- bin/templates/cordova/debug.bat | 18 --------- bin/templates/cordova/emulate | 24 ------------ bin/templates/cordova/emulate.bat | 1 - bin/templates/cordova/{BOOM => run} | 2 +- bin/templates/cordova/run.bat | 1 + 11 files changed, 32 insertions(+), 60 deletions(-) create mode 100644 bin/templates/cordova/ApplicationInfo/ApplicationInfo.class create mode 100644 bin/templates/cordova/appinfo.jar rename bin/templates/cordova/{debug => build} (96%) rename bin/templates/cordova/{BOOM.bat => build.bat} (97%) delete mode 100644 bin/templates/cordova/debug.bat delete mode 100755 bin/templates/cordova/emulate delete mode 100644 bin/templates/cordova/emulate.bat rename bin/templates/cordova/{BOOM => run} (96%) create mode 100644 bin/templates/cordova/run.bat diff --git a/bin/create b/bin/create index 1bce739e..903f55ee 100755 --- a/bin/create +++ b/bin/create @@ -147,13 +147,12 @@ replace "s/__ACTIVITY__/${ACTIVITY}/g" "$MANIFEST_PATH" replace "s/__PACKAGE__/${PACKAGE}/g" "$MANIFEST_PATH" replace "s/__APILEVEL__/${API_LEVEL}/g" "$MANIFEST_PATH" -# creating cordova folder and copying emulate/debug/log/launch scripts +# creating cordova folder and copying run/build/log/launch scripts mkdir "$PROJECT_PATH"/cordova createAppInfoJar cp "$BUILD_PATH"/bin/templates/cordova/appinfo.jar "$PROJECT_PATH"/cordova/appinfo.jar cp "$BUILD_PATH"/bin/templates/cordova/cordova "$PROJECT_PATH"/cordova/cordova -cp "$BUILD_PATH"/bin/templates/cordova/debug "$PROJECT_PATH"/cordova/debug +cp "$BUILD_PATH"/bin/templates/cordova/build "$PROJECT_PATH"/cordova/build cp "$BUILD_PATH"/bin/templates/cordova/clean "$PROJECT_PATH"/cordova/clean cp "$BUILD_PATH"/bin/templates/cordova/log "$PROJECT_PATH"/cordova/log -cp "$BUILD_PATH"/bin/templates/cordova/emulate "$PROJECT_PATH"/cordova/emulate -cp "$BUILD_PATH"/bin/templates/cordova/BOOM "$PROJECT_PATH"/cordova/BOOM +cp "$BUILD_PATH"/bin/templates/cordova/run "$PROJECT_PATH"/cordova/run diff --git a/bin/templates/cordova/ApplicationInfo/ApplicationInfo.class b/bin/templates/cordova/ApplicationInfo/ApplicationInfo.class new file mode 100644 index 0000000000000000000000000000000000000000..2ef42a46862f75fffa8b780ff7cc579396224638 GIT binary patch literal 2045 zcma)7TUQ%Z6#h7 z@?0NM&}Em;{w9~Y&m_ni|L_(?$mcNBbpyJEPf;6qHu zF@v0p**N0(NXC7!e-OvVn3FIsW1$O+Sdy_U;h~IAWUMIo6rYJ9uV57g32O>^u`c0r z1t~Fqp%Y0kF7f{pEJvjWt3NS)7asz$IzS3@9F!xR@KdlR`eXhtmK59D@9K) zJzLf7KwZKU30s7eKoUN3Q_~HTp)dWUv$|5We5b^hjllJsZC8zw?irT3V(wU3;ZeoA z7$Ku7zQMODzQa=qbhwR@gt7{b9R|rJ40?sDs9={t)=QqTZ+J&44D3mGrlN`(!!^sP zXa~1TTG^^;OI2RuCNWd>2Gc3JW&HYsA&EBQ8VtYu;S3lH> zbC1uz6Y9XfVQDLCEvKp1s2aC1?;F)JcZj`D&a!2LfE{92#Sy+|NNL%ucHvU9VnxQuR& zAxX*?3^R;e#s(=5|1U^}XmC3WnNEqFZ_Si57-YDo(>Z~yaPLg&Jg-s&wpG0Ofvl(` zKIc&lZTlWY=2k}p7w=biC%vW>cm8NYuM{X_FT6LcS zLV~nfYM^-J2BKlh7j2#4dG;_F(ABL$;)|t-lH)V9A1YaDwozI%3_eICjtHmLiw>e!i9-U9g)@XQ$!hNA_I|R>=aT6 zGtu#+e2T6R!lzI|_yh5z+V~Rt1y_=9M1MzOGdvJ2Zbk-T$?oLUI+Dc`T&tt!82yEb zI{J>$E$04X$YQ?!f^bK$MeVsam@D)`iM>THR49PFjH?80h)!>yi})spWr}#-Bnq=c zVhfX`oxxL#p-k%v#<7bD>fDoLB?}uGJbGI*WMvSMe@HkaVN4=1CSl^Cge?8F2pONm z`;C~8u@L=$(afu#p=82S`C|+`!w1D6Q|( ccn>P332iPwD*SgLr2d5zxhFqUfy(WF0XzW=od5s; literal 0 HcmV?d00001 diff --git a/bin/templates/cordova/appinfo.jar b/bin/templates/cordova/appinfo.jar new file mode 100644 index 0000000000000000000000000000000000000000..31d01d75aa31c5d82b443b37f9eb43de3f694c9d GIT binary patch literal 1574 zcmWIWW@Zs#-~d9+oMJ}?B*4kQ!r%MB z$s^LUwKFWlM4l|ss(7aQI`dP}PqnmXFRh-dh>1sQHmDd)7WQsnt9Z8b>F1)4MT}r~ z#oHQLgaK`h1Y+Fo5(UaS78K-UCMT9;=I43lrRD1-=Oh*v_lCX>mv$BT?;E!}XIopF z`+^AF&@2v>?k(G#HcUW+<-8O4f$?3}!+A~ohJwdcJ{c{0)bUtZ z^83+0jxzGeQHOeZZt|T;j62rU(r#ooF)-kRrk${J;6WuXp=lyt5+V;h=L&MFTeu+p z#HJ?3I}}io`Y}tE*Pm8+%?Y%9EOX=c`23rK7pE?$=-KioASkUh<5sdp;B|ee-ha z^6p)-GrTL55_=~Ic^q<2l-iYO^kv!nE#~2;ro9jO(InV1Z`<2lffsEL8*x8dHdR)ufT%g~R!`$9j;UQ?Y=#4O4gDk?LZXOgeP7pd^T!(z>A!fld|fA|(Eabwzt5La2= zHoem;Gk0&-j=Gwa@wxQg12x0ouVU9dgYyL#gIif=e=>cNwNr8W!q283miFexDGEhZg8zp!jOws-Q))w{fw zp5J8|r=YKuJO7);mA3bSP0_i6F#&-ko2*STZ&D?uyjUmB`<}ufiEbDmgyU4&* z<(h%pHOV!}ETO;FC5l9!2zoB3tZ#Ya!h?&qXDRA4cl>dl?JVS`a_g8%ioDl}i}BqP zJ{#_-pR=!&OHRphPUTPIDLxf@DjFK^8*KQ+l&`j4{?S^sdw%y8EbKh^=!9Zkm&o=H z-;}%_$4b3-Jj$~0EW3y6AHJ3=`zI{=Ad+rlu=B4zs7Rb^rzda0!ocvC9aQu%GKnyt zmZ-4e5>%q10(cP#DqqpHB9~~O@)QAVflRnoq|z1L1Z0PSN 0) { print }}'` + local devices=`adb devices | awk '/List of devices attached/ { while(getline > 0) { print }}' | grep device` if [ -z "$devices" ] ; then echo "1" else @@ -37,7 +37,7 @@ function emulate { # 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" + # echo "Device attached or emulator already running" return fi @@ -78,25 +78,40 @@ function log { adb logcat } -function debug { +function run { if [ $(check_devices) == 0 ] ; then - ant debug install + clean && emulate && install && launch else - ant debug + build echo "##################################################################" - echo "# Plug in your device or launch an emulator with cordova/emulate #" + echo "# Plug in your device or launch an emulator with cordova/run #" echo "##################################################################" fi } +function install { + ant debug install +} + +function build { + ant debug +} + +function wait_for_device { + local i=0 + echo "Waiting for emulator..." + while [ check_devices -eq 0 || timeout -lt 300 ] + do + sleep 1 + i=$[i+1] + end + +} + 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 && debug && launch -} - # TODO parse arguments (cd "$PROJECT_PATH" && $1) diff --git a/bin/templates/cordova/debug.bat b/bin/templates/cordova/debug.bat deleted file mode 100644 index f980eb72..00000000 --- a/bin/templates/cordova/debug.bat +++ /dev/null @@ -1,18 +0,0 @@ -:: Licensed to the Apache Software Foundation (ASF) under one -:: or more contributor license agreements. See the NOTICE file -:: distributed with this work for additional information -:: regarding copyright ownership. The ASF licenses this file -:: to you under the Apache License, Version 2.0 (the -:: "License"); you may not use this file except in compliance -:: with the License. You may obtain a copy of the License at -:: -:: http://www.apache.org/licenses/LICENSE-2.0 -:: -:: Unless required by applicable law or agreed to in writing, -:: software distributed under the License is distributed on an -:: "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -:: KIND, either express or implied. See the License for the -:: specific language governing permissions and limitations -:: under the License. - -%~dp0\cordova.bat debug diff --git a/bin/templates/cordova/emulate b/bin/templates/cordova/emulate deleted file mode 100755 index fe27b2f3..00000000 --- a/bin/templates/cordova/emulate +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -#!/bin/bash - -set -e - -CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd ) - -bash "$CORDOVA_PATH"/cordova emulate diff --git a/bin/templates/cordova/emulate.bat b/bin/templates/cordova/emulate.bat deleted file mode 100644 index 87ef969f..00000000 --- a/bin/templates/cordova/emulate.bat +++ /dev/null @@ -1 +0,0 @@ -%~dp0\cordova.bat emulate diff --git a/bin/templates/cordova/BOOM b/bin/templates/cordova/run similarity index 96% rename from bin/templates/cordova/BOOM rename to bin/templates/cordova/run index 443502d8..840a8d5a 100755 --- a/bin/templates/cordova/BOOM +++ b/bin/templates/cordova/run @@ -21,4 +21,4 @@ set -e CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd ) -bash $CORDOVA_PATH/cordova BOOM +bash "$CORDOVA_PATH"/cordova run diff --git a/bin/templates/cordova/run.bat b/bin/templates/cordova/run.bat new file mode 100644 index 00000000..7c470ed8 --- /dev/null +++ b/bin/templates/cordova/run.bat @@ -0,0 +1 @@ +%~dp0\cordova.bat run