Bug 877308 - Change when build backend update check it performed; r=glandium

Before, we checked if config.status was stale in any entrant Makefile
(top level or child directory). This had undesirable side-effects for
partial tree builds, notably that if the build backend was out of date,
the current Makefile was invalidated.

With this patch, we only regenerate the build config automatically in
full/toplevel builds. If an outdated build config is detected on partial
tree builds, we error. The impact of this is mitigated by having mach
build automatically ensure the build config is current.

--HG--
extra : rebase_source : a3a2c1d2bf68d1c0727352ebd9bfb785654e45bf
This commit is contained in:
Gregory Szorc 2013-10-29 14:53:52 -07:00
parent ae43bcf0e2
commit 0fd2e15636
5 changed files with 59 additions and 46 deletions

View File

@ -60,6 +60,24 @@ config.status: $(topsrcdir)/configure
@echo "but your build might not succeed."
@exit 1
# Regenerate the build backend if it is out of date. We only have this rule in
# this main make file because having it in rules.mk and applied to partial tree
# builds resulted in a world of hurt. Gory details are in bug 877308.
#
# The mach build driver will ensure the backend is up to date for partial tree
# builds. This cleanly avoids most of the pain.
backend.RecursiveMakeBackend:
@echo "Build configuration changed. Regenerating backend."
./config.status
Makefile: backend.RecursiveMakeBackend
@$(TOUCH) $@
include backend.RecursiveMakeBackend.pp
default:: backend.RecursiveMakeBackend
ifndef LIBXUL_SDK
.PHONY: js-config-status
js-config-status:

View File

@ -380,14 +380,9 @@ endef
endif
endif
# Static directories are largely independent of our build system. But, they
# could share the same build mechanism (like moz.build files). We need to
# prevent leaking of our backend state to these independent build systems. This
# is why MOZBUILD_BACKEND_CHECKED isn't exported to make invocations for static
# directories.
define SUBMAKE # $(call SUBMAKE,target,directory,static)
+@$(UPDATE_TITLE)
+$(if $(3), MOZBUILD_BACKEND_CHECKED=,) $(MAKE) $(if $(2),-C $(2)) $(1)
+$(MAKE) $(if $(2),-C $(2)) $(1)
endef # The extra line is important here! don't delete it
@ -590,25 +585,14 @@ HOST_OUTOPTION = -o # eol
endif
################################################################################
# Regenerate the build backend if it is out of date. We only check this once
# per traversal, hence the ifdef and the export. This rule needs to come before
# other rules for the default target or else it may not run in time.
# Ensure the build config is up to date. This is done automatically when builds
# are performed through |mach build|. The check here is to catch people not
# using mach. If we ever enforce builds through mach, this code can be removed.
ifndef MOZBUILD_BACKEND_CHECKED
# Since Makefile is listed as a global dependency, this has the
# unfortunate side-effect of invalidating all targets if it is executed.
# So e.g. if you are in /dom/bindings and /foo/moz.build changes,
# /dom/bindings will get invalidated. The upside is if the current
# Makefile/backend.mk is updated as a result of backend regeneration, we
# actually pick up the changes. This should reduce the amount of
# required clobbers and is thus the lesser evil.
Makefile: $(DEPTH)/backend.RecursiveMakeBackend
@$(TOUCH) $@
ifndef MACH
ifndef TOPLEVEL_BUILD
$(DEPTH)/backend.RecursiveMakeBackend:
@echo "Build configuration changed. Regenerating backend."
@cd $(DEPTH) && $(PYTHON) ./config.status
@$(TOUCH) $@
$(error Build configuration changed. Build with |mach build| or run |mach build-backend| to regenerate build config)
include $(DEPTH)/backend.RecursiveMakeBackend.pp
@ -616,6 +600,8 @@ default:: $(DEPTH)/backend.RecursiveMakeBackend
export MOZBUILD_BACKEND_CHECKED=1
endif
endif
endif
# The root makefile doesn't want to do a plain export/libs, because
# of the tiers and because of libxul. Suppress the default rules in favor

View File

@ -380,14 +380,9 @@ endef
endif
endif
# Static directories are largely independent of our build system. But, they
# could share the same build mechanism (like moz.build files). We need to
# prevent leaking of our backend state to these independent build systems. This
# is why MOZBUILD_BACKEND_CHECKED isn't exported to make invocations for static
# directories.
define SUBMAKE # $(call SUBMAKE,target,directory,static)
+@$(UPDATE_TITLE)
+$(if $(3), MOZBUILD_BACKEND_CHECKED=,) $(MAKE) $(if $(2),-C $(2)) $(1)
+$(MAKE) $(if $(2),-C $(2)) $(1)
endef # The extra line is important here! don't delete it
@ -590,25 +585,14 @@ HOST_OUTOPTION = -o # eol
endif
################################################################################
# Regenerate the build backend if it is out of date. We only check this once
# per traversal, hence the ifdef and the export. This rule needs to come before
# other rules for the default target or else it may not run in time.
# Ensure the build config is up to date. This is done automatically when builds
# are performed through |mach build|. The check here is to catch people not
# using mach. If we ever enforce builds through mach, this code can be removed.
ifndef MOZBUILD_BACKEND_CHECKED
# Since Makefile is listed as a global dependency, this has the
# unfortunate side-effect of invalidating all targets if it is executed.
# So e.g. if you are in /dom/bindings and /foo/moz.build changes,
# /dom/bindings will get invalidated. The upside is if the current
# Makefile/backend.mk is updated as a result of backend regeneration, we
# actually pick up the changes. This should reduce the amount of
# required clobbers and is thus the lesser evil.
Makefile: $(DEPTH)/backend.RecursiveMakeBackend
@$(TOUCH) $@
ifndef MACH
ifndef TOPLEVEL_BUILD
$(DEPTH)/backend.RecursiveMakeBackend:
@echo "Build configuration changed. Regenerating backend."
@cd $(DEPTH) && $(PYTHON) ./config.status
@$(TOUCH) $@
$(error Build configuration changed. Build with |mach build| or run |mach build-backend| to regenerate build config)
include $(DEPTH)/backend.RecursiveMakeBackend.pp
@ -616,6 +600,8 @@ default:: $(DEPTH)/backend.RecursiveMakeBackend
export MOZBUILD_BACKEND_CHECKED=1
endif
endif
endif
# The root makefile doesn't want to do a plain export/libs, because
# of the tiers and because of libxul. Suppress the default rules in favor

View File

@ -735,6 +735,10 @@ class RecursiveMakeBackend(CommonBackend):
for path in inputs:
backend_deps.write('%s:\n' % path)
with open(self._backend_output_list_file, 'a'):
pass
os.utime(self._backend_output_list_file, None)
# Make the master test manifest files.
for flavor, t in self._test_manifests.items():
install_prefix, manifests = t

View File

@ -355,6 +355,16 @@ class Build(MachCommandBase):
'instead of {target_pairs}.')
target_pairs = new_pairs
# Ensure build backend is up to date. The alternative is to
# have rules in the invoked Makefile to rebuild the build
# backend. But that involves make reinvoking itself and there
# are undesired side-effects of this. See bug 877308 for a
# comprehensive history lesson.
self._run_make(directory=self.topobjdir,
target='backend.RecursiveMakeBackend',
force_pymake=pymake, line_handler=output.on_line,
log=False, print_directory=False)
# Build target pairs.
for make_dir, make_target in target_pairs:
# We don't display build status messages during partial
@ -493,6 +503,15 @@ class Build(MachCommandBase):
raise
@Command('build-backend', category='build',
description='Generate a backend used to build the tree.')
def build_backend(self):
# When we support multiple build backends (Tup, Visual Studio, etc),
# this command will be expanded to support choosing what to generate.
config_status = os.path.join(self.topobjdir, 'config.status')
return self._run_command_in_objdir(args=[config_status],
pass_thru=True, ensure_exit_code=False)
@CommandProvider
class Warnings(MachCommandBase):