cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [6/7] android commit: CB-8255 Pass `arch` to gradle regardless of `cdvBuildMultipleApks`
Date Tue, 20 Jan 2015 03:02:53 GMT
CB-8255 Pass `arch` to gradle regardless of `cdvBuildMultipleApks`

This also pushes the "which target to build" logic into gradle, since
build.js doesn't actually know the value of `cdvBuildMultipleApks`.


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/893c0e9b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/893c0e9b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/893c0e9b

Branch: refs/heads/master
Commit: 893c0e9b6701762596d7bb1305af99070a0c12af
Parents: af60f71
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Mon Jan 19 21:56:46 2015 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Jan 19 21:56:46 2015 -0500

----------------------------------------------------------------------
 bin/templates/cordova/lib/build.js | 23 ++++++++---------------
 bin/templates/project/build.gradle | 24 ++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/893c0e9b/bin/templates/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js
index f2d60ae..e441caa 100644
--- a/bin/templates/cordova/lib/build.js
+++ b/bin/templates/cordova/lib/build.js
@@ -177,20 +177,16 @@ var builders = {
     },
     gradle: {
         getArgs: function(cmd, arch, extraArgs) {
-            if (arch == 'arm' && cmd == 'debug') {
-                cmd = 'assembleArmv7Debug';
-            } else if (arch == 'arm' && cmd == 'release') {
-                cmd = 'assembleArmv7Release';
-            } else if (arch == 'x86' && cmd == 'debug') {
-                cmd = 'assembleX86Debug';
-            } else if (arch == 'x86' && cmd == 'release') {
-                cmd = 'assembleX86Release';
+            if (cmd == 'release') {
+                cmd = 'cdvBuildRelease';
             } else if (cmd == 'debug') {
-                cmd = 'assembleDebug';
-            } else if (cmd == 'release') {
-                cmd = 'assembleRelease';
+                cmd = 'cdvBuildDebug';
             }
             var args = [cmd, '-b', path.join(ROOT, 'build.gradle')];
+            if (arch) {
+                args.push('-PcdvBuildArch=' + arch);
+            }
+
             // 10 seconds -> 6 seconds
             args.push('-Dorg.gradle.daemon=true');
             args.push.apply(args, extraArgs);
@@ -361,10 +357,7 @@ function parseOpts(options, resolvedTarget) {
         }
     }
 
-    var multiApk = ret.buildMethod == 'gradle' && process.env['BUILD_MULTIPLE_APKS'];
-    if (multiApk && !/0|false|no/i.exec(multiApk)) {
-        ret.arch = resolvedTarget && resolvedTarget.arch;
-    }
+    ret.arch = resolvedTarget && resolvedTarget.arch;
 
     return ret;
 }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/893c0e9b/bin/templates/project/build.gradle
----------------------------------------------------------------------
diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle
index adbee75..9b7f8dc 100644
--- a/bin/templates/project/build.gradle
+++ b/bin/templates/project/build.gradle
@@ -86,6 +86,10 @@ ext {
     if (!project.hasProperty('cdvDebugSigningPropertiesFile')) {
         cdvDebugSigningPropertiesFile = null
     }
+    // Set by build.js script.
+    if (!project.hasProperty('cdvBuildArch')) {
+        cdvBuildArch = null
+    }
 }
 
 def hasBuildExtras = file('build-extras.gradle').exists()
@@ -93,6 +97,26 @@ if (hasBuildExtras) {
     apply from: 'build-extras.gradle'
 }
 
+def computeBuildTargetName(debugBuild) {
+    def ret = 'assemble'
+    if (cdvBuildMultipleApks && cdvBuildArch) {
+        def arch = cdvBuildArch == 'arm' ? 'armv7' : cdvBuildArch
+        ret += '' + arch.toUpperCase().charAt(0) + arch.substring(1);
+    }
+    return ret + (debugBuild ? 'Debug' : 'Release')
+}
+
+// Make cdvBuild a task that depends on the debug/arch-sepecific task.
+task cdvBuildDebug
+cdvBuildDebug.dependsOn {
+    return computeBuildTargetName(true)
+}
+
+task cdvBuildRelease
+cdvBuildRelease.dependsOn {
+    return computeBuildTargetName(false)
+}
+
 // PLUGIN GRADLE EXTENSIONS START
 // PLUGIN GRADLE EXTENSIONS END
 


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


Mime
View raw message