Bug 1476802 - Make toolkit/library/rust/Tupfile work with --dry-run; r?Build draft
authorMike Shal <mshal@mozilla.com>
Wed, 18 Jul 2018 17:20:13 -0400
changeset 820103 80472621648eddd6ee14531b3c3deeb5c45abf60
parent 819486 afa310dc89beeb4b7a9564d2c89ff32906f427ad
push id116726
push userbmo:mshal@mozilla.com
push dateWed, 18 Jul 2018 22:13:33 +0000
reviewersBuild
bugs1476802
milestone63.0a1
Bug 1476802 - Make toolkit/library/rust/Tupfile work with --dry-run; r?Build We shouldn't call _get_backend_file during TupBackend:_init() since self.dry_run is not set yet. Instead we can just call it when we need to add rust rules. MozReview-Commit-ID: 5elqXGFMSuG
python/mozbuild/mozbuild/backend/tup.py
--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -260,21 +260,17 @@ class TupBackend(CommonBackend):
         # dependencies that aren't specified by moz.build and cause errors
         # in Tup. Express these as a group dependency.
         self._early_generated_files = '$(MOZ_OBJ_ROOT)/<early-generated-files>'
 
         self._shlibs = '$(MOZ_OBJ_ROOT)/<shlibs>'
         self._gtests = '$(MOZ_OBJ_ROOT)/<gtest>'
         self._default_group = '$(MOZ_OBJ_ROOT)/<default>'
 
-        # The two rust libraries in the tree share many prerequisites, so we need
-        # to prune common dependencies and therefore build all rust from the same
-        # Tupfile.
         self._rust_outputs = set()
-        self._rust_backend_file = self._get_backend_file('toolkit/library/rust')
 
         self._built_in_addons = set()
         self._built_in_addons_file = 'dist/bin/browser/chrome/browser/content/browser/built_in_addons.json'
 
 
     def _get_mozconfig_env(self, config):
         env = {}
         loader = MozconfigLoader(config.topsrcdir)
@@ -793,30 +789,33 @@ class TupBackend(CommonBackend):
                 inputs.add(invocation['program'])
                 header = 'RUN'
 
             invocation['full-deps'] = set(inputs)
             invocation['full-deps'].update(invocation['outputs'])
 
             output_key = tuple(outputs)
             if output_key not in self._rust_outputs:
+                # The two rust libraries in the tree share many prerequisites,
+                # so we need to prune common dependencies and therefore build
+                # all rust from the same Tupfile.
+                rust_backend_file = self._get_backend_file('toolkit/library/rust')
                 self._rust_outputs.add(output_key)
-                self._rust_backend_file.rule(
+                rust_backend_file.rule(
                     command,
                     inputs=sorted(inputs),
                     outputs=outputs,
                     output_group=self._rust_libs,
                     extra_inputs=[self._installed_files],
                     display='%s %s' % (header, display_name(invocation)),
                 )
 
                 for dst, link in invocation['links'].iteritems():
                     self._rust_outputs.add(output_key)
-                    self._rust_backend_file.symlink_rule(link, dst,
-                                                         self._rust_libs)
+                    rust_backend_file.symlink_rule(link, dst, self._rust_libs)
 
         for val in enumerate(invocations):
             _process(*val)
 
 
     def _gen_rust_rules(self, obj, backend_file):
         cargo_flags = self._get_cargo_flags(obj)
         cargo_env = self._get_cargo_env(obj, backend_file)