cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bennma...@apache.org
Subject git commit: CLI Script fixes
Date Wed, 19 Jun 2013 23:39:32 GMT
Updated Branches:
  refs/heads/master 7d3b04a29 -> d9e0b3fba


CLI Script fixes


Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/d9e0b3fb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/d9e0b3fb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/d9e0b3fb

Branch: refs/heads/master
Commit: d9e0b3fba131369787ba43686eeaa4853de69923
Parents: 7d3b04a
Author: Benn Mapes <benn.mapes@gmail.com>
Authored: Wed Jun 19 16:38:54 2013 -0700
Committer: Benn Mapes <benn.mapes@gmail.com>
Committed: Wed Jun 19 16:39:07 2013 -0700

----------------------------------------------------------------------
 wp8/template/cordova/lib/build.js  |  17 ++++-
 wp8/template/cordova/lib/clean.js  |  51 +-------------
 wp8/template/cordova/lib/deploy.js | 117 +++++++++++++++++---------------
 3 files changed, 81 insertions(+), 104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/d9e0b3fb/wp8/template/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/lib/build.js b/wp8/template/cordova/lib/build.js
index 9986a7e..fec2d17 100644
--- a/wp8/template/cordova/lib/build.js
+++ b/wp8/template/cordova/lib/build.js
@@ -85,6 +85,19 @@ function is_cordova_project(path) {
     return false;
 }
 
+function get_solution_name(path) {
+    if (fso.FolderExists(path)) {
+        var proj_folder = fso.GetFolder(path);
+        var proj_files = new Enumerator(proj_folder.Files);
+        for (;!proj_files.atEnd(); proj_files.moveNext()) {
+            if (fso.GetExtensionName(proj_files.item()) == 'sln') {
+                return proj_files.item();
+            }
+        }
+    }
+    return null;
+}
+
 // builds the project and .xap in release mode
 function build_xap_release(path) {
     Log("Building Cordova-WP8 Project:");
@@ -92,7 +105,7 @@ function build_xap_release(path) {
     Log("\tDirectory : " + path);
     
     wscript_shell.CurrentDirectory = path;
-    exec_verbose('msbuild /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
/p:Configuration=Release');
+    exec_verbose('msbuild ' + get_solution_name(path) + ' /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal
/nologo /p:Configuration=Release');
     
     // check if file xap was created
     if (fso.FolderExists(path + '\\Bin\\Release')) {
@@ -116,7 +129,7 @@ function build_xap_debug(path) {
     Log("\tDirectory : " + path);
     
     wscript_shell.CurrentDirectory = path;
-    exec_verbose('msbuild /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
/p:Configuration=Debug');
+    exec_verbose('msbuild ' + get_solution_name(path) + ' /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal
/nologo /p:Configuration=Debug');
     
     // check if file xap was created
     if (fso.FolderExists(path + '\\Bin\\Debug')) {

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/d9e0b3fb/wp8/template/cordova/lib/clean.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/lib/clean.js b/wp8/template/cordova/lib/clean.js
index b091425..f5bdbfc 100644
--- a/wp8/template/cordova/lib/clean.js
+++ b/wp8/template/cordova/lib/clean.js
@@ -28,11 +28,8 @@ var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\clean.js').join('');
 // help function
 function Usage() {
     Log("");
-    Log("Usage: clean [ --debug | --release ]");
-    Log("    --debug   : Cleans generated debug files in project.");
-    Log("    --release : Cleans generated release files in project.");
+    Log("Usage: clean");
     Log("examples:");
-    Log("    clean --debug");
     Log("    clean");
     Log("         - deletes all generated files in project");
     Log("");
@@ -52,32 +49,6 @@ function Log(msg, error) {
 function clean_project(path) {
     delete_if_exists(path + "\\obj");
     delete_if_exists(path + "\\Bin");
-
-    // checks to see if a .csproj file exists in the project root
-    if (fso.FolderExists(path)) {
-        var proj_folder = fso.GetFolder(path);
-        var proj_files = new Enumerator(proj_folder.Files);
-        for (;!proj_files.atEnd(); proj_files.moveNext()) {
-            if (fso.GetExtensionName(proj_files.item()) == 'user') {
-                delete_if_exists(proj_files.item())
-            } else if (fso.GetExtensionName(proj_files.item()) == 'sou') {
-                delete_if_exists(proj_files.item())
-            }
-        }
-    }
-    //TODO: delete Service References?
-}
-
-// cleans any files generated by build --debug
-function clean_debug(path) {
-    delete_if_exists(path + "\\obj\\Debug");
-    delete_if_exists(path + "\\Bin\\Debug");
-}
-
-// cleans any files generated by build --release
-function clean_release(path) {
-    delete_if_exists(path + "\\obj\\Release");
-    delete_if_exists(path + "\\Bin\\Release");
 }
 
 // deletes the path element if it exists
@@ -98,26 +69,8 @@ if (args.Count() > 0) {
         Usage();
         WScript.Quit(2);
     }
-    else if (args.Count() > 1) {
-        Log("Error: Too many arguments.", true);
-        Usage();
-        WScript.Quit(2);
-    }
-    else if (fso.FolderExists(ROOT)) {
-        if (args(0) == "--debug" || args(0) == "-d") {
-            clean_debug(ROOT);
-        }
-        else if (args(0) == "--release" || args(0) == "-r") {
-            clean_release(ROOT);
-        }
-        else {
-            Log("Error: \"" + args(0) + "\" is not recognized as a build option", true);
-            Usage();
-            WScript.Quit(2);
-        }
-    }
     else {
-        Log("Error: Project directory not found,", true);
+        Log("Error: \"" + args(0) + "\" is not recognized as a valid option", true);
         Usage();
         WScript.Quit(2);
     }

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/d9e0b3fb/wp8/template/cordova/lib/deploy.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/lib/deploy.js b/wp8/template/cordova/lib/deploy.js
index 29a3f7d..448fa78 100644
--- a/wp8/template/cordova/lib/deploy.js
+++ b/wp8/template/cordova/lib/deploy.js
@@ -28,6 +28,8 @@ var ROOT = WScript.ScriptFullName.split('\\cordova\\lib\\deploy.js').join('');
 var CORDOVA_DEPLOY_EXE = '\\cordova\\lib\\CordovaDeploy\\CordovaDeploy\\bin\\Debug\\CordovaDeploy.exe';
     // path to CordovaDeploy
 var CORDOVA_DEPLOY = '\\cordova\\lib\\CordovaDeploy';
+//device_id for targeting specific device
+var device_id;
 
 //build types
 var NONE = 0,
@@ -36,18 +38,27 @@ var NONE = 0,
     NO_BUILD = 3;
 var build_type = NONE;
 
+//deploy tpyes
+var NONE = 0,
+    EMULATOR = 1,
+    DEVICE = 2,
+    TARGET = 3;
+var deploy_type = NONE;
+
 
 // help function
 function Usage() {
     Log("");
-    Log("Usage: run [ --device | --emulator | --target=<id> ] [ --debug | --release
| --nobuild ]");
+    Log("Usage:");
+    Log("  run [ --device || --emulator || --target=<id> ] ");
+    Log("      [ --debug || --release || --nobuild ]");
     Log("    --device      : Deploys and runs the project on the connected device.");
-    Log("    --emulator    : Deploys and runs the project on an emulator.");
+    Log("    --emulator    : [DEFAULT] Deploys and runs the project on an emulator.");
     Log("    --target=<id> : Deploys and runs the project on the specified target.");
-    Log("    --debug       : Builds project in debug mode.");
+    Log("    --debug       : [DEFAULT] Builds project in debug mode.");
     Log("    --release     : Builds project in release mode.");
     Log("    --nobuild     : Ueses pre-built xap, or errors if project is not built.");
-    Log("examples:");
+    Log("Examples:");
     Log("    run");
     Log("    run --emulator");
     Log("    run --device");
@@ -184,7 +195,7 @@ function emulator(path)
 }
 
 // builds and launches the project on the specified target
-function target(path, device_id) {
+function target(path) {
     if (!fso.FileExists(path + CORDOVA_DEPLOY_EXE)) {
         cordovaDeploy(path);
     }
@@ -246,65 +257,67 @@ function build(path) {
     }
 }
 
+function run(path) {
+    switch(deploy_type) {
+        case EMULATOR :
+            build(path);
+            emulator(path);
+            break;
+        case DEVICE :
+            build(path);
+            device(path);
+            break;
+        case TARGET :
+            build(path);
+            target(path);
+            break;
+        case NONE :
+            Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified,
defaulting to --emulator");
+            build(path);
+            emulator(path);
+            break;
+        default :
+            Log("Deploy option not recognized: " + deploy_type, true);
+            WScript.Quit(2);
+            break;
+    }
+}
+
 
 if (args.Count() > 0) {
-    // support help flags
-    if (args(0) == "--help" || args(0) == "/?" ||
-            args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
-        Usage();
-        WScript.Quit(2);
-    }
-    else if (args.Count() > 2) {
+    // limit args
+    if (args.Count() > 2) {
         Log('Error: Too many arguments.', true);
         Usage();
         WScript.Quit(2);
     }
     else if (fso.FolderExists(ROOT)) {
-        if (args.Count() > 1) {
-            if (args(1) == "--release") {
+        // parse arguments
+        for(var i = 0; i < args.Count(); i++) {
+            if (args(i) == "--release") {
                 build_type = RELEASE;
             }
-            else if (args(1) == "--debug") {
+            else if (args(i) == "--debug") {
                 build_type = DEBUG;
             }
-            else if (args(1) == "--nobuild") {
+            else if (args(i) == "--nobuild") {
                 build_type = NO_BUILD;
             }
-            else {
-                Log('Error: \"' + args(1) + '\" is not recognized as a deploy option', true);
-                Usage();
-                WScript.Quit(2);
+            else if (args(i) == "--emulator" || args(i) == "-e") {
+                deploy_type = EMULATOR;
             }
-        }
-
-        if (args(0) == "--emulator" || args(0) == "-e") {
-            build(ROOT);
-            emulator(ROOT);
-        }
-        else if (args(0) == "--device" || args(0) == "-d") {
-            build(ROOT);
-            device(ROOT);
-        }
-        else if (args(0).substr(0,9) == "--target=") {
-            build(ROOT);
-            var device_id = args(0).split("--target=").join("");
-            target(ROOT, device_id);
-        }
-        else {
-            Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified,
defaulting to --emulator");
-            if (args(0) == "--release") {
-                build_type = RELEASE;
-                build(ROOT);
-                emulator(ROOT);
+            else if (args(i) == "--device" || args(i) == "-d") {
+                deploy_type = DEVICE;
             }
-            else if (args(0) == "--debug") {
-                build_type = DEBUG;
-                build(ROOT);
-                emulator(ROOT);
+            else if (args(i).substr(0,9) == "--target=") {
+                device_id = args(i).split("--target=").join("");
+                deploy_type = TARGET;
             }
-            else if (args(0) == "--nobuild") {
-                build_type = NO_BUILD;
-                emulator(ROOT);
+             // support help flags
+            else if (args(0) == "--help" || args(0) == "/?" ||
+                    args(0) == "help" || args(0) == "-help" || args(0) == "/help") {
+                Usage();
+                WScript.Quit(2);
             }
             else {
                 Log('Error: \"' + args(0) + '\" is not recognized as a deploy option', true);
@@ -319,8 +332,6 @@ if (args.Count() > 0) {
         WScript.Quit(2);
     }
 }
-else {
-    Log("WARNING: [ --target=<ID> | --emulator | --device ] not specified, defaulting
to --emulator");
-    build(ROOT);
-    emulator(ROOT);
-}
\ No newline at end of file
+
+// Finally run the project!
+run(ROOT);
\ No newline at end of file


Mime
View raw message