Bug 1355625 - Part 3: Tweak the Gradle build to agree more with moz.build. r=sebastian draft
authorNick Alexander <nalexander@mozilla.com>
Mon, 19 Jun 2017 15:26:22 -0700
changeset 596954 e44f8664860f841b0cfd151f23f123344a348d49
parent 596953 b672ed502ce23edbec2ae89b2310590c047feaca
child 634093 ff443a625a997d471b93bd1bb3f43420a8fe1c16
push id64783
push usernalexander@mozilla.com
push dateMon, 19 Jun 2017 22:44:01 +0000
reviewerssebastian
bugs1355625
milestone56.0a1
Bug 1355625 - Part 3: Tweak the Gradle build to agree more with moz.build. r=sebastian MozReview-Commit-ID: DMoxPnla3Ij
mobile/android/app/build.gradle
mobile/android/thirdparty/build.gradle
settings.gradle
--- a/mobile/android/app/build.gradle
+++ b/mobile/android/app/build.gradle
@@ -143,16 +143,22 @@ android {
                 srcDir "${topsrcdir}/mobile/android/base/aidl"
             }
 
             java {
                 srcDir "${topsrcdir}/mobile/android/base/java"
                 srcDir "${topsrcdir}/mobile/android/search/java"
                 srcDir "${topsrcdir}/mobile/android/services/src/main/java"
 
+                // These aren't included in moz.build builds, for reasons unknown.
+                exclude "org/mozilla/gecko/dlc/CleanupAction.java"
+                // This is a marker file for linting.  We can probably find
+                // other ways to achieve this once we're Gradle-only.
+                exclude "org/mozilla/gecko/util/UnusedResourcesUtil.java"
+
                 if (mozconfig.substs.MOZ_ANDROID_MLS_STUMBLER) {
                     srcDir "${topsrcdir}/mobile/android/stumbler/java"
                 }
 
                 if (!mozconfig.substs.MOZ_CRASHREPORTER) {
                     exclude 'org/mozilla/gecko/CrashReporter.java'
                 }
 
@@ -160,16 +166,17 @@ android {
                     exclude 'org/mozilla/gecko/ChromeCastDisplay.java'
                     exclude 'org/mozilla/gecko/ChromeCastPlayer.java'
                     exclude 'org/mozilla/gecko/GeckoMediaPlayer.java'
                     exclude 'org/mozilla/gecko/GeckoPresentationDisplay.java'
                     exclude 'org/mozilla/gecko/MediaPlayerManager.java'
                 }
 
                 if (mozconfig.substs.MOZ_WEBRTC) {
+                    srcDir "${topsrcdir}/media/webrtc/trunk/webrtc/base/java/src"
                     srcDir "${topsrcdir}/media/webrtc/trunk/webrtc/modules/audio_device/android/java/src"
                     srcDir "${topsrcdir}/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src"
                     srcDir "${topsrcdir}/media/webrtc/trunk/webrtc/modules/video_render/android/java/src"
                 }
 
                 if (mozconfig.substs.MOZ_INSTALL_TRACKING) {
                     exclude 'org/mozilla/gecko/adjust/StubAdjustHelper.java'
                 } else {
@@ -550,8 +557,18 @@ android.applicationVariants.all { varian
                         .each { it.replaceNode {} }
 
                     manifestOutFile.write(XmlUtil.serialize(xml), 'UTF-8')
                 }
             })
         }
     }
 }
+
+// Bug 1355625: strip extra .class files from Gradle builds; modified from
+// http://stackoverflow.com/a/40705699.
+android.applicationVariants.all { variant ->
+    variant.javaCompile.doLast {
+        delete fileTree(dir: "${project.buildDir}", include: '**/org/mozilla/gecko/BuildConfig.class')
+        delete fileTree(dir: "${project.buildDir}", include: '**/org/mozilla/gecko/Manifest.class')
+        delete fileTree(dir: "${project.buildDir}", include: '**/org/mozilla/gecko/Manifest$permission.class')
+    }
+}
--- a/mobile/android/thirdparty/build.gradle
+++ b/mobile/android/thirdparty/build.gradle
@@ -64,8 +64,16 @@ idea {
             excludeDirs += file('com/leanplum')
         }
     }
 }
 
 // Bug 1353055 - Strip 'vars' debugging information to agree with moz.build.
 apply from: "${topsrcdir}/mobile/android/gradle/debug_level.gradle"
 android.libraryVariants.all configureVariantDebugLevel
+
+// Bug 1355625: strip extra .class files from Gradle builds; modified from
+// http://stackoverflow.com/a/40705699.
+android.libraryVariants.all { variant ->
+    variant.javaCompile.doLast {
+        delete fileTree(dir: "${project.buildDir}", include: "**/org/mozilla/gecko/thirdparty_unused/BuildConfig.class")
+    }
+}
--- a/settings.gradle
+++ b/settings.gradle
@@ -48,8 +48,14 @@ if (json.substs.MOZ_ANDROID_PACKAGE_INST
 // The Gradle instance is shared between settings.gradle and all the
 // other build.gradle files (see
 // http://forums.gradle.org/gradle/topics/define_extension_properties_from_settings_xml).
 // We use this ext property to pass the per-object-directory mozconfig
 // between scripts.  This lets us execute set-up code before we gradle
 // tries to configure the project even once, and as a side benefit
 // saves invoking |mach environment| multiple times.
 gradle.ext.mozconfig = json
+
+if (!gradle.ext.mozconfig.substs.COMPILE_ENVIRONMENT) {
+    // These should really come from the included binaries, but that's not easy.
+    gradle.ext.mozconfig.substs.TARGET_XPCOM_ABI = 'arm-eabi-gcc3'
+}
+gradle.ext.mozconfig.substs.MOZ_APP_ABI = gradle.ext.mozconfig.substs.TARGET_XPCOM_ABI