Bug 1474028 - Use output categories to exclude the gtest libxul from the default tup build. r=mshal
authorChris Manchester <cmanchester@mozilla.com>
Fri, 10 Aug 2018 12:07:36 -0700
changeset 486671 37cf2f43323bd7c49caa3e308a624a181a1836e9
parent 486670 f3a2d3db15e629812f0860ebdbadc5d6050c0307
child 486672 7395257233f2fce9f80a7660cbfb2b91d379b28f
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs1474028
milestone63.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 1474028 - Use output categories to exclude the gtest libxul from the default tup build. r=mshal MozReview-Commit-ID: 2C9PmFziFqr
python/mozbuild/mozbuild/backend/tup.py
--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -251,33 +251,39 @@ class TupBackend(CommonBackend):
             '*.inc',
             '*.msg',
             '*.py',
             '*.rs',
         )
 
         # These are 'group' dependencies - All rules that list these as an output
         # will be built before any rules that list this as an input.
-        self._installed_idls = '$(MOZ_OBJ_ROOT)/<installed-idls>'
-        self._installed_files = '$(MOZ_OBJ_ROOT)/<installed-files>'
-        self._rust_libs = '$(MOZ_OBJ_ROOT)/<rust-libs>'
+        self._installed_idls = self._output_group('installed-idls')
+        self._installed_files = self._output_group('installed-files')
+        self._rust_libs = self._output_group('rust-libs')
         # The preprocessor including source-repo.h and buildid.h creates
         # 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._early_generated_files = self._output_group('early-generated-files')
 
-        self._shlibs = '$(MOZ_OBJ_ROOT)/<shlibs>'
-        self._gtests = '$(MOZ_OBJ_ROOT)/<gtest>'
-        self._default_group = '$(MOZ_OBJ_ROOT)/<default>'
+        self._shlibs = self._output_group('shlibs')
+        self._default_group = self._output_group('default')
 
         self._rust_cmds = set()
 
         self._built_in_addons = set()
         self._built_in_addons_file = 'dist/bin/browser/chrome/browser/content/browser/built_in_addons.json'
 
+    def _output_group(self, label):
+        if label:
+            return '$(MOZ_OBJ_ROOT)/<%s>' % label
+
+    def _rust_output_group(self, label):
+        if label:
+            return self._output_group('rust-' + label)
 
     def _get_mozconfig_env(self, config):
         env = {}
         loader = MozconfigLoader(config.topsrcdir)
         mozconfig = loader.read_mozconfig(config.substs['MOZCONFIG'])
         make_extra = mozconfig['make_extra'] or []
         env = {}
         for line in make_extra:
@@ -338,18 +344,18 @@ class TupBackend(CommonBackend):
     def _lib_paths(self, objdir, libs):
         return [mozpath.relpath(mozpath.join(l.objdir, l.import_name), objdir)
                 for l in libs]
 
     def _gen_shared_library(self, backend_file):
         shlib = backend_file.shared_lib
 
         output_group = self._shlibs
-        if 'toolkit/library/gtest' in backend_file.objdir:
-            output_group = self._gtests
+        if shlib.output_category:
+            output_group = self._output_group(shlib.output_category)
 
         if shlib.cxx_link:
             mkshlib = (
                 [backend_file.environment.substs['CXX']] +
                 backend_file.local_flags['CXX_LDFLAGS']
             )
         else:
             mkshlib = (
@@ -366,26 +372,26 @@ class TupBackend(CommonBackend):
 
         objs, _, _, shared_libs, os_libs, static_libs = self._expand_libs(shlib)
         static_libs = self._lib_paths(backend_file.objdir, static_libs)
         shared_libs = self._lib_paths(backend_file.objdir, shared_libs)
 
         list_file_name = '%s.list' % shlib.name.replace('.', '_')
         list_file = self._make_list_file(backend_file.objdir, objs, list_file_name)
 
-        rust_linked = self._lib_paths(backend_file.objdir,
-                                      (l for l in backend_file.shared_lib.linked_libraries
-                                       if isinstance(l, RustLibrary)))
+        rust_linked = [l for l in backend_file.shared_lib.linked_libraries
+                       if isinstance(l, RustLibrary)]
 
         inputs = objs + static_libs + shared_libs
 
         extra_inputs = []
         if rust_linked:
-            extra_inputs = [self._rust_libs]
-            static_libs += rust_linked
+            extra_inputs = [self._rust_output_group(rust_linked[0].output_category) or
+                            self._rust_libs]
+            static_libs += self._lib_paths(backend_file.objdir, rust_linked)
 
         symbols_file = []
         if (shlib.symbols_file and
             backend_file.environment.substs.get('GCC_USE_GNU_LD')):
             inputs.append(shlib.symbols_file)
             symbols_file = ['-Wl,--version-script,%s' % shlib.symbols_file]
 
         cmd = (
@@ -734,17 +740,17 @@ class TupBackend(CommonBackend):
         if os.environ.get('MOZ_AUTOMATION'):
             # Build scripts generally read environment variables that are set
             # by cargo, however, some may rely on MOZ_AUTOMATION. We may need
             # to audit for others as well.
             env['MOZ_AUTOMATION'] = os.environ['MOZ_AUTOMATION']
 
         return env
 
-    def _gen_cargo_rules(self, backend_file, build_plan, cargo_env):
+    def _gen_cargo_rules(self, backend_file, build_plan, cargo_env, output_group):
         invocations = build_plan['invocations']
         processed = set()
 
         def get_libloading_outdir():
             for invocation in invocations:
                 if (invocation['package_name'] == 'libloading' and
                     invocation['outputs'][0].endswith('.rlib')):
                     return invocation['env']['OUT_DIR']
@@ -826,24 +832,24 @@ class TupBackend(CommonBackend):
                 # 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')
                 rust_backend_file.rule(
                     command,
                     inputs=sorted(inputs),
                     outputs=outputs,
-                    output_group=self._rust_libs,
+                    output_group=output_group,
                     extra_inputs=[self._installed_files],
                     display='%s %s' % (header, display_name(invocation)),
                     check_unchanged=check_unchanged,
                 )
 
                 for dst, link in invocation['links'].iteritems():
-                    rust_backend_file.symlink_rule(link, dst, self._rust_libs)
+                    rust_backend_file.symlink_rule(link, dst, output_group)
 
         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)
@@ -857,17 +863,20 @@ class TupBackend(CommonBackend):
             line_handler=accumulate_output,
             ensure_exit_code=False,
             explicit_env=cargo_env)
         if cargo_status:
             raise Exception("cargo --build-plan failed with output:\n%s" %
                             '\n'.join(output_lines))
 
         cargo_plan = json.loads(''.join(output_lines))
-        self._gen_cargo_rules(backend_file, cargo_plan, cargo_env)
+
+        self._gen_cargo_rules(backend_file, cargo_plan, cargo_env,
+                              self._rust_output_group(obj.output_category) or
+                              self._rust_libs)
         self.backend_input_files |= set(cargo_plan['inputs'])
 
 
     def _process_generated_file(self, backend_file, obj):
         if obj.script and obj.method:
             backend_file.export_shell()
             cmd = self._py_action('file_generate')
             if obj.localized: