You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2012/11/23 04:28:59 UTC
[3/11] android commit: refactoring windows scripts
refactoring windows scripts
Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/68161d27
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/68161d27
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/68161d27
Branch: refs/heads/master
Commit: 68161d2714c9d966139f3c9fe485b582884939c3
Parents: a6473cb
Author: Anis Kadri <an...@gmail.com>
Authored: Tue Nov 20 18:49:16 2012 -0800
Committer: Simon MacDonald <si...@gmail.com>
Committed: Thu Nov 22 22:23:51 2012 -0500
----------------------------------------------------------------------
bin/create.js | 5 +--
bin/templates/cordova/cordova.js | 46 ++++++++++++++++++++++----------
2 files changed, 33 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/68161d27/bin/create.js
----------------------------------------------------------------------
diff --git a/bin/create.js b/bin/create.js
index 2d6b8d6..258c32c 100644
--- a/bin/create.js
+++ b/bin/create.js
@@ -198,10 +198,9 @@ exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\appinfo.jar ' + PRO
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\\build.bat ' + PROJECT_PATH + '\\cordova\\build.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');
+exec('%comspec% /c copy "'+ROOT+'"\\bin\\templates\\cordova\\run.bat ' + PROJECT_PATH + '\\cordova\\run.bat /Y');
// interpolate the activity name and package
WScript.Echo("Updating AndroidManifest.xml and Main Activity...");
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/68161d27/bin/templates/cordova/cordova.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/cordova.js b/bin/templates/cordova/cordova.js
index ff91430..51533cb 100644
--- a/bin/templates/cordova/cordova.js
+++ b/bin/templates/cordova/cordova.js
@@ -34,17 +34,19 @@ function exec(command) {
return output;
}
-function emulator_running() {
+function device_running() {
var local_devices = shell.Exec("%comspec% /c adb devices").StdOut.ReadAll();
- if(local_devices.match(/emulator/)) {
+ if(local_devices.match(/\w+\tdevice/)) {
+ WScript.Echo("Yes");
return true;
}
+ WScript.Echo("No");
return false;
}
function emulate() {
// don't run emulator if a device is plugged in or if emulator is already running
- if(emulator_running()) {
- WScript.Echo("Device or Emulator already running!");
+ if(device_running()) {
+ //WScript.Echo("Device or Emulator already running!");
return;
}
var oExec = shell.Exec("%comspec% /c android.bat list avd");
@@ -84,18 +86,18 @@ function emulate() {
}
function clean() {
+ WScript.Echo("Cleaning project...");
exec("%comspec% /c ant.bat clean -f "+ROOT+"\\build.xml 2>&1");
}
-function debug() {
- if(emulator_running()) {
- exec("%comspec% /c ant.bat debug install -f "+ROOT+"\\build.xml 2>&1");
- } else {
- exec("%comspec% /c ant.bat debug -f "+ROOT+"\\build.xml 2>&1");
- WScript.Echo("##################################################################");
- WScript.Echo("# Plug in your device or launch an emulator with cordova/emulate #");
- WScript.Echo("##################################################################");
- }
+function build() {
+ WScript.Echo("Building project...");
+ exec("%comspec% /c ant.bat debug -f "+ROOT+"\\build.xml 2>&1");
+}
+
+function install() {
+ WScript.Echo("Building/Installing project...");
+ exec("%comspec% /c ant.bat debug install -f "+ROOT+"\\build.xml 2>&1");
}
function log() {
@@ -103,14 +105,28 @@ function log() {
}
function launch() {
+ WScript.Echo("Launching app...");
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() {
+function run() {
+ var i=0;
clean();
- debug();
+ emulate();
+ WScript.Stdout.Write('Waiting for device...');
+ while(!device_running() && i < 300) {
+ WScript.Stdout.Write('.');
+ WScript.sleep(1000);
+ i += 1;
+ }
+ if(i == 300) {
+ WScript.Stderr.WriteLine("device/emulator timeout!");
+ } else {
+ WScript.Stdout.WriteLine("connected!");
+ }
+ install();
launch();
}
var args = WScript.Arguments;