Skip to content

Commit

Permalink
Bug 1417264 - Write .mozconfig.mk file from Python; r=nalexander
Browse files Browse the repository at this point in the history
The file is a filtered version of the make file that we previously
started generating for client.mk. Why there is special casing for
UPLOAD_EXTRA_FILES, I'm not sure. This smells fishy and is something
I'd like to take a look at once all code is ported out of client.mk.

The removal of the logic from client.mk meant that we could remove
a bunch of code from client.mk related to loading mozconfig files.
We can now simply include the auto-generated make file directly and
be done with it.

MozReview-Commit-ID: 4M5NElQA7iR
  • Loading branch information
indygreg committed Nov 14, 2017
1 parent 1e1a5f2 commit 76e0714
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 29 deletions.
29 changes: 0 additions & 29 deletions client.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,8 @@ PYTHON ?= $(shell which python2.7 > /dev/null 2>&1 && echo python2.7 || echo pyt
####################################
# Load mozconfig Options

# See build pages, http://www.mozilla.org/build/ for how to set up mozconfig.

define CR


endef

# As $(shell) doesn't preserve newlines, use sed to replace them with an
# unlikely sequence (||), which is then replaced back to newlines by make
# before evaluation. $(shell) replacing newlines with spaces, || is always
# followed by a space (since sed doesn't remove newlines), except on the
# last line, so replace both '|| ' and '||'.
MOZCONFIG_CONTENT := $(subst ||,$(CR),$(subst || ,$(CR),$(shell cat $(OBJDIR)/.mozconfig-client-mk | sed 's/$$/||/')))
include $(OBJDIR)/.mozconfig-client-mk

# As '||' was used as a newline separator, it means it's not occurring in
# lines themselves. It can thus safely be used to replaces normal spaces,
# to then replace newlines with normal spaces. This allows to get a list
# of mozconfig output lines.
MOZCONFIG_OUT_LINES := $(subst $(CR), ,$(subst $(NULL) $(NULL),||,$(MOZCONFIG_CONTENT)))

ifdef MOZ_PARALLEL_BUILD
MOZ_MAKE_FLAGS := $(filter-out -j%,$(MOZ_MAKE_FLAGS))
MOZ_MAKE_FLAGS += -j$(MOZ_PARALLEL_BUILD)
Expand Down Expand Up @@ -92,16 +73,6 @@ $(error client.mk must be used via `mach`. Try running \
`./mach $(firstword $(MAKECMDGOALS) $(.DEFAULT_GOAL))`)
endif

# For now, only output "export" lines and lines containing UPLOAD_EXTRA_FILES.
MOZCONFIG_MK_LINES := $(filter export||% UPLOAD_EXTRA_FILES% %UPLOAD_EXTRA_FILES%,$(MOZCONFIG_OUT_LINES))
$(OBJDIR)/.mozconfig.mk: $(TOPSRCDIR)/client.mk $(FOUND_MOZCONFIG)
$(if $(MOZCONFIG_MK_LINES),( $(foreach line,$(MOZCONFIG_MK_LINES), echo '$(subst ||, ,$(line))';) )) > $@

# Include that makefile so that it is created. This should not actually change
# the environment since MOZCONFIG_CONTENT, which MOZCONFIG_OUT_LINES derives
# from, has already been eval'ed.
include $(OBJDIR)/.mozconfig.mk

# In automation, manage an sccache daemon. The starting of the server
# needs to be in a make file so sccache inherits the jobserver.
ifdef MOZBUILD_MANAGE_SCCACHE_DAEMON
Expand Down
13 changes: 13 additions & 0 deletions python/mozbuild/mozbuild/controller/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -1353,11 +1353,24 @@ def _run_client_mk(self, target=None, line_handler=None, jobs=0,
mozpath.normsep(mozconfig['path']))
mozconfig_make_lines.append(b'export FOUND_MOZCONFIG')

# The .mozconfig.mk file only contains exported variables and lines with
# UPLOAD_EXTRA_FILES.
mozconfig_filtered_lines = [
line for line in mozconfig_make_lines
# Bug 1418122 investigate why UPLOAD_EXTRA_FILES is special and
# remove it.
if line.startswith(b'export ') or b'UPLOAD_EXTRA_FILES' in line
]

mozconfig_client_mk = os.path.join(self.topobjdir,
'.mozconfig-client-mk')
with FileAvoidWrite(mozconfig_client_mk) as fh:
fh.write(b'\n'.join(mozconfig_make_lines))

mozconfig_mk = os.path.join(self.topobjdir, '.mozconfig.mk')
with FileAvoidWrite(mozconfig_mk) as fh:
fh.write(b'\n'.join(mozconfig_filtered_lines))

if mozconfig_make_lines:
self.log(logging.WARNING, 'mozconfig_content', {
'path': mozconfig['path'],
Expand Down

0 comments on commit 76e0714

Please sign in to comment.