Bug 1305157 - Handle the build/ directory's GENERATED_FILES; r?gps
This is a little tricky since tup expects rules in a single Tupfile to
be topologically sorted, and the emitter emits the GeneratedFile object
before it emits the FinalTargetPreprocessedFile object. We work around
this by delaying when we process the application.ini.h GeneratedFile
object, but it's a hack.
MozReview-Commit-ID: 8nVm76nZOKb
--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -36,16 +36,17 @@ class BackendTupfile(object):
self.objdir = objdir
self.relobjdir = mozpath.relpath(objdir, topobjdir)
self.environment = environment
self.name = mozpath.join(objdir, 'Tupfile')
self.rules_included = False
self.shell_exported = False
self.defines = []
self.host_defines = []
+ self.delayed_generated_files = []
self.fh = FileAvoidWrite(self.name, capture_diff=True)
self.fh.write('# THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT.\n')
self.fh.write('\n')
def write(self, buf):
self.fh.write(buf)
@@ -145,32 +146,41 @@ class TupOnly(CommonBackend, PartialBack
skip_files = (
'buildid.h',
'source-repo.h',
)
if any(f in skip_files for f in obj.outputs):
# Let the RecursiveMake backend handle these.
return False
- self._process_generated_file(backend_file, obj)
+ if 'application.ini.h' in obj.outputs:
+ # application.ini.h is a special case since we need to process
+ # the FINAL_TARGET_PP_FILES for application.ini before running
+ # the GENERATED_FILES script, and tup doesn't handle the rules
+ # out of order.
+ backend_file.delayed_generated_files.append(obj)
+ else:
+ self._process_generated_file(backend_file, obj)
elif isinstance(obj, Defines):
self._process_defines(backend_file, obj)
elif isinstance(obj, HostDefines):
self._process_defines(backend_file, obj, host=True)
elif isinstance(obj, FinalTargetPreprocessedFiles):
self._process_final_target_pp_files(obj, backend_file)
elif isinstance(obj, ObjdirPreprocessedFiles):
self._process_final_target_pp_files(obj, backend_file)
return True
def consume_finished(self):
CommonBackend.consume_finished(self)
for objdir, backend_file in sorted(self._backend_files.items()):
+ for obj in backend_file.delayed_generated_files:
+ self._process_generated_file(backend_file, obj)
with self._write_file(fh=backend_file):
pass
with self._write_file(mozpath.join(self.environment.topobjdir, 'Tuprules.tup')) as fh:
acdefines = [name for name in self.environment.defines
if not name in self.environment.non_global_defines]
acdefines_flags = ' '.join(['-D%s=%s' % (name,
shell_quote(self.environment.defines[name]))
@@ -194,17 +204,16 @@ class TupOnly(CommonBackend, PartialBack
if not os.path.exists(mozpath.join(self.environment.topsrcdir, ".tup")):
tup = self.environment.substs.get('TUP', 'tup')
self._cmd.run_process(cwd=self.environment.topsrcdir, log_name='tup', args=[tup, 'init'])
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 = (
- 'build', # FinalTargetPreprocessedFiles
'layout/style/test', # HostSimplePrograms
'toolkit/library', # libxul.so
)
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,