cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject [20/29] git commit: CB-7554 Use x86 apk when deploying to an intel device / emulator
Date Thu, 02 Oct 2014 18:17:54 GMT
CB-7554 Use x86 apk when deploying to an intel device / emulator


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/f9e64473
Tree: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/tree/f9e64473
Diff: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/diff/f9e64473

Branch: refs/heads/master
Commit: f9e6447358920ec3a766fc5e684d8b2e51099817
Parents: 9062a78
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Mon Sep 15 14:23:26 2014 -0400
Committer: Prabhjot Singh <prabhjos@amazon.com>
Committed: Wed Sep 17 19:20:07 2014 +0530

----------------------------------------------------------------------
 bin/templates/cordova/lib/build.js    | 15 +++++++++++++++
 bin/templates/cordova/lib/device.js   | 21 ++++++++++-----------
 bin/templates/cordova/lib/emulator.js |  9 ++++++---
 3 files changed, 31 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/f9e64473/bin/templates/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js
index 30056f4..df2448c 100644
--- a/bin/templates/cordova/lib/build.js
+++ b/bin/templates/cordova/lib/build.js
@@ -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' +
@@ -338,6 +339,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?)
  * This is called by the run script to install the apk to the device

http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/f9e64473/bin/templates/cordova/lib/device.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/device.js b/bin/templates/cordova/lib/device.js
index df21287..671f93d 100644
--- a/bin/templates/cordova/lib/device.js
+++ b/bin/templates/cordova/lib/device.js
@@ -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);
 

http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/f9e64473/bin/templates/cordova/lib/emulator.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/emulator.js b/bin/templates/cordova/lib/emulator.js
index 0b9747d..88b35f7 100644
--- a/bin/templates/cordova/lib/emulator.js
+++ b/bin/templates/cordova/lib/emulator.js
@@ -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);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message