You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/06/22 06:16:06 UTC
[2/4] android commit: windows build/debug/launch scripts
windows build/debug/launch 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/b9f94295
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/b9f94295
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/b9f94295
Branch: refs/heads/master
Commit: b9f942954224a90a8955396673d5db91613eef18
Parents: 6f8e132
Author: Anis Kadri <an...@gmail.com>
Authored: Thu Jun 21 21:15:53 2012 -0700
Committer: Anis Kadri <an...@gmail.com>
Committed: Thu Jun 21 21:15:53 2012 -0700
----------------------------------------------------------------------
bin/create.js | 32 ++++----
.../cordova/ApplicationInfo/ApplicationInfo.class | Bin 1941 -> 2045 bytes
.../cordova/ApplicationInfo/ApplicationInfo.java | 2 +-
bin/templates/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(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b9f94295/bin/create.js
----------------------------------------------------------------------
diff --git a/bin/create.js b/bin/create.js
index fcce478..35d4fd7 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);
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b9f94295/bin/templates/cordova/ApplicationInfo/ApplicationInfo.class
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/ApplicationInfo/ApplicationInfo.class b/bin/templates/cordova/ApplicationInfo/ApplicationInfo.class
index 6b854f7..5ad90f5 100644
Binary files a/bin/templates/cordova/ApplicationInfo/ApplicationInfo.class and b/bin/templates/cordova/ApplicationInfo/ApplicationInfo.class differ
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b9f94295/bin/templates/cordova/ApplicationInfo/ApplicationInfo.java
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/ApplicationInfo/ApplicationInfo.java b/bin/templates/cordova/ApplicationInfo/ApplicationInfo.java
index 9a66321..21a0787 100644
--- a/bin/templates/cordova/ApplicationInfo/ApplicationInfo.java
+++ b/bin/templates/cordova/ApplicationInfo/ApplicationInfo.java
@@ -21,7 +21,7 @@ public class ApplicationInfo {
// getting activity name
String activity = ((Element)dom.getElementsByTagName("activity").item(0)).getAttribute("android:name");
- System.out.println(String.format("%s/%s.%s", pakkage, pakkage, activity));
+ System.out.println(String.format("%s/.%s", pakkage, activity.replace(".", "")));
} catch(ParserConfigurationException pce) {
pce.printStackTrace();
} catch(SAXException se) {
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b9f94295/bin/templates/cordova/ApplicationInfo/manifest.txt
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/ApplicationInfo/manifest.txt b/bin/templates/cordova/ApplicationInfo/manifest.txt
deleted file mode 100644
index 7d77999..0000000
--- a/bin/templates/cordova/ApplicationInfo/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Main-Class: ApplicationInfo
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b9f94295/bin/templates/cordova/BOOM.bat
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/BOOM.bat b/bin/templates/cordova/BOOM.bat
index e69de29..87b1042 100644
--- a/bin/templates/cordova/BOOM.bat
+++ b/bin/templates/cordova/BOOM.bat
@@ -0,0 +1 @@
+%~dp0\cordova.bat BOOM
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b9f94295/bin/templates/cordova/appinfo.jar
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/appinfo.jar b/bin/templates/cordova/appinfo.jar
index 4116f48..37e00df 100644
Binary files a/bin/templates/cordova/appinfo.jar and b/bin/templates/cordova/appinfo.jar differ
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b9f94295/bin/templates/cordova/clean.bat
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/clean.bat b/bin/templates/cordova/clean.bat
index e69de29..8194b33 100644
--- a/bin/templates/cordova/clean.bat
+++ b/bin/templates/cordova/clean.bat
@@ -0,0 +1 @@
+%~dp0\cordova.bat clean
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b9f94295/bin/templates/cordova/cordova.bat
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/cordova.bat b/bin/templates/cordova/cordova.bat
index e69de29..6164131 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
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b9f94295/bin/templates/cordova/cordova.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/cordova.js b/bin/templates/cordova/cordova.js
index 6435707..6353b55 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)+"()");
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b9f94295/bin/templates/cordova/debug.bat
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/debug.bat b/bin/templates/cordova/debug.bat
index e69de29..ff5edc2 100644
--- a/bin/templates/cordova/debug.bat
+++ b/bin/templates/cordova/debug.bat
@@ -0,0 +1 @@
+%~dp0\cordova.bat debug
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b9f94295/bin/templates/cordova/emulate.bat
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/emulate.bat b/bin/templates/cordova/emulate.bat
index e69de29..87ef969 100644
--- a/bin/templates/cordova/emulate.bat
+++ b/bin/templates/cordova/emulate.bat
@@ -0,0 +1 @@
+%~dp0\cordova.bat emulate