Skip to content

Commit

Permalink
Bug 1551639 - Don't build generated source files during the export ti…
Browse files Browse the repository at this point in the history
…er. r=nalexander

As established previously, generated source files that are not included
don't need to be built during the export tier.

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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
glandium committed Jun 6, 2019
1 parent 98317c4 commit 4725fa3
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
5 changes: 3 additions & 2 deletions python/mozbuild/mozbuild/backend/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ def consume_object(self, obj):
return False

elif isinstance(obj, GeneratedFile):
if obj.required_for_compile:
for f in obj.required_for_compile:
if obj.required_during_compile or obj.required_before_compile:
for f in itertools.chain(obj.required_before_compile,
obj.required_during_compile):
fullpath = ObjDirPath(obj._context, '!' + f).full_path
self._handle_generated_sources([fullpath])
return False
Expand Down
20 changes: 12 additions & 8 deletions python/mozbuild/mozbuild/backend/recursivemake.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,13 +515,16 @@ def consume_object(self, obj):
self._process_defines(obj, backend_file)

elif isinstance(obj, GeneratedFile):
if obj.required_for_compile:
if obj.required_before_compile:
tier = 'export'
elif obj.required_during_compile:
tier = None
elif obj.localized:
tier = 'libs'
else:
tier = 'misc'
self._no_skip[tier].add(backend_file.relobjdir)
if tier:
self._no_skip[tier].add(backend_file.relobjdir)

# Localized generated files can use {AB_CD} and {AB_rCD} in their
# output paths.
Expand Down Expand Up @@ -582,12 +585,13 @@ def srcpath(p):
force = ' $(if $(IS_LANGUAGE_REPACK),FORCE)'

if obj.script:
# If we're doing this during export that means we need it during
# compile, but if we have an artifact build we don't run compile,
# so we can skip it altogether or let the rule run as the result of
# something depending on it.
if tier != 'export' or not self.environment.is_artifact_build:
if not needs_AB_rCD:
# If we are doing an artifact build, we don't run compiler, so
# we can skip generated files that are needed during compile,
# or let the rule run as the result of something depending on
# it.
if not (obj.required_before_compile or obj.required_during_compile) or \
not self.environment.is_artifact_build:
if tier and not needs_AB_rCD:
# Android localized resources have special Makefile
# handling.
backend_file.write('%s:: %s\n' % (tier, stub_file))
Expand Down
2 changes: 1 addition & 1 deletion python/mozbuild/mozbuild/backend/tup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ def _process_generated_file(self, backend_file, obj):
for f in obj.outputs):
output_group = self._early_generated_files
else:
output_group = self._installed_files if obj.required_for_compile else None
output_group = self._installed_files if obj.required_during_compile else None
full_inputs += [self._early_generated_files]

extra_inputs = []
Expand Down
11 changes: 6 additions & 5 deletions python/mozbuild/mozbuild/frontend/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,8 @@ class GeneratedFile(ContextDerived):
'outputs',
'inputs',
'flags',
'required_for_compile',
'required_before_compile',
'required_during_compile',
'localized',
'force',
)
Expand All @@ -1195,9 +1196,6 @@ def __init__(self, context, script, method, outputs, inputs,
self.force = force

suffixes = (
'.asm',
'.c',
'.cpp',
'.h',
'.inc',
'.py',
Expand All @@ -1210,9 +1208,12 @@ def __init__(self, context, script, method, outputs, inputs,
'.profdata',
'.webidl'
)
self.required_for_compile = [
self.required_before_compile = [
f for f in self.outputs if f.endswith(suffixes) or 'stl_wrappers/' in f]

self.required_during_compile = [
f for f in self.outputs if f.endswith(('.asm', '.c', '.cpp'))]


class ChromeManifestEntry(ContextDerived):
"""Represents a chrome.manifest entry."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/

GENERATED_FILES += [ 'bar.c', 'foo.c', 'quux.c' ]
GENERATED_FILES += [ 'bar.c', 'foo.h', 'quux.c' ]

bar = GENERATED_FILES['bar.c']
bar.script = 'generate-bar.py:baz'

foo = GENERATED_FILES['foo.c']
foo = GENERATED_FILES['foo.h']
foo.script = 'generate-foo.py'
foo.inputs = ['foo-data']
17 changes: 7 additions & 10 deletions python/mozbuild/mozbuild/test/backend/test_recursivemake.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ def test_generated_files(self):
lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]

expected = [
'export:: $(MDDEPDIR)/bar.c.stub',
'bar.c: $(MDDEPDIR)/bar.c.stub ;',
'GARBAGE += bar.c',
'GARBAGE += $(MDDEPDIR)/bar.c.stub',
Expand All @@ -410,14 +409,14 @@ def test_generated_files(self):
'$(call py_action,file_generate,%s/generate-bar.py baz bar.c $(MDDEPDIR)/bar.c.pp $(MDDEPDIR)/bar.c.stub)' % env.topsrcdir, # noqa
'@$(TOUCH) $@',
'',
'export:: $(MDDEPDIR)/foo.c.stub',
'foo.c: $(MDDEPDIR)/foo.c.stub ;',
'GARBAGE += foo.c',
'GARBAGE += $(MDDEPDIR)/foo.c.stub',
'EXTRA_MDDEPEND_FILES += foo.c.pp',
'$(MDDEPDIR)/foo.c.stub: %s/generate-foo.py $(srcdir)/foo-data' % (env.topsrcdir),
'export:: $(MDDEPDIR)/foo.h.stub',
'foo.h: $(MDDEPDIR)/foo.h.stub ;',
'GARBAGE += foo.h',
'GARBAGE += $(MDDEPDIR)/foo.h.stub',
'EXTRA_MDDEPEND_FILES += foo.h.pp',
'$(MDDEPDIR)/foo.h.stub: %s/generate-foo.py $(srcdir)/foo-data' % (env.topsrcdir),
'$(REPORT_BUILD)',
'$(call py_action,file_generate,%s/generate-foo.py main foo.c $(MDDEPDIR)/foo.c.pp $(MDDEPDIR)/foo.c.stub $(srcdir)/foo-data)' % (env.topsrcdir), # noqa
'$(call py_action,file_generate,%s/generate-foo.py main foo.h $(MDDEPDIR)/foo.h.pp $(MDDEPDIR)/foo.h.stub $(srcdir)/foo-data)' % (env.topsrcdir), # noqa
'@$(TOUCH) $@',
'',
]
Expand All @@ -433,7 +432,6 @@ def test_generated_files_force(self):
lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]

expected = [
'export:: $(MDDEPDIR)/bar.c.stub',
'bar.c: $(MDDEPDIR)/bar.c.stub ;',
'GARBAGE += bar.c',
'GARBAGE += $(MDDEPDIR)/bar.c.stub',
Expand All @@ -443,7 +441,6 @@ def test_generated_files_force(self):
'$(call py_action,file_generate,%s/generate-bar.py baz bar.c $(MDDEPDIR)/bar.c.pp $(MDDEPDIR)/bar.c.stub)' % env.topsrcdir, # noqa
'@$(TOUCH) $@',
'',
'export:: $(MDDEPDIR)/foo.c.stub',
'foo.c: $(MDDEPDIR)/foo.c.stub ;',
'GARBAGE += foo.c',
'GARBAGE += $(MDDEPDIR)/foo.c.stub',
Expand Down

0 comments on commit 4725fa3

Please sign in to comment.