Merge branch 'master' into 4.0.x (x86 deploy)

This commit is contained in:
Andrew Grieve 2014-09-15 14:24:45 -04:00
commit a10106c61a
3 changed files with 31 additions and 14 deletions

View File

@ -26,6 +26,7 @@ var shell = require('shelljs'),
fs = require('fs'),
ROOT = path.join(__dirname, '..', '..');
var check_reqs = require('./check_reqs');
var exec = require('./exec');
var LOCAL_PROPERTIES_TEMPLATE =
'# This file is automatically generated.\n' +
@ -337,6 +338,20 @@ module.exports.run = function(options) {
});
};
/*
* Detects the architecture of a device/emulator
* Returns "arm" or "x86".
*/
module.exports.detectArchitecture = function(target) {
return exec('adb -s ' + target + ' shell cat /proc/cpuinfo')
.then(function(output) {
if (/intel/i.exec(output)) {
return 'x86';
}
return 'arm';
});
};
/*
* Gets the path to the apk file, if not such file exists then
* the script will error out. (should we error or just return undefined?)

View File

@ -58,19 +58,18 @@ module.exports.install = function(target) {
// default device
target = typeof target !== 'undefined' ? target : device_list[0];
if (device_list.indexOf(target) < 0)
if (device_list.indexOf(target) < 0) {
return Q.reject('ERROR: Unable to find target \'' + target + '\'.');
var apk_path;
if (typeof process.env.DEPLOY_APK_ARCH == 'undefined') {
apk_path = build.get_apk();
} else {
apk_path = build.get_apk(null, process.env.DEPLOY_APK_ARCH);
}
launchName = appinfo.getActivityName();
console.log('Installing app on device...');
var cmd = 'adb -s ' + target + ' install -r "' + apk_path + '"';
return exec(cmd);
return build.detectArchitecture(target)
.then(function(arch) {
var apk_path = build.get_apk(null, arch);
launchName = appinfo.getActivityName();
console.log('Installing app on device...');
var cmd = 'adb -s ' + target + ' install -r "' + apk_path + '"';
return exec(cmd);
});
}).then(function(output) {
if (output.match(/Failure/)) return Q.reject('ERROR: Failed to install apk to device: ' + output);

View File

@ -293,9 +293,12 @@ module.exports.install = function(target) {
return Q.reject('Unable to find target \'' + target + '\'. Failed to deploy to emulator.');
}
console.log('Installing app on emulator...');
var apk_path = build.get_apk();
return exec('adb -s ' + target + ' install -r "' + apk_path + '"');
return build.detectArchitecture(target)
.then(function(arch) {
var apk_path = build.get_apk(null, arch);
console.log('Installing app on emulator...');
return exec('adb -s ' + target + ' install -r "' + apk_path + '"');
});
}).then(function(output) {
if (output.match(/Failure/)) {
return Q.reject('Failed to install apk to emulator: ' + output);