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/13 01:11:23 UTC
[12/18] android commit: updating Windows !@#% build script
updating Windows !@#% build script
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/e8b80e87
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/e8b80e87
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/e8b80e87
Branch: refs/heads/master
Commit: e8b80e8752b840988b2b39e9106be584cea97075
Parents: 30a1164
Author: Anis Kadri <an...@gmail.com>
Authored: Thu Jun 7 19:56:08 2012 -0700
Committer: Anis Kadri <an...@gmail.com>
Committed: Thu Jun 7 19:56:08 2012 -0700
----------------------------------------------------------------------
bin/create.bat | 2 +-
bin/create.js | 77 ++++++++++++++++++++++-----------------------------
2 files changed, 34 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/e8b80e87/bin/create.bat
----------------------------------------------------------------------
diff --git a/bin/create.bat b/bin/create.bat
index 7182d21..12068a2 100644
--- a/bin/create.bat
+++ b/bin/create.bat
@@ -1 +1 @@
-cscript bin\create.js %*
\ No newline at end of file
+cscript %~dp0\create.js %*
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/e8b80e87/bin/create.js
----------------------------------------------------------------------
diff --git a/bin/create.js b/bin/create.js
index a15db7a..4984b6c 100644
--- a/bin/create.js
+++ b/bin/create.js
@@ -50,16 +50,16 @@ function exec(s, output) {
WScript.Echo("Command exited with code " + o.Status);
}
-function fork(s) {
- WScript.Echo('Executing ' + s);
- var o=shell.Exec(s);
- while (o.Status != 1) {
- WScript.Sleep(100);
- }
- WScript.Echo(o.StdOut.ReadAll());
- WScript.Echo(o.StdErr.ReadAll());
- WScript.Echo("Command exited with code " + o.Status);
-}
+//function fork(s) {
+// WScript.Echo('Executing ' + s);
+// var o=shell.Exec(s);
+// while (o.Status != 1) {
+// WScript.Sleep(100);
+// }
+// WScript.Echo(o.StdOut.ReadAll());
+// WScript.Echo(o.StdErr.ReadAll());
+// WScript.Echo("Command exited with code " + o.Status);
+//}
var args = WScript.Arguments, PROJECT_PATH="example",
PACKAGE="org.apache.cordova.example", ACTIVITY="cordovaExample",
@@ -79,7 +79,7 @@ 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 VERSION=read('VERSION').replace(/\r\n/,'').replace(/\n/,'');
+var VERSION=read(ROOT+'\\VERSION').replace(/\r\n/,'').replace(/\n/,'');
WScript.Echo("Project path: " + PROJECT_PATH);
WScript.Echo("Package: " + PACKAGE);
@@ -89,28 +89,24 @@ WScript.Echo("Activity path: " + ACTIVITY_PATH);
WScript.Echo("Manifest path: " + MANIFEST_PATH);
WScript.Echo("Cordova version: " + VERSION);
-// TODO: clobber any existing example
-
-/*
-if [ $# -eq 0 ]
-then
- rm -rf $PROJECT_PATH
-fi
-*/
-
// create the project
exec('android.bat create project --target '+TARGET+' --path '+PROJECT_PATH+' --package '+PACKAGE+' --activity '+ACTIVITY);
// update the cordova framework project to a target that exists on this machine
-exec('android.bat update project --target '+TARGET+' --path framework');
+exec('android.bat update project --target '+TARGET+' --path '+ROOT+'\\framework');
// pull down commons codec if necessary
var fso = WScript.CreateObject('Scripting.FileSystemObject');
if (!fso.FileExists(ROOT + '\\framework\\libs\\commons-codec-1.6.jar')) {
// We need the .jar
var url = 'http://mirror.symnds.com/software/Apache//commons/codec/binaries/commons-codec-1.6-bin.zip';
- var savePath = ROOT + '\\framework\\libs\\commons-codec-1.6-bin.zip';
+ var libsPath = ROOT + '\\framework\\libs';
+ var savePath = libsPath + '\\commons-codec-1.6-bin.zip';
if (!fso.FileExists(savePath)) {
+ if(!fso.FolderExists(ROOT + '\\framework\\libs')) {
+ fso.CreateFolder(libsPath);
+ WScript.Echo('Created new libs folder at '+libsPath);
+ }
// We need the zip to get the jar
var xhr = WScript.CreateObject('MSXML2.XMLHTTP');
xhr.open('GET', url, false);
@@ -139,36 +135,29 @@ if (!fso.FileExists(ROOT + '\\framework\\libs\\commons-codec-1.6.jar')) {
fso.DeleteFile(ROOT + '\\framework\\libs\\commons-codec-1.6-bin.zip');
fso.DeleteFolder(ROOT + '\\framework\\libs\\commons-codec-1.6', true);
}
-
-
// compile cordova.js and cordova.jar
// if you see an error about "Unable to resolve target" then you may need to
// update your android tools or install an additional Android platform version
-exec('ant.bat -f framework\\build.xml jar');
+exec('ant.bat -f '+ ROOT +'\\framework\\build.xml jar');
// copy in the project template
-exec('cmd /c xcopy bin\\templates\\project\\* '+PROJECT_PATH+' /S /Y');
-
-// copy example www assets
-exec('cmd /c xcopy ' + PROJECT_PATH + '\\cordova\\assets ' + PROJECT_PATH + ' /S /Y');
+exec('cmd /c xcopy '+ ROOT + '\\bin\\templates2\\project\\* '+PROJECT_PATH+' /S /Y');
// copy in cordova.js
-exec('cmd /c copy framework\\assets\\js\\cordova.android.js '+PROJECT_PATH+'\\.cordova\\android\\cordova-'+VERSION+'.js /Y');
+exec('cmd /c copy '+ROOT+'\\framework\\assets\\js\\cordova.js '+PROJECT_PATH+'\\assets\\www\\cordova-'+VERSION+'.js /Y');
// copy in cordova.jar
-exec('cmd /c copy framework\\cordova-'+VERSION+'.jar '+PROJECT_PATH+'\\.cordova\\android\\cordova-'+VERSION+'.jar /Y');
+exec('cmd /c copy '+ROOT+'\\framework\\cordova-'+VERSION+'.jar '+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar /Y');
// copy in xml
-exec('cmd /c copy framework\\res\\xml\\cordova.xml ' + PROJECT_PATH + '\\.cordova\\android\\cordova.xml /Y');
-exec('cmd /c copy framework\\res\\xml\\plugins.xml ' + PROJECT_PATH + '\\.cordova\\android\\plugins.xml /Y');
-
-// write out config file
-write(PROJECT_PATH + '\\.cordova\\config',
- 'VERSION=' + VERSION + '\r\n' +
- 'PROJECT_PATH=' + PROJECT_PATH + '\r\n' +
- 'PACKAGE=' + PACKAGE + '\r\n' +
- 'ACTIVITY=' + ACTIVITY + '\r\n' +
- 'TARGET=' + TARGET);
-
-// run project-specific create process
-fork('cscript.exe ' + PROJECT_PATH + '\\cordova\\create.js');
\ No newline at end of file
+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');
+
+// interpolate the activity name and package
+replaceInFile(ACTIVITY_PATH, /__ACTIVITY__/, ACTIVITY);
+replaceInFile(ACTIVITY_PATH, /__ID__/, PACKAGE);
+
+replaceInFile(MANIFEST_PATH, /__ACTIVITY__/, ACTIVITY);
+replaceInFile(MANIFEST_PATH, /__PACKAGE__/, PACKAGE);
+
+WScript.Echo('Create completed successfully.');