From e9a9144098781153c76927588b78a6ef78ebd48b Mon Sep 17 00:00:00 2001 From: Anis Kadri Date: Wed, 20 Jun 2012 19:07:41 -0700 Subject: [PATCH 1/4] adding windows scripts --- bin/templates/cordova/BOOM.bat | 0 bin/templates/cordova/clean.bat | 0 bin/templates/cordova/cordova.bat | 0 bin/templates/cordova/cordova.js | 96 +++++++++++++++++++++++++++++++ bin/templates/cordova/debug.bat | 0 bin/templates/cordova/emulate.bat | 0 bin/templates/cordova/log.bat | 0 7 files changed, 96 insertions(+) create mode 100644 bin/templates/cordova/BOOM.bat create mode 100644 bin/templates/cordova/clean.bat create mode 100644 bin/templates/cordova/cordova.bat create mode 100644 bin/templates/cordova/cordova.js create mode 100644 bin/templates/cordova/debug.bat create mode 100644 bin/templates/cordova/emulate.bat create mode 100644 bin/templates/cordova/log.bat diff --git a/bin/templates/cordova/BOOM.bat b/bin/templates/cordova/BOOM.bat new file mode 100644 index 00000000..e69de29b diff --git a/bin/templates/cordova/clean.bat b/bin/templates/cordova/clean.bat new file mode 100644 index 00000000..e69de29b diff --git a/bin/templates/cordova/cordova.bat b/bin/templates/cordova/cordova.bat new file mode 100644 index 00000000..e69de29b diff --git a/bin/templates/cordova/cordova.js b/bin/templates/cordova/cordova.js new file mode 100644 index 00000000..64357072 --- /dev/null +++ b/bin/templates/cordova/cordova.js @@ -0,0 +1,96 @@ +var ROOT = WScript.ScriptFullName.split('\\bin\\templates\\cordova\\cordova.js').join(''), + shell=WScript.CreateObject("WScript.Shell"); + +function exec(command) { + var oExec=shell.Exec(command); + var output = ''; + while (!oExec.StdOut.AtEndOfStream) { + output += oExec.StdOut.ReadLine(); + } + return output; +} + +function devices_running() { + var local_devices = exec("adb devices"); + if(local_devices.match(/device |emulator /)) { + return true; + } + return false; +} +function emulate() { + // don't run emulator if a device is plugged in or if emulator is already running + if(devices_running()) { + WScript.Echo("Device or Emulator already running!"); + return; + } + var oExec = shell.Exec("android.bat list avd"); + var avd_list = []; + var avd_id = -10; + while(!oExec.StdOut.AtEndOfStream) { + var output = oExec.StdOut.ReadLine(); + if(output.match(/Name: (.)*/)) { + avd_list.push(output.replace(/\sName:\s/, "")); + } + } + // user has no AVDs + if(avd_list.length == 0) { + WScript.Echo("You don't have any Android Virtual Devices. Please create at least one AVD."); + WScript.Echo("android"); + WScript.Quit(1); + } + // user has only one AVD so we launch that one + if(avd_list.length == 1) { + + exec("emulator.bat -cpu-delay 0 -no-boot-anim -cache /tmp/cache -avd "+avd_list[0]+" > NUL"); + } + + // user has more than one avd so we ask them to choose + if(avd_list.length > 1) { + while(!avd_list[avd_id]) { + WScript.Echo("Choose from one of the following Android Virtual Devices [0 to "+(avd_list.length - 1)+"]:") + for(i = 0, j = avd_list.length ; i < j ; i++) { + WScript.Echo((i)+") "+avd_list[i]); + } + WScript.StdOut.Write("> "); + avd_id = new Number(WScript.StdIn.ReadLine()); + } + + WScript.Echo("emulator.bat -cpu-delay 0 -no-boot-anim -cache /tmp/cache -avd "+avd_list[avd_id]+" > NUL"); + } +} + +function clean() { + WScript.Echo(exec("ant.bat clean")); +} + +function debug() { + WScript.Echo(exec("ant.bat debug")); +} + +function debug_install() { + WScript.Echo(exec("ant.bat debug install")); +} + +function log() { + WScript.Echo(exec("adb.bat logcat")); +} + +function launch() { + var launch_str=exec("java -jar "+ROOT+"\\cordova\\appinfo.jar "+ROOT+"\\AndroidManifest.xml") + exec("adb.bat shell am start -n "+launch_str); +} + +function BOOM() { + clean(); + if(devices_running()) { + debug_install(); + launch(); + } else { + debug(); + WScript.Echo("##################################################################"); + WScript.Echo("# Plug in your device or launch an emulator with cordova/emulate #"); + WScript.Echo("##################################################################"); + } +} + +emulate(); diff --git a/bin/templates/cordova/debug.bat b/bin/templates/cordova/debug.bat new file mode 100644 index 00000000..e69de29b diff --git a/bin/templates/cordova/emulate.bat b/bin/templates/cordova/emulate.bat new file mode 100644 index 00000000..e69de29b diff --git a/bin/templates/cordova/log.bat b/bin/templates/cordova/log.bat new file mode 100644 index 00000000..e69de29b From 6f8e13297e015fa7b0d30ed2b86e1b349fa748ef Mon Sep 17 00:00:00 2001 From: Anis Kadri Date: Wed, 20 Jun 2012 19:08:18 -0700 Subject: [PATCH 2/4] fixing create --- bin/create.js | 32 +++++++++++++++++++++-------- bin/tests/test_create_win.js | 39 ++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 10 deletions(-) diff --git a/bin/create.js b/bin/create.js index 9f704430..fcce4786 100644 --- a/bin/create.js +++ b/bin/create.js @@ -33,6 +33,10 @@ function read(filename) { f.Close(); return s; } +function setTarget() { + var targets = shell.Exec('android.bat list targets').StdOut.ReadAll().match(/id:\s\d+/g); + return targets[targets.length - 1].replace(/id: /, ""); // TODO: give users the option to set their target +} function write(filename, contents) { var fso=WScript.CreateObject("Scripting.FileSystemObject"); var f=fso.OpenTextFile(filename, 2, true); @@ -42,12 +46,11 @@ function write(filename, contents) { function replaceInFile(filename, regexp, replacement) { write(filename, read(filename).replace(regexp, replacement)); } -function exec(s, output) { - var o=shell.Exec(s); - while (o.Status == 0) { - WScript.Sleep(100); +function exec(command) { + var oShell=shell.Exec(command); + while (oShell.Status == 0) { + WScript.sleep(100); } - //WScript.Echo("Command exited with code " + o.Status); } function cleanup() { @@ -125,9 +128,8 @@ if(fso.FolderExists(PROJECT_PATH)) { var PACKAGE_AS_PATH=PACKAGE.replace(/\./g, '\\'); var ACTIVITY_PATH=PROJECT_PATH+'\\src\\'+PACKAGE_AS_PATH+'\\'+ACTIVITY+'.java'; var MANIFEST_PATH=PROJECT_PATH+'\\AndroidManifest.xml'; -var TARGET=shell.Exec('android.bat list targets').StdOut.ReadAll().match(/id:\s([0-9]).*/)[1]; +var TARGET=setTarget(); var VERSION=read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,''); - // create the project exec('android.bat create project --target '+TARGET+' --path '+PROJECT_PATH+' --package '+PACKAGE+' --activity '+ACTIVITY); @@ -140,7 +142,10 @@ downloadCommonsCodec(); exec('ant.bat -f '+ ROOT +'\\framework\\build.xml jar'); // copy in the project template -exec('cmd /c xcopy '+ ROOT + '\\bin\\templates\\project\\* '+PROJECT_PATH+' /S /Y'); +exec('cmd /c xcopy '+ ROOT + '\\bin\\templates\\project\\res '+PROJECT_PATH+'\\res\\ /E /Y'); +exec('cmd /c xcopy '+ ROOT + '\\bin\\templates\\project\\assets '+PROJECT_PATH+'\\assets\\ /E /Y'); +exec('cmd /c copy '+ROOT+'\\bin\\templates\\project\\AndroidManifest.xml ' + PROJECT_PATH + '\\AndroidManifest.xml /Y'); +exec('cmd /c copy '+ROOT+'\\bin\\templates\\project\\Activity.java '+ ACTIVITY_PATH +' /Y'); // copy in cordova.js exec('cmd /c copy '+ROOT+'\\framework\\assets\\www\\cordova-'+VERSION+'.js '+PROJECT_PATH+'\\assets\\www\\cordova-'+VERSION+'.js /Y'); @@ -153,6 +158,17 @@ fso.CreateFolder(PROJECT_PATH + '\\res\\xml'); exec('cmd /c copy '+ROOT+'\\framework\\res\\xml\\cordova.xml ' + PROJECT_PATH + '\\res\\xml\\cordova.xml /Y'); exec('cmd /c copy '+ROOT+'\\framework\\res\\xml\\plugins.xml ' + PROJECT_PATH + '\\res\\xml\\plugins.xml /Y'); +// copy cordova scripts +fso.CreateFolder(PROJECT_PATH + '\\cordova'); +exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\appinfo.jar ' + PROJECT_PATH + '\\cordova\\appinfo.jar /Y'); +exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\cordova.js ' + PROJECT_PATH + '\\cordova\\cordova.js /Y'); +exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\cordova.bat ' + PROJECT_PATH + '\\cordova\\cordova.bat /Y'); +exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\clean.bat ' + PROJECT_PATH + '\\cordova\\clean.bat /Y'); +exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\debug.bat ' + PROJECT_PATH + '\\cordova\\debug.bat /Y'); +exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\log.bat ' + PROJECT_PATH + '\\cordova\\log.bat /Y'); +exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\emulate.bat ' + PROJECT_PATH + '\\cordova\\emulate.bat /Y'); +exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\BOOM.bat ' + PROJECT_PATH + '\\cordova\\BOOM.bat /Y'); + // interpolate the activity name and package replaceInFile(ACTIVITY_PATH, /__ACTIVITY__/, ACTIVITY); replaceInFile(ACTIVITY_PATH, /__ID__/, PACKAGE); diff --git a/bin/tests/test_create_win.js b/bin/tests/test_create_win.js index 76dd6aab..e8202dec 100644 --- a/bin/tests/test_create_win.js +++ b/bin/tests/test_create_win.js @@ -91,8 +91,43 @@ create_project.on('exit', function(code) { assert(exists, 'cordova.js did not get added'); }); - // check that project compiles && creates a cordovaExample-debug.apk - // XXX: !@##!@# WINDOWS + // make sure cordova master script was added + path.exists(util.format('%s/cordova/cordova.bat', project_path), function(exists) { + assert(exists, 'cordova script did not get added'); + }); + + // make sure debug script was added + path.exists(util.format('%s/cordova/debug.bat', project_path), function(exists) { + assert(exists, 'debug script did not get added'); + }); + + // make sure BOOM script was added + path.exists(util.format('%s/cordova/BOOM.bat', project_path), function(exists) { + assert(exists, 'BOOM script did not get added'); + }); + + // make sure log script was added + path.exists(util.format('%s/cordova/log.bat', project_path), function(exists) { + assert(exists, 'log script did not get added'); + }); + + // make sure clean script was added + path.exists(util.format('%s/cordova/clean.bat', project_path), function(exists) { + assert(exists, 'clean script did not get added'); + }); + + // make sure emulate script was added + path.exists(util.format('%s/cordova/emulate.bat', project_path), function(exists) { + assert(exists, 'emulate script did not get added'); + }); + + // make sure appinfo.jar script was added + path.exists(util.format('%s/cordova/appinfo.jar', project_path), function(exists) { + assert(exists, 'appinfo.jar script did not get added'); + }); + + // check that project compiles && creates a cordovaExample-debug.apk + // XXX: !@##!@# WINDOWS exec('ant debug -f ' + project_path + "\\build.xml", function(error, stdout, stderr) { assert(error == null, "Cordova Android Project does not compile"); path.exists(util.format('%s/bin/%s-debug.apk', project_path, project_name), From b9f942954224a90a8955396673d5db91613eef18 Mon Sep 17 00:00:00 2001 From: Anis Kadri Date: Thu, 21 Jun 2012 21:15:53 -0700 Subject: [PATCH 3/4] windows build/debug/launch scripts --- bin/create.js | 32 +++++----- .../ApplicationInfo/ApplicationInfo.class | Bin 1941 -> 2045 bytes .../ApplicationInfo/ApplicationInfo.java | 2 +- .../cordova/ApplicationInfo/manifest.txt | 1 - bin/templates/cordova/BOOM.bat | 1 + bin/templates/cordova/appinfo.jar | Bin 1527 -> 1587 bytes bin/templates/cordova/clean.bat | 1 + bin/templates/cordova/cordova.bat | 15 +++++ bin/templates/cordova/cordova.js | 56 +++++++++++------- bin/templates/cordova/debug.bat | 1 + bin/templates/cordova/emulate.bat | 1 + 11 files changed, 70 insertions(+), 40 deletions(-) delete mode 100644 bin/templates/cordova/ApplicationInfo/manifest.txt diff --git a/bin/create.js b/bin/create.js index fcce4786..35d4fd79 100644 --- a/bin/create.js +++ b/bin/create.js @@ -142,32 +142,32 @@ downloadCommonsCodec(); exec('ant.bat -f '+ ROOT +'\\framework\\build.xml jar'); // copy in the project template -exec('cmd /c xcopy '+ ROOT + '\\bin\\templates\\project\\res '+PROJECT_PATH+'\\res\\ /E /Y'); -exec('cmd /c xcopy '+ ROOT + '\\bin\\templates\\project\\assets '+PROJECT_PATH+'\\assets\\ /E /Y'); -exec('cmd /c copy '+ROOT+'\\bin\\templates\\project\\AndroidManifest.xml ' + PROJECT_PATH + '\\AndroidManifest.xml /Y'); -exec('cmd /c copy '+ROOT+'\\bin\\templates\\project\\Activity.java '+ ACTIVITY_PATH +' /Y'); +exec('%comspec% /c xcopy '+ ROOT + '\\bin\\templates\\project\\res '+PROJECT_PATH+'\\res\\ /E /Y'); +exec('%comspec% /c xcopy '+ ROOT + '\\bin\\templates\\project\\assets '+PROJECT_PATH+'\\assets\\ /E /Y'); +exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\project\\AndroidManifest.xml ' + PROJECT_PATH + '\\AndroidManifest.xml /Y'); +exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\project\\Activity.java '+ ACTIVITY_PATH +' /Y'); // copy in cordova.js -exec('cmd /c copy '+ROOT+'\\framework\\assets\\www\\cordova-'+VERSION+'.js '+PROJECT_PATH+'\\assets\\www\\cordova-'+VERSION+'.js /Y'); +exec('%comspec% /c copy '+ROOT+'\\framework\\assets\\www\\cordova-'+VERSION+'.js '+PROJECT_PATH+'\\assets\\www\\cordova-'+VERSION+'.js /Y'); // copy in cordova.jar -exec('cmd /c copy '+ROOT+'\\framework\\cordova-'+VERSION+'.jar '+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar /Y'); +exec('%comspec% /c copy '+ROOT+'\\framework\\cordova-'+VERSION+'.jar '+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar /Y'); // copy in xml fso.CreateFolder(PROJECT_PATH + '\\res\\xml'); -exec('cmd /c copy '+ROOT+'\\framework\\res\\xml\\cordova.xml ' + PROJECT_PATH + '\\res\\xml\\cordova.xml /Y'); -exec('cmd /c copy '+ROOT+'\\framework\\res\\xml\\plugins.xml ' + PROJECT_PATH + '\\res\\xml\\plugins.xml /Y'); +exec('%comspec% /c copy '+ROOT+'\\framework\\res\\xml\\cordova.xml ' + PROJECT_PATH + '\\res\\xml\\cordova.xml /Y'); +exec('%comspec% /c copy '+ROOT+'\\framework\\res\\xml\\plugins.xml ' + PROJECT_PATH + '\\res\\xml\\plugins.xml /Y'); // copy cordova scripts fso.CreateFolder(PROJECT_PATH + '\\cordova'); -exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\appinfo.jar ' + PROJECT_PATH + '\\cordova\\appinfo.jar /Y'); -exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\cordova.js ' + PROJECT_PATH + '\\cordova\\cordova.js /Y'); -exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\cordova.bat ' + PROJECT_PATH + '\\cordova\\cordova.bat /Y'); -exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\clean.bat ' + PROJECT_PATH + '\\cordova\\clean.bat /Y'); -exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\debug.bat ' + PROJECT_PATH + '\\cordova\\debug.bat /Y'); -exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\log.bat ' + PROJECT_PATH + '\\cordova\\log.bat /Y'); -exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\emulate.bat ' + PROJECT_PATH + '\\cordova\\emulate.bat /Y'); -exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\BOOM.bat ' + PROJECT_PATH + '\\cordova\\BOOM.bat /Y'); +exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\appinfo.jar ' + PROJECT_PATH + '\\cordova\\appinfo.jar /Y'); +exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\cordova.js ' + PROJECT_PATH + '\\cordova\\cordova.js /Y'); +exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\cordova.bat ' + PROJECT_PATH + '\\cordova\\cordova.bat /Y'); +exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\clean.bat ' + PROJECT_PATH + '\\cordova\\clean.bat /Y'); +exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\debug.bat ' + PROJECT_PATH + '\\cordova\\debug.bat /Y'); +exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\log.bat ' + PROJECT_PATH + '\\cordova\\log.bat /Y'); +exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\emulate.bat ' + PROJECT_PATH + '\\cordova\\emulate.bat /Y'); +exec('%comspec% /c copy '+ROOT+'\\bin\\templates\\cordova\\BOOM.bat ' + PROJECT_PATH + '\\cordova\\BOOM.bat /Y'); // interpolate the activity name and package replaceInFile(ACTIVITY_PATH, /__ACTIVITY__/, ACTIVITY); diff --git a/bin/templates/cordova/ApplicationInfo/ApplicationInfo.class b/bin/templates/cordova/ApplicationInfo/ApplicationInfo.class index 6b854f7d209a1bea4014ab9b59749ed15d2cd7dc..5ad90f5ce8c8ac798634fe1588fd2919528fd5aa 100644 GIT binary patch delta 829 zcmZ{hTTc^F6otRj(w^yb3|IuLfQV48(kkEu?-dj;Tok+^sEqAUicp{}cn^O;Gx62L zCwxVdN;I07_~eiA7kJx)4?a1QS?laQ`|Q2WSue|fmal#L_2Dzn%`=m7dQA>;$b-Ws zN9YT4lw$_R!-P3uaMFuUg*i=9bH<=Q!~kav&S?e>&Kq1XxyU6ChD?ST(Tti@aanW4 zq{ibhlc>kzCbje$bzC*2$2BjyZg9innZ9D{2z)cp{lg=NGf-VLO+daSFxw!-aW^Cp@)iqy60*--z$H&O1x~6 z+dpgP$DQRBCzo=L{V(r+2~=95duB1eV2j8;_qD&$tqgp<*d#W3j~|6xm0*iR^}=!t z0v+#B8?sQe3I?~5Axuw|tff>1G32+BrqDp9>og~vPBF+AS2A+yVv5^t)uI3vz`@uE2Iqt$&IY+9S5LHcp4^sjFv+-4to0Lxj{)_FIa5noi9=l%{J?6PGVhMu`0!_^Vu+`Q(N6j?b?!JN(^4 z>(qXvcH%vCk@`(`muQIW5hx{T9O~R;uXht7NwAuLU`((D&!c7;-A3n@fDk_G2Q@NZ K26b<3>G=bJtdKeY delta 623 zcmW-dSx-|@5XXP_b~(4VSKES?ZY*V05fO324RN6^h)6|g1+=Xd3s#X<6Q6wa(U=<_ zjES#(CMLBp!4JTjAHnb8Hiwg(`Op04%>T^HpU}t9+nvAPe*njLWfNk|7H?de<2ENa z8RQhFEhd5lIb(5F$LE5a=YnF=;$na)E?HbwT(P;zv`vOmV{`aYsAzHa%n&cRzft>{(FU6BQAVS~p@$XVUZv=Ww4zha7pu1BWG+ z6)O%8d1RnA3Z?bJYT2Pc(ZDK{>Xp}(`WuH5j}^i{Vb%R&4DEgDP+?7;4Ae#kYVJ=X z8dfYgtn*A!b$HI8>oL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)ASrqF zB~iz)j>mjNBsckpNN)2HiG+X`aDSduqcly}y`+7}Qfq|t4quaXT&498p5P*?T$>o? z#d-;wT-&UIgDdb@m-p#q7_on;98r*0Fb1KZa9_bV{}VAfpG5JXcuyHTLOxb_{R`AW z^k!)X!@py2?G=VH7xyr{i%XfyB)hm$8sEcJS>O)d0mMmjq@zTgr>sCa9xlf3K}7o- zS%zmEJv8~?KTt~t2rv``m`0F?&-08mQ-0u%rg00;mG0M>TTlWYYz4c2zgKtKRh zlvV%$09li<1vMWraLzz56a<(F1ONb)2LJ#S0000000000000000M(KG7?T|a5C$Oy H00000Ga4{x diff --git a/bin/templates/cordova/clean.bat b/bin/templates/cordova/clean.bat index e69de29b..8194b33a 100644 --- a/bin/templates/cordova/clean.bat +++ b/bin/templates/cordova/clean.bat @@ -0,0 +1 @@ +%~dp0\cordova.bat clean diff --git a/bin/templates/cordova/cordova.bat b/bin/templates/cordova/cordova.bat index e69de29b..61641316 100644 --- a/bin/templates/cordova/cordova.bat +++ b/bin/templates/cordova/cordova.bat @@ -0,0 +1,15 @@ +@ECHO OFF +IF NOT DEFINED JAVA_HOME GOTO MISSING +FOR %%X in (java.exe ant.bat android.bat) do ( + SET FOUND=%%~$PATH:X + IF NOT DEFINED FOUND GOTO MISSING +) +cscript %~dp0\cordova.js %* +GOTO END +:MISSING +ECHO Missing one of the following: +ECHO JDK: http://java.oracle.com +ECHO Android SDK: http://developer.android.com +ECHO Apache ant: http://ant.apache.org +EXIT /B 1 +:END diff --git a/bin/templates/cordova/cordova.js b/bin/templates/cordova/cordova.js index 64357072..6353b55d 100644 --- a/bin/templates/cordova/cordova.js +++ b/bin/templates/cordova/cordova.js @@ -1,35 +1,42 @@ -var ROOT = WScript.ScriptFullName.split('\\bin\\templates\\cordova\\cordova.js').join(''), +var ROOT = WScript.ScriptFullName.split('\\cordova\\cordova.js').join(''), shell=WScript.CreateObject("WScript.Shell"); function exec(command) { var oExec=shell.Exec(command); - var output = ''; - while (!oExec.StdOut.AtEndOfStream) { - output += oExec.StdOut.ReadLine(); + var output = new String(); + while(oExec.Status == 0) { + if(!oExec.StdOut.AtEndOfStream) { + var line = oExec.StdOut.ReadLine(); + // XXX: Change to verbose mode + //WScript.StdOut.WriteLine(line); + output += line; + } + WScript.sleep(100); } + return output; } -function devices_running() { - var local_devices = exec("adb devices"); - if(local_devices.match(/device |emulator /)) { +function emulator_running() { + var local_devices = shell.Exec("%comspec% /c adb devices").StdOut.ReadAll(); + if(local_devices.match(/emulator/)) { return true; } return false; } function emulate() { // don't run emulator if a device is plugged in or if emulator is already running - if(devices_running()) { + if(emulator_running()) { WScript.Echo("Device or Emulator already running!"); return; } - var oExec = shell.Exec("android.bat list avd"); + var oExec = shell.Exec("%comspec% /c android.bat list avd"); var avd_list = []; var avd_id = -10; while(!oExec.StdOut.AtEndOfStream) { var output = oExec.StdOut.ReadLine(); if(output.match(/Name: (.)*/)) { - avd_list.push(output.replace(/\sName:\s/, "")); + avd_list.push(output.replace(/ *Name:\s/, "")); } } // user has no AVDs @@ -41,7 +48,7 @@ function emulate() { // user has only one AVD so we launch that one if(avd_list.length == 1) { - exec("emulator.bat -cpu-delay 0 -no-boot-anim -cache /tmp/cache -avd "+avd_list[0]+" > NUL"); + shell.Run("emulator -cpu-delay 0 -no-boot-anim -cache %Temp%\cache -avd "+avd_list[0]); } // user has more than one avd so we ask them to choose @@ -55,34 +62,35 @@ function emulate() { avd_id = new Number(WScript.StdIn.ReadLine()); } - WScript.Echo("emulator.bat -cpu-delay 0 -no-boot-anim -cache /tmp/cache -avd "+avd_list[avd_id]+" > NUL"); + shell.Run("emulator -cpu-delay 0 -no-boot-anim -cache %Temp%\\cache -avd "+avd_list[avd_id], 0, false); } } function clean() { - WScript.Echo(exec("ant.bat clean")); + exec("%comspec% /c ant.bat clean -f "+ROOT+"\\build.xml 2>&1"); } function debug() { - WScript.Echo(exec("ant.bat debug")); + exec("%comspec% /c ant.bat debug -f "+ROOT+"\\build.xml 2>&1"); } function debug_install() { - WScript.Echo(exec("ant.bat debug install")); + exec("%comspec% /c ant.bat debug install -f "+ROOT+"\\build.xml 2>&1"); } function log() { - WScript.Echo(exec("adb.bat logcat")); + WScript.Echo(exec("%comspec% /c adb.bat logcat")); } function launch() { - var launch_str=exec("java -jar "+ROOT+"\\cordova\\appinfo.jar "+ROOT+"\\AndroidManifest.xml") - exec("adb.bat shell am start -n "+launch_str); + var launch_str=exec("%comspec% /c java -jar "+ROOT+"\\cordova\\appinfo.jar "+ROOT+"\\AndroidManifest.xml"); + //WScript.Echo(launch_str); + exec("%comspec% /c adb shell am start -n "+launch_str+" 2>&1"); } function BOOM() { - clean(); - if(devices_running()) { + clean(); + if(emulator_running()) { debug_install(); launch(); } else { @@ -92,5 +100,9 @@ function BOOM() { WScript.Echo("##################################################################"); } } - -emulate(); +var args = WScript.Arguments; +if(args.count() != 1) { + WScript.StdErr.Write("An error has occured!\n"); + WScript.Quit(1); +} +eval(args(0)+"()"); diff --git a/bin/templates/cordova/debug.bat b/bin/templates/cordova/debug.bat index e69de29b..ff5edc2c 100644 --- a/bin/templates/cordova/debug.bat +++ b/bin/templates/cordova/debug.bat @@ -0,0 +1 @@ +%~dp0\cordova.bat debug diff --git a/bin/templates/cordova/emulate.bat b/bin/templates/cordova/emulate.bat index e69de29b..87ef969f 100644 --- a/bin/templates/cordova/emulate.bat +++ b/bin/templates/cordova/emulate.bat @@ -0,0 +1 @@ +%~dp0\cordova.bat emulate From fba87de064446a613c0a7475e0088c51514498a4 Mon Sep 17 00:00:00 2001 From: Fil Maj Date: Fri, 22 Jun 2012 10:07:07 -0700 Subject: [PATCH 4/4] Removed some legacy button code that existed in droidgap + app plugins --- framework/src/org/apache/cordova/App.java | 12 ------- .../src/org/apache/cordova/DroidGap.java | 33 ------------------- 2 files changed, 45 deletions(-) diff --git a/framework/src/org/apache/cordova/App.java b/framework/src/org/apache/cordova/App.java index 8d0895b0..4830c581 100755 --- a/framework/src/org/apache/cordova/App.java +++ b/framework/src/org/apache/cordova/App.java @@ -73,10 +73,6 @@ public class App extends Plugin { else if (action.equals("overrideBackbutton")) { this.overrideBackbutton(args.getBoolean(0)); } - else if (action.equals("isBackbuttonOverridden")) { - boolean b = this.isBackbuttonOverridden(); - return new PluginResult(status, b); - } else if (action.equals("exitApp")) { this.exitApp(); } @@ -202,14 +198,6 @@ public class App extends Plugin { LOG.i("DroidGap", "WARNING: Volume Button Default Behaviour will be overridden. The volume event will be fired!"); webView.bindButton(button, override); } - /** - * Return whether the Android back button is overridden by the user. - * - * @return boolean - */ - public boolean isBackbuttonOverridden() { - return this.cordova.isBackButtonBound(); - } /** * Exit the Android application. diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java index 8b26f375..723be5c0 100755 --- a/framework/src/org/apache/cordova/DroidGap.java +++ b/framework/src/org/apache/cordova/DroidGap.java @@ -138,7 +138,6 @@ public class DroidGap extends Activity implements CordovaInterface { protected CordovaWebViewClient webViewClient; protected LinearLayout root; - public boolean bound = false; protected boolean cancelLoadUrl = false; protected ProgressDialog spinnerDialog = null; @@ -181,10 +180,6 @@ public class DroidGap extends Activity implements CordovaInterface { // when another application (activity) is started. protected boolean keepRunning = true; - private boolean volumeupBound; - - private boolean volumedownBound; - /** * Sets the authentication token. * @@ -948,24 +943,6 @@ public class DroidGap extends Activity implements CordovaInterface { return this.getContext(); } - /** - * Override the backbutton. - * - * @param override - */ - public void bindBackButton(boolean override) { - this.bound = override; - } - - /** - * Determine of backbutton is overridden. - * - * @return - */ - public boolean isBackButtonBound() { - return this.bound; - } - /** * Load the specified URL in the Cordova webview or a new browser instance. * @@ -982,16 +959,6 @@ public class DroidGap extends Activity implements CordovaInterface { } } - public void bindButton(String button, boolean override) { - // TODO Auto-generated method stub - if (button.compareTo("volumeup")==0) { - this.volumeupBound = override; - } - else if (button.compareTo("volumedown")==0) { - this.volumedownBound = override; - } - } - protected Dialog splashDialog; /**