cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject [18/33] git commit: CB-5793 Don't clean before build and change output directory to ant-build to avoid conflicts with Eclipse.
Date Mon, 03 Feb 2014 18:37:31 GMT
CB-5793 Don't clean before build and change output directory to ant-build to avoid conflicts
with Eclipse.


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

Branch: refs/heads/master
Commit: da70943395f65157b29300af5fc44099f6e167e5
Parents: 7c63c95
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Sun Jan 19 23:08:05 2014 -0500
Committer: Archana Naik <naika@lab126.com>
Committed: Fri Jan 31 15:02:19 2014 -0800

----------------------------------------------------------------------
 bin/templates/cordova/lib/build.js | 38 ++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/da709433/bin/templates/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js
index 7ea7d09..5e8ce0a 100644
--- a/bin/templates/cordova/lib/build.js
+++ b/bin/templates/cordova/lib/build.js
@@ -20,7 +20,6 @@
 */
 
 var shell   = require('shelljs'),
-    clean   = require('./clean'),
     spawn   = require('./spawn'),
     Q       = require('q'),
     path    = require('path'),
@@ -34,13 +33,12 @@ var shell   = require('shelljs'),
 module.exports.run = function(build_type) {
     //default build type
     build_type = typeof build_type !== 'undefined' ? build_type : "--debug";
-    var args;
+    var args = ['debug', '-f', path.join(ROOT, 'build.xml'), '-Dout.dir=ant-build', '-Dgen.dir=ant-build/gen'];
     switch(build_type) {
         case '--debug' :
-            args = ['debug', '-f', path.join(ROOT, 'build.xml')];
             break;
         case '--release' :
-            args = ['release', '-f', path.join(ROOT, 'build.xml')];
+            args[0] = 'release';
             break;
         case '--nobuild' :
             console.log('Skipping build...');
@@ -48,10 +46,7 @@ module.exports.run = function(build_type) {
         default :
             return Q.reject('Build option \'' + build_type + '\' not recognized.');
     }
-    return clean.run() // TODO: Can we stop cleaning every time and let ant build incrementally?
-    .then(function() {
-        return spawn('ant', args);
-    });
+    return spawn('ant', args);
 }
 
 /*
@@ -59,17 +54,26 @@ module.exports.run = function(build_type) {
  * the script will error out. (should we error or just return undefined?)
  */
 module.exports.get_apk = function() {
-    if(fs.existsSync(path.join(ROOT, 'bin'))) {
-        var bin_files = fs.readdirSync(path.join(ROOT, 'bin'));
-        for (file in bin_files) {
-            if(path.extname(bin_files[file]) == '.apk') {
-                return path.join(ROOT, 'bin', bin_files[file]);
-            }
+    var binDir = path.join(ROOT, 'ant-build');
+    if (fs.existsSync(binDir)) {
+        var candidates = fs.readdirSync(binDir).filter(function(p) {
+            // Need to choose between release and debug .apk.
+            return path.extname(p) == '.apk';
+        }).map(function(p) {
+            p = path.join(binDir, p);
+            return { p: p, t: fs.statSync(p).mtime };
+        }).sort(function(a,b) {
+            return a.t > b.t ? -1 :
+                   a.t < b.t ? 1 : 0;
+        });
+        if (candidates.length === 0) {
+            console.error('ERROR : No .apk found in \'ant-build\' directory');
+            process.exit(2);
         }
-        console.error('ERROR : No .apk found in \'bin\' folder');
-        process.exit(2);
+        console.log('Using apk: ' + candidates[0].p);
+        return candidates[0].p;
     } else {
-        console.error('ERROR : unable to find project bin folder, could not locate .apk');
+        console.error('ERROR : unable to find project ant-build directory, could not locate
.apk');
         process.exit(2);
     }
 }


Mime
View raw message