mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 15:12:51 +08:00
CB-5801 exec->spawn in build to make sure compile errors are shown.
This commit is contained in:
parent
e16cab6b9c
commit
4971670e56
21
bin/templates/cordova/lib/build.js
vendored
21
bin/templates/cordova/lib/build.js
vendored
@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
var shell = require('shelljs'),
|
||||
exec = require('./exec'),
|
||||
Q = require('q'),
|
||||
clean = require('./clean'),
|
||||
spawn = require('./spawn'),
|
||||
Q = require('q'),
|
||||
path = require('path'),
|
||||
fs = require('fs'),
|
||||
ROOT = path.join(__dirname, '..', '..');
|
||||
@ -34,13 +34,13 @@ var shell = require('shelljs'),
|
||||
module.exports.run = function(build_type) {
|
||||
//default build type
|
||||
build_type = typeof build_type !== 'undefined' ? build_type : "--debug";
|
||||
var cmd;
|
||||
var args;
|
||||
switch(build_type) {
|
||||
case '--debug' :
|
||||
cmd = 'ant debug -f "' + path.join(ROOT, 'build.xml') + '"';
|
||||
args = ['debug', '-f', path.join(ROOT, 'build.xml')];
|
||||
break;
|
||||
case '--release' :
|
||||
cmd = 'ant release -f "' + path.join(ROOT, 'build.xml') + '"';
|
||||
args = ['release', '-f', path.join(ROOT, 'build.xml')];
|
||||
break;
|
||||
case '--nobuild' :
|
||||
console.log('Skipping build...');
|
||||
@ -48,13 +48,10 @@ module.exports.run = function(build_type) {
|
||||
default :
|
||||
return Q.reject('Build option \'' + build_type + '\' not recognized.');
|
||||
}
|
||||
if(cmd) {
|
||||
return clean.run() // TODO: Can we stop cleaning every time and let ant build incrementally?
|
||||
.then(function() {
|
||||
return exec(cmd);
|
||||
});
|
||||
}
|
||||
return Q();
|
||||
return clean.run() // TODO: Can we stop cleaning every time and let ant build incrementally?
|
||||
.then(function() {
|
||||
return spawn('ant', args);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
|
6
bin/templates/cordova/lib/clean.js
vendored
6
bin/templates/cordova/lib/clean.js
vendored
@ -19,16 +19,16 @@
|
||||
under the License.
|
||||
*/
|
||||
|
||||
var exec = require('./exec'),
|
||||
var spawn = require('./spawn'),
|
||||
path = require('path'),
|
||||
ROOT = path.join(__dirname, '..', '..');
|
||||
ROOT = path.join(__dirname, '..', '..');
|
||||
|
||||
/*
|
||||
* Cleans the project using ant
|
||||
* Returns a promise.
|
||||
*/
|
||||
module.exports.run = function() {
|
||||
return exec('ant clean -f "' + path.join(ROOT, 'build.xml') + '"');
|
||||
return spawn('ant', ['clean', '-f', path.join(ROOT, 'build.xml')]);
|
||||
}
|
||||
|
||||
module.exports.help = function() {
|
||||
|
43
bin/templates/cordova/lib/spawn.js
vendored
Normal file
43
bin/templates/cordova/lib/spawn.js
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/*
|
||||
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 child_process = require('child_process'),
|
||||
Q = require('q');
|
||||
|
||||
// Takes a command and optional current working directory.
|
||||
module.exports = function(cmd, args, opt_cwd) {
|
||||
var d = Q.defer();
|
||||
try {
|
||||
var child = child_process.spawn(cmd, args, {cwd: opt_cwd, stdio: 'inherit'});
|
||||
child.on('exit', function(code) {
|
||||
if (code) {
|
||||
d.reject('Error code ' + code + ' for command: ' + cmd + ' with args: ' + args);
|
||||
} else {
|
||||
d.resolve();
|
||||
}
|
||||
});
|
||||
} catch(e) {
|
||||
console.error('error caught: ' + e);
|
||||
d.reject(e);
|
||||
}
|
||||
return d.promise;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user