Bug 1509573 - Part 3: Extract shared `onlyIf` Gradle guard. r=snorp
authorNick Alexander <nalexander@mozilla.com>
Wed, 28 Nov 2018 19:46:54 +0000
changeset 448644 059741f95cf4d4f680bea3eeadb714e567cd5413
parent 448643 36cf7b9ce095cca9ebc495fb44f23125c100efa7
child 448645 ace2d2ada8eff0cc3505f1d6cc1f81da2bcf9179
push id35121
push userdvarga@mozilla.com
push dateThu, 29 Nov 2018 09:53:54 +0000
treeherdermozilla-central@c302586458e0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1509573
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1509573 - Part 3: Extract shared `onlyIf` Gradle guard. r=snorp This will be used to make it very clear when certain tasks are being skipped, as we move details about Gecko binaries to depend on the Gradle task execution graph. Differential Revision: https://phabricator.services.mozilla.com/D12798
build.gradle
--- a/build.gradle
+++ b/build.gradle
@@ -74,47 +74,64 @@ class TaggedLogOutputStream extends org.
         this.logger = logger
     }
 
     void processLine(String line, int level) {
         logger.lifecycle("${this.tag} ${line}")
     }
 }
 
-if ('multi' == System.env.AB_CD) {
+ext.geckoBinariesOnlyIf = { task ->
+    // Never for official builds.
+    if (mozconfig.substs.MOZILLA_OFFICIAL) {
+        rootProject.logger.lifecycle("Skipping task ${task.path} because: MOZILLA_OFFICIAL")
+        return false
+    }
+
     // Multi-l10n builds set `AB_CD=multi`, which isn't a valid locale.  This
     // causes the
     //
     // |mach build| > |mach gradle| > AndroidManifest.xml > strings.xml > multi/brand.dtd
     //
     // dependency chain to fail, since multi isn't a real locale.  To avoid
     // this, if Gradle is invoked with AB_CD=multi, we don't invoke Make at all.
-    task machBuildFaster()
-} else if (System.env.IS_LANGUAGE_REPACK == '1') {
+    if ('multi' == System.env.AB_CD) {
+        rootProject.logger.lifecycle("Skipping task ${task.path} because: AB_CD=multi")
+        return false
+    }
+
     // Single-locale l10n repacks set `IS_LANGUAGE_REPACK=1` and handle resource
     // and code generation themselves.
-    task machBuildFaster()
-} else {
-    task machBuildFaster(type: Exec) {
-        workingDir "${topsrcdir}"
+    if ('1' == System.env.IS_LANGUAGE_REPACK) {
+        rootProject.logger.lifecycle("Skipping task ${task.path} because: IS_LANGUAGE_REPACK")
+        return false
+    }
 
-        commandLine mozconfig.substs.PYTHON
-        args "${topsrcdir}/mach"
-        args 'build'
-        args 'faster'
+    rootProject.logger.lifecycle("Executing task ${task.path}")
+    return true
+}
+
+task machBuildFaster(type: Exec) {
+    onlyIf rootProject.ext.geckoBinariesOnlyIf
+
+    workingDir "${topsrcdir}"
 
-        // Add `-v` if we're running under `--info` (or `--debug`).
-        if (project.logger.isEnabled(LogLevel.INFO)) {
-            args '-v'
-        }
+    commandLine mozconfig.substs.PYTHON
+    args "${topsrcdir}/mach"
+    args 'build'
+    args 'faster'
 
-        // `path` is like `:machBuildFaster`.
-        standardOutput = new TaggedLogOutputStream("${path}>", logger)
-        errorOutput = standardOutput
+    // Add `-v` if we're running under `--info` (or `--debug`).
+    if (project.logger.isEnabled(LogLevel.INFO)) {
+        args '-v'
     }
+
+    // `path` is like `:machBuildFaster`.
+    standardOutput = new TaggedLogOutputStream("${path}>", logger)
+    errorOutput = standardOutput
 }
 
 afterEvaluate {
     subprojects { project ->
         if (project.name != 'thirdparty') {
             tasks.withType(JavaCompile) {
                 // Add compiler args for all code except third-party code.
                 options.compilerArgs += [