mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 12:03:28 +08:00
windows build/debug/launch scripts
This commit is contained in:
parent
6f8e13297e
commit
b9f9429542
@ -142,32 +142,32 @@ downloadCommonsCodec();
|
|||||||
exec('ant.bat -f '+ ROOT +'\\framework\\build.xml jar');
|
exec('ant.bat -f '+ ROOT +'\\framework\\build.xml jar');
|
||||||
|
|
||||||
// copy in the project template
|
// copy in the project template
|
||||||
exec('cmd /c xcopy '+ ROOT + '\\bin\\templates\\project\\res '+PROJECT_PATH+'\\res\\ /E /Y');
|
exec('%comspec% /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('%comspec% /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('%comspec% /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 copy '+ROOT+'\\bin\\templates\\project\\Activity.java '+ ACTIVITY_PATH +' /Y');
|
||||||
|
|
||||||
// copy in cordova.js
|
// 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
|
// 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
|
// copy in xml
|
||||||
fso.CreateFolder(PROJECT_PATH + '\\res\\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('%comspec% /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\\plugins.xml ' + PROJECT_PATH + '\\res\\xml\\plugins.xml /Y');
|
||||||
|
|
||||||
// copy cordova scripts
|
// copy cordova scripts
|
||||||
fso.CreateFolder(PROJECT_PATH + '\\cordova');
|
fso.CreateFolder(PROJECT_PATH + '\\cordova');
|
||||||
exec('cmd /c copy '+ROOT+'\\bin\\templates\\cordova\\appinfo.jar ' + PROJECT_PATH + '\\cordova\\appinfo.jar /Y');
|
exec('%comspec% /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('%comspec% /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('%comspec% /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('%comspec% /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('%comspec% /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('%comspec% /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('%comspec% /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\\BOOM.bat ' + PROJECT_PATH + '\\cordova\\BOOM.bat /Y');
|
||||||
|
|
||||||
// interpolate the activity name and package
|
// interpolate the activity name and package
|
||||||
replaceInFile(ACTIVITY_PATH, /__ACTIVITY__/, ACTIVITY);
|
replaceInFile(ACTIVITY_PATH, /__ACTIVITY__/, ACTIVITY);
|
||||||
|
Binary file not shown.
@ -21,7 +21,7 @@ public class ApplicationInfo {
|
|||||||
|
|
||||||
// getting activity name
|
// getting activity name
|
||||||
String activity = ((Element)dom.getElementsByTagName("activity").item(0)).getAttribute("android: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) {
|
} catch(ParserConfigurationException pce) {
|
||||||
pce.printStackTrace();
|
pce.printStackTrace();
|
||||||
} catch(SAXException se) {
|
} catch(SAXException se) {
|
||||||
|
@ -1 +0,0 @@
|
|||||||
Main-Class: ApplicationInfo
|
|
@ -0,0 +1 @@
|
|||||||
|
%~dp0\cordova.bat BOOM
|
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
%~dp0\cordova.bat clean
|
@ -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
|
56
bin/templates/cordova/cordova.js
vendored
56
bin/templates/cordova/cordova.js
vendored
@ -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");
|
shell=WScript.CreateObject("WScript.Shell");
|
||||||
|
|
||||||
function exec(command) {
|
function exec(command) {
|
||||||
var oExec=shell.Exec(command);
|
var oExec=shell.Exec(command);
|
||||||
var output = '';
|
var output = new String();
|
||||||
while (!oExec.StdOut.AtEndOfStream) {
|
while(oExec.Status == 0) {
|
||||||
output += oExec.StdOut.ReadLine();
|
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;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
function devices_running() {
|
function emulator_running() {
|
||||||
var local_devices = exec("adb devices");
|
var local_devices = shell.Exec("%comspec% /c adb devices").StdOut.ReadAll();
|
||||||
if(local_devices.match(/device |emulator /)) {
|
if(local_devices.match(/emulator/)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function emulate() {
|
function emulate() {
|
||||||
// don't run emulator if a device is plugged in or if emulator is already running
|
// 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!");
|
WScript.Echo("Device or Emulator already running!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var oExec = shell.Exec("android.bat list avd");
|
var oExec = shell.Exec("%comspec% /c android.bat list avd");
|
||||||
var avd_list = [];
|
var avd_list = [];
|
||||||
var avd_id = -10;
|
var avd_id = -10;
|
||||||
while(!oExec.StdOut.AtEndOfStream) {
|
while(!oExec.StdOut.AtEndOfStream) {
|
||||||
var output = oExec.StdOut.ReadLine();
|
var output = oExec.StdOut.ReadLine();
|
||||||
if(output.match(/Name: (.)*/)) {
|
if(output.match(/Name: (.)*/)) {
|
||||||
avd_list.push(output.replace(/\sName:\s/, ""));
|
avd_list.push(output.replace(/ *Name:\s/, ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// user has no AVDs
|
// user has no AVDs
|
||||||
@ -41,7 +48,7 @@ function emulate() {
|
|||||||
// user has only one AVD so we launch that one
|
// user has only one AVD so we launch that one
|
||||||
if(avd_list.length == 1) {
|
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
|
// 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());
|
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() {
|
function clean() {
|
||||||
WScript.Echo(exec("ant.bat clean"));
|
exec("%comspec% /c ant.bat clean -f "+ROOT+"\\build.xml 2>&1");
|
||||||
}
|
}
|
||||||
|
|
||||||
function debug() {
|
function debug() {
|
||||||
WScript.Echo(exec("ant.bat debug"));
|
exec("%comspec% /c ant.bat debug -f "+ROOT+"\\build.xml 2>&1");
|
||||||
}
|
}
|
||||||
|
|
||||||
function debug_install() {
|
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() {
|
function log() {
|
||||||
WScript.Echo(exec("adb.bat logcat"));
|
WScript.Echo(exec("%comspec% /c adb.bat logcat"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function launch() {
|
function launch() {
|
||||||
var launch_str=exec("java -jar "+ROOT+"\\cordova\\appinfo.jar "+ROOT+"\\AndroidManifest.xml")
|
var launch_str=exec("%comspec% /c java -jar "+ROOT+"\\cordova\\appinfo.jar "+ROOT+"\\AndroidManifest.xml");
|
||||||
exec("adb.bat shell am start -n "+launch_str);
|
//WScript.Echo(launch_str);
|
||||||
|
exec("%comspec% /c adb shell am start -n "+launch_str+" 2>&1");
|
||||||
}
|
}
|
||||||
|
|
||||||
function BOOM() {
|
function BOOM() {
|
||||||
clean();
|
clean();
|
||||||
if(devices_running()) {
|
if(emulator_running()) {
|
||||||
debug_install();
|
debug_install();
|
||||||
launch();
|
launch();
|
||||||
} else {
|
} else {
|
||||||
@ -92,5 +100,9 @@ function BOOM() {
|
|||||||
WScript.Echo("##################################################################");
|
WScript.Echo("##################################################################");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var args = WScript.Arguments;
|
||||||
emulate();
|
if(args.count() != 1) {
|
||||||
|
WScript.StdErr.Write("An error has occured!\n");
|
||||||
|
WScript.Quit(1);
|
||||||
|
}
|
||||||
|
eval(args(0)+"()");
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
%~dp0\cordova.bat debug
|
@ -0,0 +1 @@
|
|||||||
|
%~dp0\cordova.bat emulate
|
Loading…
Reference in New Issue
Block a user