Bug 1498031 - Merge code paths for running configure between Tup and Make based backends. r=firefox-build-system-reviewers,mshal

This addresses a related issue along the way: a build that results in running
configure would not update the value of self.config_environment (and therefore
self.substs) as seen from the build driver, so out of date values would have
been used.

The changes to Makefile.in and client.mk made exploit the assumption that by
he time anything in the Make build is running, config.status is up to date.
Users running "make" without the benefit of "mach" will need to manually run
configure when necessary in order to take this into account.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Chris Manchester 2018-10-16 22:21:36 +00:00
parent 21708e2918
commit d69003537d
4 changed files with 42 additions and 87 deletions

View File

@ -45,24 +45,13 @@ buildid.h: $(MDDEPDIR)/buildid.h.stub
endif
endif
ifdef JS_STANDALONE
configure_dir = $(topsrcdir)/js/src
else
configure_dir = $(topsrcdir)
endif
BUILD_BACKEND_FILES := $(addprefix backend.,$(addsuffix Backend,$(BUILD_BACKENDS)))
ifndef TEST_MOZBUILD
ifndef MOZ_PROFILE_USE
# We need to explicitly put BUILD_BACKEND_FILES here otherwise the rule in
# rules.mk doesn't run early enough.
$(TIERS) binaries:: CLOBBER $(configure_dir)/configure config.status $(BUILD_BACKEND_FILES)
ifdef MOZ_WIDGET_TOOLKIT
ifdef COMPILE_ENVIRONMENT
$(TIERS) binaries:: $(topsrcdir)/js/src/configure js/src/config.status
endif
endif
$(TIERS) binaries:: CLOBBER $(BUILD_BACKEND_FILES)
endif
endif
@ -76,15 +65,6 @@ CLOBBER: $(topsrcdir)/CLOBBER
@exit 1
endif
config.status: $(configure_dir)/configure $(configure_dir)/old-configure
js/src/config.status: $(topsrcdir)/js/src/configure $(topsrcdir)/js/src/old-configure
config.status js/src/config.status:
@echo 'STOP! $? has changed and needs to be run again.'
@echo 'Please rerun it.'
@echo 'To ignore this message, touch "$(CURDIR)/$@",'
@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.
@ -118,20 +98,9 @@ install_manifests += dist/bin
endif
install_manifest_depends = \
CLOBBER \
$(configure_dir)/configure \
config.status \
$(BUILD_BACKEND_FILES) \
$(NULL)
ifdef MOZ_WIDGET_TOOLKIT
ifdef COMPILE_ENVIRONMENT
install_manifest_depends += \
$(topsrcdir)/js/src/configure \
js/src/config.status \
$(NULL)
endif
endif
.PHONY: install-manifests
install-manifests: $(addprefix install-,$(install_manifests))

View File

@ -89,12 +89,6 @@ endif
####################################
# Configure
MAKEFILE = $(wildcard $(OBJDIR)/Makefile)
CONFIG_STATUS = $(wildcard $(OBJDIR)/config.status)
# Include deps for configure written by configure itself.
CONFIG_STATUS_DEPS := $(if $(wildcard $(OBJDIR)/config_status_deps.in),$(shell cat $(OBJDIR)/config_status_deps.in),)
$(CONFIGURES): %: %.in
@echo Generating $@
cp -f $< $@
@ -113,14 +107,7 @@ else
CONFIGURE = $(TOPSRCDIR)/configure
endif
configure-files: $(CONFIGURES)
configure-preqs = \
configure-files \
$(OBJDIR)/.mozconfig.json \
$(NULL)
configure:: $(configure-preqs)
configure:: $(CONFIGURES)
$(call BUILDSTATUS,TIERS configure)
$(call BUILDSTATUS,TIER_START configure)
@echo cd $(OBJDIR);
@ -131,23 +118,10 @@ configure:: $(configure-preqs)
@touch $(OBJDIR)/Makefile
$(call BUILDSTATUS,TIER_FINISH configure)
ifneq (,$(MAKEFILE))
$(OBJDIR)/Makefile: $(OBJDIR)/config.status
$(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
else
$(OBJDIR)/Makefile: $(CONFIG_STATUS_DEPS)
endif
@$(MAKE) -f $(TOPSRCDIR)/client.mk configure
####################################
# Build it
build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
build::
+$(MOZ_MAKE)
ifdef MOZ_AUTOMATION

View File

@ -317,6 +317,13 @@ class MozbuildObject(ProcessExecutionMixin):
return get_repository_object(self.topsrcdir)
def reload_config_environment(self):
'''Force config.status to be re-read and return the new value
of ``self.config_environment``.
'''
self._config_environment = None
return self.config_environment
def mozbuild_reader(self, config_mode='build', vcs_revision=None,
vcs_check_clean=True):
"""Obtain a ``BuildReader`` for evaluating moz.build files.

View File

@ -1039,37 +1039,45 @@ class BuildDriver(MozbuildObject):
except Exception:
pass
if config is None:
# Record whether a clobber was requested so we can print
# a special message later if the build fails.
clobber_requested = False
# Write out any changes to the current mozconfig in case
# they should invalidate configure.
self._write_mozconfig_json()
previous_backend = None
if config is not None:
previous_backend = config.substs.get('BUILD_BACKENDS', [None])[0]
config_rc = None
# Even if we have a config object, it may be out of date
# if something that influences its result has changed.
if config is None or build_out_of_date(mozpath.join(self.topobjdir,
'config.status'),
mozpath.join(self.topobjdir,
'config_status_deps.in')):
if previous_backend and 'Make' not in previous_backend:
clobber_requested = self._clobber_configure()
config_rc = self.configure(buildstatus_messages=True,
line_handler=output.on_line)
if config_rc != 0:
return config_rc
config = self.config_environment
config = self.reload_config_environment()
active_backend = config.substs.get('BUILD_BACKENDS', [None])[0]
status = None
active_backend = config.substs.get('BUILD_BACKENDS', [None])[0]
if active_backend and 'Make' not in active_backend:
# Record whether a clobber was requested so we can print
# a special message later if the build fails.
clobber_requested = False
# Write out any changes to the current mozconfig in case
# they should invalidate configure.
self._write_mozconfig_json()
# Even if we have a config object, it may be out of date
# if something that influences its result has changed.
if build_out_of_date(mozpath.join(self.topobjdir,
'config.status'),
mozpath.join(self.topobjdir,
'config_status_deps.in')):
clobber_requested = self._clobber_configure()
config_rc = self.configure(buildstatus_messages=True,
line_handler=output.on_line)
if config_rc != 0:
return config_rc
elif backend_out_of_date(mozpath.join(self.topobjdir,
'backend.%sBackend' %
active_backend)):
if 'Make' not in active_backend:
if (not config_rc and
backend_out_of_date(mozpath.join(self.topobjdir,
'backend.%sBackend' %
active_backend))):
print('Build configuration changed. Regenerating backend.')
args = [config.substs['PYTHON'],
mozpath.join(self.topobjdir, 'config.status')]
@ -1179,7 +1187,6 @@ class BuildDriver(MozbuildObject):
# Try to run the active build backend's post-build step, if possible.
try:
config = self.config_environment
active_backend = config.substs.get('BUILD_BACKENDS', [None])[0]
if active_backend:
backend_cls = get_backend_class(active_backend)(config)
@ -1456,8 +1463,6 @@ class BuildDriver(MozbuildObject):
with FileAvoidWrite(mozconfig_mk) as fh:
fh.write(b'\n'.join(mozconfig_filtered_lines))
self._write_mozconfig_json()
# Copy the original mozconfig to the objdir.
mozconfig_objdir = os.path.join(self.topobjdir, '.mozconfig')
if mozconfig['path']: