incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [4/4] android commit: adding windows scripts
Date Fri, 22 Jun 2012 04:16:07 GMT
adding windows 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/e9a91440
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/e9a91440
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/e9a91440

Branch: refs/heads/master
Commit: e9a9144098781153c76927588b78a6ef78ebd48b
Parents: 507554b
Author: Anis Kadri <anis.kadri@gmail.com>
Authored: Wed Jun 20 19:07:41 2012 -0700
Committer: Anis Kadri <anis.kadri@gmail.com>
Committed: Wed Jun 20 19:07:41 2012 -0700

----------------------------------------------------------------------
 bin/templates/cordova/cordova.js |   96 +++++++++++++++++++++++++++++++++
 1 files changed, 96 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/e9a91440/bin/templates/cordova/BOOM.bat
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/BOOM.bat b/bin/templates/cordova/BOOM.bat
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/e9a91440/bin/templates/cordova/clean.bat
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/clean.bat b/bin/templates/cordova/clean.bat
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/e9a91440/bin/templates/cordova/cordova.bat
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/cordova.bat b/bin/templates/cordova/cordova.bat
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/e9a91440/bin/templates/cordova/cordova.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/cordova.js b/bin/templates/cordova/cordova.js
new file mode 100644
index 0000000..6435707
--- /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();

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/e9a91440/bin/templates/cordova/debug.bat
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/debug.bat b/bin/templates/cordova/debug.bat
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/e9a91440/bin/templates/cordova/emulate.bat
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/emulate.bat b/bin/templates/cordova/emulate.bat
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/e9a91440/bin/templates/cordova/log.bat
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/log.bat b/bin/templates/cordova/log.bat
new file mode 100644
index 0000000..e69de29


Mime
View raw message