From 4725fa3b70a31161f4a99d84e6887b7e81687408 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 6 Jun 2019 04:35:00 +0000 Subject: [PATCH] Bug 1551639 - Don't build generated source files during the export tier. 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 --- python/mozbuild/mozbuild/backend/common.py | 5 +++-- .../mozbuild/backend/recursivemake.py | 20 +++++++++++-------- python/mozbuild/mozbuild/backend/tup.py | 2 +- python/mozbuild/mozbuild/frontend/data.py | 11 +++++----- .../backend/data/generated-files/moz.build | 4 ++-- .../test/backend/test_recursivemake.py | 17 +++++++--------- 6 files changed, 31 insertions(+), 28 deletions(-) diff --git a/python/mozbuild/mozbuild/backend/common.py b/python/mozbuild/mozbuild/backend/common.py index 637fc7431a566..fa2d627087f87 100644 --- a/python/mozbuild/mozbuild/backend/common.py +++ b/python/mozbuild/mozbuild/backend/common.py @@ -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 diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index 82cb5fdb8b071..c550f36e63a1e 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -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. @@ -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)) diff --git a/python/mozbuild/mozbuild/backend/tup.py b/python/mozbuild/mozbuild/backend/tup.py index 8541689b5f3b1..db97e1ced05d4 100644 --- a/python/mozbuild/mozbuild/backend/tup.py +++ b/python/mozbuild/mozbuild/backend/tup.py @@ -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 = [] diff --git a/python/mozbuild/mozbuild/frontend/data.py b/python/mozbuild/mozbuild/frontend/data.py index 9e166ff8478a2..b461ba703cc2d 100644 --- a/python/mozbuild/mozbuild/frontend/data.py +++ b/python/mozbuild/mozbuild/frontend/data.py @@ -1178,7 +1178,8 @@ class GeneratedFile(ContextDerived): 'outputs', 'inputs', 'flags', - 'required_for_compile', + 'required_before_compile', + 'required_during_compile', 'localized', 'force', ) @@ -1195,9 +1196,6 @@ def __init__(self, context, script, method, outputs, inputs, self.force = force suffixes = ( - '.asm', - '.c', - '.cpp', '.h', '.inc', '.py', @@ -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.""" diff --git a/python/mozbuild/mozbuild/test/backend/data/generated-files/moz.build b/python/mozbuild/mozbuild/test/backend/data/generated-files/moz.build index 1fa389f51843c..69cb3406907bb 100644 --- a/python/mozbuild/mozbuild/test/backend/data/generated-files/moz.build +++ b/python/mozbuild/mozbuild/test/backend/data/generated-files/moz.build @@ -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'] diff --git a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py index 5c18a78702000..a6cc5ece81553 100644 --- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py +++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py @@ -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', @@ -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) $@', '', ] @@ -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', @@ -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',