Bug 1543982 - Part 2: Don't invoke mach build ... recursively. r=emilio

This commit avoids moz.build tasks when we're already within `mach
build`.

This is belt-and-braces: from within `mach build`, we want the main
moz.build dependency graph to arrange for the Gradle invocations to be
in the right state.  It's only in other situations, like `mach android
...` or invocation from Android Studio, that we want Gradle to arrange
to be in the right state vis. moz.build.

Differential Revision: https://phabricator.services.mozilla.com/D30426

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nick Alexander 2019-05-09 20:39:10 +00:00
parent e68b7c0a8f
commit 1764740990
2 changed files with 12 additions and 1 deletions

View File

@ -107,6 +107,12 @@ class TaggedLogOutputStream extends org.apache.commons.exec.LogOutputStream {
} }
ext.geckoBinariesOnlyIf = { task -> ext.geckoBinariesOnlyIf = { task ->
// Never when Gradle was invoked within `mach build`.
if ('1' == System.env.GRADLE_INVOKED_WITHIN_MACH_BUILD) {
rootProject.logger.lifecycle("Skipping task ${task.path} because: within `mach build`")
return false
}
// Never for official builds. // Never for official builds.
if (mozconfig.substs.MOZILLA_OFFICIAL) { if (mozconfig.substs.MOZILLA_OFFICIAL) {
rootProject.logger.lifecycle("Skipping task ${task.path} because: MOZILLA_OFFICIAL") rootProject.logger.lifecycle("Skipping task ${task.path} because: MOZILLA_OFFICIAL")

View File

@ -5,6 +5,7 @@
from __future__ import print_function from __future__ import print_function
import buildconfig import buildconfig
import os
import subprocess import subprocess
import sys import sys
@ -30,7 +31,11 @@ def android(verb, *args):
verb, verb,
] ]
cmd.extend(args) cmd.extend(args)
subprocess.check_call(cmd) env = dict(os.environ)
# Confusingly, `MACH` is set only within `mach build`.
if env.get('MACH'):
env['GRADLE_INVOKED_WITHIN_MACH_BUILD'] = '1'
subprocess.check_call(cmd, env=env)
return 0 return 0
finally: finally: