Bug 1684584: move call to `_check_clobber` to `mach build` instead of running in `_run_client_mk` r=firefox-build-system-reviewers,mhentges

The `AUTOCLOBBER` mozconfig option is reliably causing builds to fail when
a clobber is triggered. When we auto-clobber a build we do so after running
`configure` but before running `make client.mk`. This means we destroy all
the gathered information from the `configure` step in the objdir and then
attempt to run `make` using the previously destroyed information.

This commit moves the call to `_check_clobber` to an earlier stage in the
build process, before `configure` is called, so any clobber that takes place
will happen before setting up the objdir via `configure`.

Since `_check_clobber` is only called once in the codebase, and both cases
are now adding clobber metrics one after another, we remove the metrics
gathering from `_check_clobber` and rely on callers to set metrics instead.

Also clean up some nested `if` statements that can be flattened.

Differential Revision: https://phabricator.services.mozilla.com/D100794
This commit is contained in:
Connor Sheehan 2021-01-06 17:19:34 +00:00
Родитель 3d9fb0766a
Коммит 1266f6cfb7
1 изменённых файлов: 14 добавлений и 17 удалений

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

@ -1100,6 +1100,9 @@ class BuildDriver(MozbuildObject):
monitor.start_resource_recording()
if self._check_clobber(self.mozconfig, os.environ):
return 1
self.mach_context.command_attrs["clobber"] = False
self.metrics.mozbuild.clobber.set(False)
config = None
@ -1632,9 +1635,6 @@ class BuildDriver(MozbuildObject):
mozconfig = self.mozconfig
if self._check_clobber(mozconfig, os.environ):
return 1
mozconfig_make_lines = []
for arg in mozconfig["make_extra"] or []:
mozconfig_make_lines.append(arg)
@ -1715,8 +1715,8 @@ class BuildDriver(MozbuildObject):
def _check_clobber(self, mozconfig, env):
"""Run `Clobberer.maybe_do_clobber`, log the result and return a status bool.
Wraps the clobbering logic in `Clobberer.maybe_do_clobber` to provide logging,
handling of the `AUTOCLOBBER` mozconfig option and metrics gathering.
Wraps the clobbering logic in `Clobberer.maybe_do_clobber` to provide logging
and handling of the `AUTOCLOBBER` mozconfig option.
Return a bool indicating whether the clobber reached an error state. For example,
return `True` if the clobber was required but not completed, and return `False` if
@ -1745,20 +1745,17 @@ class BuildDriver(MozbuildObject):
self.log(logging.WARNING, "clobber", {"msg": line.rstrip()}, "{msg}")
clobber_required, clobber_performed, clobber_message = res
if self.mach_context is not None and clobber_performed:
self.mach_context.command_attrs["clobber"] = True
self.metrics.mozbuild.clobber.set(True)
if not clobber_required or clobber_performed:
if clobber_performed and env.get("TINDERBOX_OUTPUT"):
self.log(
logging.WARNING,
"clobber",
{"msg": "TinderboxPrint: auto clobber"},
"{msg}",
)
else:
if clobber_required and not clobber_performed:
for line in clobber_message.splitlines():
self.log(logging.WARNING, "clobber", {"msg": line.rstrip()}, "{msg}")
return True
if clobber_performed and env.get("TINDERBOX_OUTPUT"):
self.log(
logging.WARNING,
"clobber",
{"msg": "TinderboxPrint: auto clobber"},
"{msg}",
)
return False