Bug 1355625 - Part 3: Tweak the Gradle build to agree more with moz.build. r=sebastian
authorNick Alexander <nalexander@mozilla.com>
Tue, 09 May 2017 10:56:28 -0700
changeset 1118440 9928cde62142e65bca32a274997b9e7ee36bdce1
parent 1118439 abe0a492141040de73fcdb1d5dcfdc9a6f53fe00
child 1118441 3e0d0fdddc8b336556242574bf596fcfe1ddba82
push id188513
push usernalexander@mozilla.com
push dateTue, 09 May 2017 17:59:12 +0000
treeherdertry@33bb2f4cb03c [default view] [failures only]
reviewerssebastian
bugs1355625
milestone55.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
@@ -135,16 +135,23 @@ 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"
+                exclude "org/mozilla/gecko/tabs/TabsLayoutRecyclerAdapter.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'
                 }
 
@@ -152,16 +159,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 {
@@ -527,8 +535,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
@@ -51,8 +51,16 @@ idea {
             excludeDirs += file('com/adjust/sdk')
         }
     }
 }
 
 // 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.MOZ_APP_ABI = 'arm-eabi-gcc3'
+    gradle.ext.mozconfig.substs.TARGET_XPCOM_ABI = 'arm-eabi-gcc3'
+}