Bug 1256033 - Allow GENERATED_FILES scripts to depend on other generated files; r?glandium
If we add an ObjDirPath as an input to a GENERATED_FILES script, we
should run it in the misc tier to ensure the dependent files are created
beforehand. We need to use Path objects instead of raw filenames in the
GeneratedFile object so the recursive make backend can distinguish
between source and objdir files.
MozReview-Commit-ID: 9thHTi75zdI
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -501,29 +501,30 @@ 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):
- self._no_skip['export'].add(backend_file.relobjdir)
+ tier = 'misc' if any(isinstance(f, ObjDirPath) for f in obj.inputs) else 'export'
+ self._no_skip[tier].add(backend_file.relobjdir)
dep_file = "%s.pp" % obj.output
- backend_file.write('export:: %s\n' % obj.output)
+ backend_file.write('%s:: %s\n' % (tier, obj.output))
backend_file.write('GARBAGE += %s\n' % obj.output)
backend_file.write('EXTRA_MDDEPEND_FILES += %s\n' % dep_file)
if obj.script:
backend_file.write("""{output}: {script}{inputs}{backend}
\t$(REPORT_BUILD)
\t$(call py_action,file_generate,{script} {method} {output} $(MDDEPDIR)/{dep_file}{inputs}{flags})
""".format(output=obj.output,
dep_file=dep_file,
- inputs=' ' + ' '.join(obj.inputs) if obj.inputs else '',
+ inputs=' ' + ' '.join([f.full_path for f in obj.inputs]) if obj.inputs else '',
flags=' ' + ' '.join(obj.flags) if obj.flags else '',
backend=' backend.mk' if obj.flags else '',
script=obj.script,
method=obj.method))
elif isinstance(obj, JARManifest):
self._no_skip['libs'].add(backend_file.relobjdir)
backend_file.write('JAR_MANIFEST := %s\n' % obj.path.full_path)
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -566,17 +566,17 @@ class TreeMetadataEmitter(LoggingMixin):
script = mozpath.join(
mozpath.dirname(mozpath.dirname(__file__)),
'action', 'generate_symbols_file.py')
defines = ()
if lib.defines:
defines = lib.defines.get_defines()
yield GeneratedFile(context, script,
'generate_symbols_file', lib.symbols_file,
- [symbols_file.full_path], defines)
+ [symbols_file], defines)
if static_lib:
lib = StaticLibrary(context, libname, **static_args)
self._libs[libname].append(lib)
self._linkage.append((context, lib, 'USE_LIBS'))
has_linkables = True
if lib_defines:
if not libname:
@@ -976,17 +976,17 @@ class TreeMetadataEmitter(LoggingMixin):
xpidl_module, add_to_manifest=not context['XPIDL_NO_MANIFEST'])
def _process_generated_files(self, context):
for path in context['CONFIGURE_DEFINE_FILES']:
script = mozpath.join(mozpath.dirname(mozpath.dirname(__file__)),
'action', 'process_define_files.py')
yield GeneratedFile(context, script, 'process_define_file',
unicode(path),
- [mozpath.join(context.srcdir, path + '.in')])
+ [Path(context, path + '.in')])
generated_files = context.get('GENERATED_FILES')
if not generated_files:
return
for f in generated_files:
flags = generated_files[f]
output = f
@@ -1011,17 +1011,17 @@ class TreeMetadataEmitter(LoggingMixin):
for i in flags.inputs:
p = Path(context, i)
if (isinstance(p, SourcePath) and
not os.path.exists(p.full_path)):
raise SandboxValidationError(
'Input for generating %s does not exist: %s'
% (f, p.full_path), context)
- inputs.append(p.full_path)
+ inputs.append(p)
else:
script = None
method = None
yield GeneratedFile(context, script, method, output, inputs)
def _process_test_manifests(self, context):
for prefix, info in TEST_MANIFESTS.items():
for path, manifest in context.get('%s_MANIFESTS' % prefix, []):