Bug 1417264 - Write .mozconfig.json from Python; r=nalexander

In order to determine if we need to re-run configure, we write
a JSON file representing the evaluated mozconfig. If this JSON
file changes, configure (and config.status for that matter) is
out of data and it is re-executed.

This commit moves the generation of that JSON file to Python.

MozReview-Commit-ID: 636rpSY7gOm

--HG--
extra : rebase_source : ee1defd74decfd64ffb66a45b053dada58de04fb
This commit is contained in:
Gregory Szorc 2017-11-13 17:45:03 -08:00
parent f269a93370
commit 214be74c6c
2 changed files with 9 additions and 10 deletions

View File

@ -141,15 +141,6 @@ configure-preqs = \
$(OBJDIR)/.mozconfig.json \
$(NULL)
CREATE_MOZCONFIG_JSON = $(shell $(TOPSRCDIR)/mach environment --format=json -o $(OBJDIR)/.mozconfig.json)
# Force CREATE_MOZCONFIG_JSON above to be resolved, without side effects in
# case the result is non empty, and allowing an override on the make command
# line not running the command (using := $(shell) still runs the shell command).
ifneq (,$(CREATE_MOZCONFIG_JSON))
endif
$(OBJDIR)/.mozconfig.json: ;
configure:: $(configure-preqs)
$(call BUILDSTATUS,TIERS configure)
$(call BUILDSTATUS,TIER_START configure)
@ -168,7 +159,7 @@ $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
else
$(OBJDIR)/Makefile: $(CONFIG_STATUS_DEPS)
endif
@$(MAKE) -f $(TOPSRCDIR)/client.mk configure CREATE_MOZCONFIG_JSON=
@$(MAKE) -f $(TOPSRCDIR)/client.mk configure
####################################
# Build it

View File

@ -1372,6 +1372,14 @@ class BuildDriver(MozbuildObject):
with FileAvoidWrite(mozconfig_mk) as fh:
fh.write(b'\n'.join(mozconfig_filtered_lines))
mozconfig_json = os.path.join(self.topobjdir, '.mozconfig.json')
with FileAvoidWrite(mozconfig_json) as fh:
json.dump({
'topsrcdir': self.topsrcdir,
'topobjdir': self.topobjdir,
'mozconfig': mozconfig,
}, fh, sort_keys=True, indent=2)
# Copy the original mozconfig to the objdir.
mozconfig_objdir = os.path.join(self.topobjdir, '.mozconfig')
if mozconfig['path']: