Bug 1305157 - Move GeneratedFile handling into its own function; r=gps
authorMike Shal <mshal@mozilla.com>
Tue, 27 Sep 2016 13:41:16 -0400
changeset 360666 f65ae87fe51a0af01b2f31f98c50c1aa76ba4b47
parent 360665 a008ff0d08b46635ffad694851c52f7d6141d83a
child 360667 1e844b5048255469f65842edd1753882820cb3c3
push id1369
push userjlorenzo@mozilla.com
push dateMon, 27 Feb 2017 14:59:41 +0000
treeherdermozilla-release@d75a1dba431f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1305157
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1305157 - Move GeneratedFile handling into its own function; r=gps MozReview-Commit-ID: HbZBYVugj9E
python/mozbuild/mozbuild/backend/tup.py
--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -134,45 +134,17 @@ class TupOnly(CommonBackend, PartialBack
         # Even if CommonBackend acknowledged the object, we still need to let
         # the RecursiveMake backend also handle these objects.
         if consumed:
             return False
 
         backend_file = self._get_backend_file_for(obj)
 
         if isinstance(obj, GeneratedFile):
-            # 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,
-                    obj.method,
-                    obj.outputs[0],
-                    '%s.pp' % obj.outputs[0], # deps file required
-                ])
-                full_inputs = [f.full_path for f in obj.inputs]
-                cmd.extend(full_inputs)
-
-                outputs = []
-                outputs.extend(obj.outputs)
-                outputs.append('%s.pp' % obj.outputs[0])
-
-                backend_file.rule(
-                    display='python {script}:{method} -> [%o]'.format(script=obj.script, method=obj.method),
-                    cmd=cmd,
-                    inputs=full_inputs,
-                    outputs=outputs,
-                )
+            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)
 
         return True
 
     def consume_finished(self):
@@ -200,16 +172,47 @@ class TupOnly(CommonBackend, PartialBack
             fh.write('IDL_PARSER_DIR = $(topsrcdir)/xpcom/idl-parser\n')
             fh.write('IDL_PARSER_CACHE_DIR = $(MOZ_OBJ_ROOT)/xpcom/idl-parser/xpidl\n')
 
         # Run 'tup init' if necessary.
         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,
+                obj.method,
+                obj.outputs[0],
+                '%s.pp' % obj.outputs[0], # deps file required
+            ])
+            full_inputs = [f.full_path for f in obj.inputs]
+            cmd.extend(full_inputs)
+
+            outputs = []
+            outputs.extend(obj.outputs)
+            outputs.append('%s.pp' % obj.outputs[0])
+
+            backend_file.rule(
+                display='python {script}:{method} -> [%o]'.format(script=obj.script, method=obj.method),
+                cmd=cmd,
+                inputs=full_inputs,
+                outputs=outputs,
+            )
+
     def _process_defines(self, backend_file, obj, host=False):
         defines = list(obj.get_defines())
         if defines:
             if host:
                 backend_file.host_defines = defines
             else:
                 backend_file.defines = defines