Bug 1215526 - part 1 - pass dependencies file to file_generate.py; r=glandium

In addition to their inputs declared in moz.build files, generated files
may also depend on other files, such as #includes in preprocessed files.
Let's provide a place for file_generate.py to write out those extra
dependencies.
This commit is contained in:
Nathan Froyd 2015-10-21 09:23:09 -04:00
parent 8167eb6d1d
commit d93013ebc9
3 changed files with 11 additions and 3 deletions

View File

@ -25,6 +25,8 @@ def main(argv):
help='The method of the script to invoke')
parser.add_argument('output_file', metavar='output-file', type=str,
help='The file to generate')
parser.add_argument('dep_file', metavar='dep-file', type=str,
help='File to write any additional make dependencies to')
parser.add_argument('additional_arguments', metavar='arg', nargs='*',
help="Additional arguments to the script's main() method")

View File

@ -505,13 +505,16 @@ class RecursiveMakeBackend(CommonBackend):
self._process_exports(obj, obj.exports, backend_file)
elif isinstance(obj, GeneratedFile):
dep_file = "%s.pp" % obj.output
backend_file.write('GENERATED_FILES += %s\n' % obj.output)
backend_file.write('EXTRA_MDDEPEND_FILES += %s\n' % dep_file)
if obj.script:
backend_file.write("""{output}: {script}{inputs}
\t$(REPORT_BUILD)
\t$(call py_action,file_generate,{script} {method} {output}{inputs})
\t$(call py_action,file_generate,{script} {method} {output} $(MDDEPDIR)/{dep_file}{inputs})
""".format(output=obj.output,
dep_file=dep_file,
inputs=' ' + ' '.join(obj.inputs) if obj.inputs else '',
script=obj.script,
method=obj.method))

View File

@ -384,16 +384,19 @@ class TestRecursiveMakeBackend(BackendTester):
expected = [
'GENERATED_FILES += bar.c',
'EXTRA_MDDEPEND_FILES += bar.c.pp',
'bar.c: %s/generate-bar.py' % env.topsrcdir,
'$(REPORT_BUILD)',
'$(call py_action,file_generate,%s/generate-bar.py baz bar.c)' % env.topsrcdir,
'$(call py_action,file_generate,%s/generate-bar.py baz bar.c $(MDDEPDIR)/bar.c.pp)' % env.topsrcdir,
'',
'GENERATED_FILES += foo.c',
'EXTRA_MDDEPEND_FILES += foo.c.pp',
'foo.c: %s/generate-foo.py %s/foo-data' % (env.topsrcdir, env.topsrcdir),
'$(REPORT_BUILD)',
'$(call py_action,file_generate,%s/generate-foo.py main foo.c %s/foo-data)' % (env.topsrcdir, env.topsrcdir),
'$(call py_action,file_generate,%s/generate-foo.py main foo.c $(MDDEPDIR)/foo.c.pp %s/foo-data)' % (env.topsrcdir, env.topsrcdir),
'',
'GENERATED_FILES += quux.c',
'EXTRA_MDDEPEND_FILES += quux.c.pp',
]
self.maxDiff = None