Bug 1417658 - Move export_suffixes into GeneratedFile; r=nalexander
I believe all backends will need to know which GeneratedFiles are needed
before compilation can start, so we should make that an attribute of the
object. Each backend can then make its own decision about what to do
with the different types of GeneratedFiles.
MozReview-Commit-ID: ByburRx540b
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -515,26 +515,17 @@ class RecursiveMakeBackend(CommonBackend
else:
backend_file.write('%s := %s\n' % (k, v))
elif isinstance(obj, HostDefines):
self._process_defines(obj, backend_file, which='HOST_DEFINES')
elif isinstance(obj, Defines):
self._process_defines(obj, backend_file)
elif isinstance(obj, GeneratedFile):
- export_suffixes = (
- '.c',
- '.cpp',
- '.h',
- '.inc',
- '.py',
- '.rs',
- 'new', # 'new' is an output from make-stl-wrappers.py
- )
- tier = 'export' if any(f.endswith(export_suffixes) for f in obj.outputs) else 'misc'
+ tier = 'export' if obj.required_for_compile else 'misc'
self._no_skip[tier].add(backend_file.relobjdir)
first_output = obj.outputs[0]
dep_file = "%s.pp" % first_output
# 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.
--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -328,21 +328,16 @@ class TupOnly(CommonBackend, PartialBack
def _process_generated_file(self, backend_file, obj):
# TODO: These are directories that don't work in the tup backend
# yet, because things they depend on aren't built yet.
skip_directories = (
'layout/style/test', # HostSimplePrograms
'toolkit/library', # libxul.so
)
- install_exts = (
- '.h',
- '.inc',
- 'new', # 'new' is an output from make-stl-wrappers.py
- )
if obj.script and obj.method and obj.relobjdir not in skip_directories:
backend_file.export_shell()
cmd = self._py_action('file_generate')
cmd.extend([
obj.script,
obj.method,
obj.outputs[0],
'%s.pp' % obj.outputs[0], # deps file required
@@ -350,17 +345,17 @@ class TupOnly(CommonBackend, PartialBack
full_inputs = [f.full_path for f in obj.inputs]
cmd.extend(full_inputs)
cmd.extend(shell_quote(f) for f in obj.flags)
outputs = []
outputs.extend(obj.outputs)
outputs.append('%s.pp' % obj.outputs[0])
- extra_outputs = [self._installed_files] if any(f.endswith(install_exts) for f in obj.outputs) else None
+ extra_outputs = [self._installed_files] if obj.required_for_compile else None
backend_file.rule(
display='python {script}:{method} -> [%o]'.format(script=obj.script, method=obj.method),
cmd=cmd,
inputs=full_inputs,
outputs=outputs,
extra_outputs=extra_outputs,
)
--- a/python/mozbuild/mozbuild/frontend/data.py
+++ b/python/mozbuild/mozbuild/frontend/data.py
@@ -1051,26 +1051,38 @@ class GeneratedFile(ContextDerived):
"""Represents a generated file."""
__slots__ = (
'script',
'method',
'outputs',
'inputs',
'flags',
+ 'required_for_compile',
)
def __init__(self, context, script, method, outputs, inputs, flags=()):
ContextDerived.__init__(self, context)
self.script = script
self.method = method
self.outputs = outputs if isinstance(outputs, tuple) else (outputs,)
self.inputs = inputs
self.flags = flags
+ suffixes = (
+ '.c',
+ '.cpp',
+ '.h',
+ '.inc',
+ '.py',
+ '.rs',
+ 'new', # 'new' is an output from make-stl-wrappers.py
+ )
+ self.required_for_compile = any(f.endswith(suffixes) for f in self.outputs)
+
class AndroidResDirs(ContextDerived):
"""Represents Android resource directories."""
__slots__ = (
'paths',
)