Bug 1543982 - Part 1: Avoid re-configuring from within Gradle. r=emilio

The inline comment explains what is happening here.  The issue is that
client.mk is setting MOZ_OBJDIR (and autoconf.mk is setting CC/CXX and
others) as part of `mach build`, which means that recursively invoking
`mach build` sees a different environment, and that triggers
reconfigure.

In some situations we can avoid this by recognizing that the
environment has changed and setting it back to what it was at the time
of `mach build` before client.mk adjusts it.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nick Alexander 2019-05-09 20:38:48 +00:00
Родитель c14acdeadd
Коммит e68b7c0a8f
2 изменённых файлов: 24 добавлений и 3 удалений

Просмотреть файл

@ -138,7 +138,19 @@ ext.geckoBinariesOnlyIf = { task ->
return true
}
task machBuildGeneratedAndroidCodeAndResources(type: Exec) {
class MachExec extends Exec {
def MachExec() {
// Bug 1543982: When invoking `mach build` recursively, the outer `mach
// build` itself modifies the environment, causing configure to run
// again. This tries to restore the environment that the outer `mach
// build` was invoked in. See the comment in
// $topsrcdir/settings.gradle.
project.ext.mozconfig.mozconfig.env.unmodified.each { k, v -> environment.remove(k) }
environment project.ext.mozconfig.orig_mozconfig.env.unmodified
}
}
task machBuildGeneratedAndroidCodeAndResources(type: MachExec) {
onlyIf rootProject.ext.geckoBinariesOnlyIf
workingDir "${topsrcdir}"
@ -164,7 +176,7 @@ task machBuildGeneratedAndroidCodeAndResources(type: Exec) {
// generation/native code compilation. So we have the special target for
// Android-specific generated code, and the |mach build faster| target for all
// the stuff that goes into the omnijar.
task machBuildFaster(type: Exec) {
task machBuildFaster(type: MachExec) {
onlyIf rootProject.ext.geckoBinariesOnlyIf
workingDir "${topsrcdir}"
@ -185,7 +197,7 @@ task machBuildFaster(type: Exec) {
}
def createMachStagePackageTask(name) {
return task(name, type: Exec) {
return task(name, type: MachExec) {
onlyIf rootProject.ext.geckoBinariesOnlyIf
dependsOn rootProject.machBuildFaster

Просмотреть файл

@ -61,3 +61,12 @@ project(':thirdparty').projectDir = new File("${json.topsrcdir}/mobile/android/t
// tries to configure the project even once, and as a side benefit
// saves invoking |mach environment| multiple times.
gradle.ext.mozconfig = json
// Produced by `mach build`. Bug 1543982: the mozconfig determined by `mach
// environment` above can be different because `mach build` itself sets certain
// critical environment variables including MOZ_OBJDIR, CC, and CXX. We use
// this record to patch up the environment when we recursively invoke `mach
// build ...` commands from within Gradle. This avoids invalidating configure
// based on the changed environment variables.
def orig = slurper.parse(new File(json.topobjdir, '.mozconfig.json'))
gradle.ext.mozconfig.orig_mozconfig = orig.mozconfig