cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bra...@apache.org
Subject [1/2] git commit: Separate build into prepare and compile.
Date Wed, 13 Feb 2013 18:47:58 GMT
Separate build into prepare and compile.

Prepare just copies www and plugins into the platform directories, it's
much faster than the compilation, and great if you're using
Eclipse/Xcode/etc.


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

Branch: refs/heads/master
Commit: 5c10b0a1f7309830de21e8ae6e82822cf81461d7
Parents: 2e455a1
Author: Braden Shepherdson <braden@chromium.org>
Authored: Wed Feb 13 13:23:43 2013 -0500
Committer: Braden Shepherdson <braden@chromium.org>
Committed: Wed Feb 13 13:23:43 2013 -0500

----------------------------------------------------------------------
 bin/cordova    |    2 +-
 cordova.js     |   11 ++++-
 doc/help.txt   |    5 ++-
 src/build.js   |  120 ---------------------------------------------------
 src/compile.js |   94 ++++++++++++++++++++++++++++++++++++++++
 src/prepare.js |   96 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 204 insertions(+), 124 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5c10b0a1/bin/cordova
----------------------------------------------------------------------
diff --git a/bin/cordova b/bin/cordova
index 4d29175..e6ec3e1 100755
--- a/bin/cordova
+++ b/bin/cordova
@@ -29,7 +29,7 @@ if (version) {
     var r;
     if (cmd == 'create' || cmd == 'docs' || cmd == 'serve') {
         r = cordova[cmd].apply(this, opts);
-    } else if (cmd == 'emulate' || cmd == 'build') {
+    } else if (cmd == 'emulate' || cmd == 'build' || cmd == 'prepare' || cmd == 'compile')
{
         r = cordova[cmd].call(this, opts);
     } else {
         // platform or plugin cmds

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5c10b0a1/cordova.js
----------------------------------------------------------------------
diff --git a/cordova.js b/cordova.js
index 6d07878..224406b 100755
--- a/cordova.js
+++ b/cordova.js
@@ -16,14 +16,17 @@
     specific language governing permissions and limitations
     under the License.
 */
-var cordova_events = require('./src/events');
+var cordova_events = require('./src/events'),
+    prepare = require('./src/prepare'),
+    compile = require('./src/compile');
 
 module.exports = {
     help:     require('./src/help'),
     create:   require('./src/create'),
     platform: require('./src/platform'),
     platforms: require('./src/platform'),
-    build:    require('./src/build'),
+    prepare:    prepare,
+    compile:    compile,
     emulate:  require('./src/emulate'),
     plugin:   require('./src/plugin'),
     plugins:   require('./src/plugin'),
@@ -33,5 +36,9 @@ module.exports = {
     },
     emit:     function() {
         cordova_events.emit.apply(cordova_events, arguments);
+    },
+    build: function() {
+        prepare.apply(this, arguments);
+        compile.apply(this, arguments);
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5c10b0a1/doc/help.txt
----------------------------------------------------------------------
diff --git a/doc/help.txt b/doc/help.txt
index 5e9d409..28d74a9 100644
--- a/doc/help.txt
+++ b/doc/help.txt
@@ -11,7 +11,10 @@ Project-Level Commands
 
     platform(s) [add|remove|ls [name]] ... adds or removes a platform, or lists all currently-added
platforms
     plugin(s) [add|remove|ls [path]] ..... adds or removes a plugin (from the specified path),
or lists all currently-added plugins
-    build ............................. builds a cordova project
+    prepare [platform...] ............. copies files into the specified platforms, or all
platforms.
+                                        it is then ready for building by Eclipse/Xcode/etc.
+    compile [platform...] ............. builds the app for the specified (or all) platforms
+    build ............................. alias for prepare and then compile
     emulate ........................... starts emulator for cordova project
     serve <platform> [port] ........... runs a local web server for the www/ directory
of the given platform
                                         the default port is 8000

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5c10b0a1/src/build.js
----------------------------------------------------------------------
diff --git a/src/build.js b/src/build.js
deleted file mode 100644
index 0cd52db..0000000
--- a/src/build.js
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-*/
-var cordova_util  = require('./util'),
-    path          = require('path'),
-    config_parser = require('./config_parser'),
-    platform      = require('./platform'),
-    fs            = require('fs'),
-    shell         = require('shelljs'),
-    ls            = fs.readdirSync,
-    et            = require('elementtree'),
-    android_parser= require('./metadata/android_parser'),
-    blackberry_parser= require('./metadata/blackberry_parser'),
-    ios_parser    = require('./metadata/ios_parser'),
-    hooker        = require('./hooker'),
-    n             = require('ncallbacks'),
-    prompt        = require('prompt'),
-    util          = require('util');
-
-function shell_out_to_debug(projectRoot, platform, callback) {
-    var cmd = path.join(projectRoot, 'platforms', platform);
-    // TODO: this is bb10 only for now
-    // TODO: PLATFORM LIBRARY INCONSISTENCY
-    if (platform == 'blackberry') {
-        cmd = 'ant -f "' + path.join(cmd, 'build.xml') + '" qnx load-device';
-    } else {
-        cmd = '"' + cmd + '/cordova/build"';
-    }
-    shell.exec(cmd, {silent:true, async:true}, function(code, output) {
-        if (code > 0) {
-            throw new Error('An error occurred while building the ' + platform + ' project.
' + output);
-        } else {
-            callback();
-        }
-    });
-}
-
-module.exports = function build(platforms, callback) {
-    var projectRoot = cordova_util.isCordova(process.cwd());
-
-    if (!projectRoot) {
-        throw new Error('Current working directory is not a Cordova-based project.');
-    }
-
-    var xml = path.join(projectRoot, 'www', 'config.xml');
-    var assets = path.join(projectRoot, 'www');
-    var cfg = new config_parser(xml);
-
-    if (arguments.length === 0 || (platforms instanceof Array && platforms.length
=== 0)) {
-        platforms = ls(path.join(projectRoot, 'platforms'));
-    } else if (typeof platforms == 'string') platforms = [platforms];
-    else if (platforms instanceof Function && callback === undefined) {
-        callback = platforms;
-        platforms = ls(path.join(projectRoot, 'platforms'));
-    }
-
-    if (platforms.length === 0) throw new Error('No platforms added to this project. Please
use `cordova platform add <platform>`.');
-
-    var hooks = new hooker(projectRoot);
-    if (!(hooks.fire('before_build'))) {
-        throw new Error('before_build hooks exited with non-zero code. Aborting.');
-    }
-
-    var end = n(platforms.length, function() {
-        if (!(hooks.fire('after_build'))) {
-            throw new Error('after_build hooks exited with non-zero code. Aborting.');
-        }
-        if (callback) callback();
-    });
-
-    // Iterate over each added platform 
-    platforms.forEach(function(platform) {
-        // Figure out paths based on platform
-        var parser, platformPath;
-        switch (platform) {
-            case 'android':
-                platformPath = path.join(projectRoot, 'platforms', 'android');
-                parser = new android_parser(platformPath);
-
-                // Update the related platform project from the config
-                parser.update_project(cfg);
-                shell_out_to_debug(projectRoot, 'android', end);
-                break;
-            case 'blackberry':
-                platformPath = path.join(projectRoot, 'platforms', 'blackberry');
-                parser = new blackberry_parser(platformPath);
-                
-                // Update the related platform project from the config
-                parser.update_project(cfg, function() {
-                    // Shell it
-                    shell_out_to_debug(projectRoot, 'blackberry', end);
-                });
-                break;
-            case 'ios':
-                platformPath = path.join(projectRoot, 'platforms', 'ios');
-                parser = new ios_parser(platformPath);
-
-                // Update the related platform project from the config
-                parser.update_project(cfg, function() {
-                    shell_out_to_debug(projectRoot, 'ios', end);
-                });
-                break;
-        }
-    });
-};

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5c10b0a1/src/compile.js
----------------------------------------------------------------------
diff --git a/src/compile.js b/src/compile.js
new file mode 100644
index 0000000..0677c41
--- /dev/null
+++ b/src/compile.js
@@ -0,0 +1,94 @@
+/**
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+*/
+var cordova_util  = require('./util'),
+    path          = require('path'),
+    config_parser = require('./config_parser'),
+    platform      = require('./platform'),
+    fs            = require('fs'),
+    shell         = require('shelljs'),
+    ls            = fs.readdirSync,
+    et            = require('elementtree'),
+    android_parser= require('./metadata/android_parser'),
+    blackberry_parser= require('./metadata/blackberry_parser'),
+    ios_parser    = require('./metadata/ios_parser'),
+    hooker        = require('./hooker'),
+    n             = require('ncallbacks'),
+    prompt        = require('prompt'),
+    util          = require('util');
+
+
+function shell_out_to_debug(projectRoot, platform, callback) {
+    var cmd = path.join(projectRoot, 'platforms', platform);
+    // TODO: this is bb10 only for now
+    // TODO: PLATFORM LIBRARY INCONSISTENCY
+    if (platform == 'blackberry') {
+        cmd = 'ant -f "' + path.join(cmd, 'build.xml') + '" qnx load-device';
+    } else {
+        cmd = '"' + cmd + '/cordova/build"';
+    }
+    shell.exec(cmd, {silent:true, async:true}, function(code, output) {
+        if (code > 0) {
+            throw new Error('An error occurred while building the ' + platform + ' project.
' + output);
+        } else {
+            callback();
+        }
+    });
+}
+
+
+module.exports = function compile(platforms, callback) {
+    var projectRoot = cordova_util.isCordova(process.cwd());
+
+    if (!projectRoot) {
+        throw new Error('Current working directory is not a Cordova-based project.');
+    }
+
+    var xml = path.join(projectRoot, 'www', 'config.xml');
+    var assets = path.join(projectRoot, 'www');
+    var cfg = new config_parser(xml);
+
+    if (arguments.length === 0 || (platforms instanceof Array && platforms.length
=== 0)) {
+        platforms = ls(path.join(projectRoot, 'platforms'));
+    } else if (typeof platforms == 'string') platforms = [platforms];
+    else if (platforms instanceof Function && callback === undefined) {
+        callback = platforms;
+        platforms = ls(path.join(projectRoot, 'platforms'));
+    }
+
+    if (platforms.length === 0) throw new Error('No platforms added to this project. Please
use `cordova platform add <platform>`.');
+
+    var hooks = new hooker(projectRoot);
+    if (!(hooks.fire('before_compile'))) {
+        throw new Error('before_compile hooks exited with non-zero code. Aborting.');
+    }
+
+    var end = n(platforms.length, function() {
+        if (!(hooks.fire('after_compile'))) {
+            throw new Error('after_compile hooks exited with non-zero code. Aborting.');
+        }
+        if (callback) callback();
+    });
+
+    // Iterate over each added platform
+    platforms.forEach(function(platform) {
+        shell_out_to_debug(projectRoot, platform);
+    });
+};
+
+

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/5c10b0a1/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
new file mode 100644
index 0000000..9e5888b
--- /dev/null
+++ b/src/prepare.js
@@ -0,0 +1,96 @@
+/**
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+*/
+var cordova_util  = require('./util'),
+    path          = require('path'),
+    config_parser = require('./config_parser'),
+    platform      = require('./platform'),
+    fs            = require('fs'),
+    shell         = require('shelljs'),
+    ls            = fs.readdirSync,
+    et            = require('elementtree'),
+    android_parser= require('./metadata/android_parser'),
+    blackberry_parser= require('./metadata/blackberry_parser'),
+    ios_parser    = require('./metadata/ios_parser'),
+    hooker        = require('./hooker'),
+    n             = require('ncallbacks'),
+    prompt        = require('prompt'),
+    util          = require('util');
+
+module.exports = function prepare(platforms, callback) {
+    var projectRoot = cordova_util.isCordova(process.cwd());
+
+    if (!projectRoot) {
+        throw new Error('Current working directory is not a Cordova-based project.');
+    }
+
+    var xml = path.join(projectRoot, 'www', 'config.xml');
+    var assets = path.join(projectRoot, 'www');
+    var cfg = new config_parser(xml);
+
+    if (arguments.length === 0 || (platforms instanceof Array && platforms.length
=== 0)) {
+        platforms = ls(path.join(projectRoot, 'platforms'));
+    } else if (typeof platforms == 'string') platforms = [platforms];
+    else if (platforms instanceof Function && callback === undefined) {
+        callback = platforms;
+        platforms = ls(path.join(projectRoot, 'platforms'));
+    }
+
+    if (platforms.length === 0) throw new Error('No platforms added to this project. Please
use `cordova platform add <platform>`.');
+
+    var hooks = new hooker(projectRoot);
+    if (!(hooks.fire('before_prepare'))) {
+        throw new Error('before_prepare hooks exited with non-zero code. Aborting.');
+    }
+
+    var end = n(platforms.length, function() {
+        if (!(hooks.fire('after_prepare'))) {
+            throw new Error('after_prepare hooks exited with non-zero code. Aborting.');
+        }
+        if (callback) callback();
+    });
+
+    // Iterate over each added platform
+    platforms.forEach(function(platform) {
+        // Figure out paths based on platform
+        var parser, platformPath;
+        switch (platform) {
+            case 'android':
+                platformPath = path.join(projectRoot, 'platforms', 'android');
+                parser = new android_parser(platformPath);
+
+                // Update the related platform project from the config
+                parser.update_project(cfg);
+                break;
+            case 'blackberry':
+                platformPath = path.join(projectRoot, 'platforms', 'blackberry');
+                parser = new blackberry_parser(platformPath);
+
+                // Update the related platform project from the config
+                parser.update_project(cfg);
+                break;
+            case 'ios':
+                platformPath = path.join(projectRoot, 'platforms', 'ios');
+                parser = new ios_parser(platformPath);
+
+                // Update the related platform project from the config
+                parser.update_project(cfg);
+                break;
+        }
+    });
+};


Mime
View raw message