Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 23A6310E5C for ; Thu, 6 Jun 2013 21:49:43 +0000 (UTC) Received: (qmail 40452 invoked by uid 500); 6 Jun 2013 21:49:43 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 40438 invoked by uid 500); 6 Jun 2013 21:49:43 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 40431 invoked by uid 99); 6 Jun 2013 21:49:43 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Jun 2013 21:49:43 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C8CE38139E4; Thu, 6 Jun 2013 21:49:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bennmapes@apache.org To: commits@cordova.apache.org Message-Id: <13efaed3c47946bc8007ec4ffaa49ecb@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: wp7 commit: fixed up deploy tooling to work with new cli run/emulate command Date: Thu, 6 Jun 2013 21:49:42 +0000 (UTC) Updated Branches: refs/heads/master 011d4b8cb -> a99700938 fixed up deploy tooling to work with new cli run/emulate command Project: http://git-wip-us.apache.org/repos/asf/cordova-wp7/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp7/commit/a9970093 Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp7/tree/a9970093 Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp7/diff/a9970093 Branch: refs/heads/master Commit: a997009385763c32f97f19d84016cdc810b95674 Parents: 011d4b8 Author: Benn Mapes Authored: Thu Jun 6 14:49:08 2013 -0700 Committer: Benn Mapes Committed: Thu Jun 6 14:49:08 2013 -0700 ---------------------------------------------------------------------- templates/standalone/cordova/lib/deploy.js | 117 ++++++++++++---------- 1 files changed, 64 insertions(+), 53 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-wp7/blob/a9970093/templates/standalone/cordova/lib/deploy.js ---------------------------------------------------------------------- diff --git a/templates/standalone/cordova/lib/deploy.js b/templates/standalone/cordova/lib/deploy.js index 29a3f7d..448fa78 100644 --- a/templates/standalone/cordova/lib/deploy.js +++ b/templates/standalone/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= ] [ --debug | --release | --nobuild ]"); + Log("Usage:"); + Log(" run [ --device || --emulator || --target= ] "); + 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= : 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= | --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= | --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= | --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