Bug 1372381 - Install TEST_HARNESS_FILES in the tup backend. draft
authorChris Manchester <cmanchester@mozilla.com>
Mon, 30 Apr 2018 11:10:44 -0700
changeset 790017 e8229a13aaf6e20c2e9232a6123ddaca5e672a75
parent 790016 5a28305e85311bb38b39e467600f80d5369be660
push id108388
push userbmo:cmanchester@mozilla.com
push dateMon, 30 Apr 2018 23:35:47 +0000
bugs1372381
milestone61.0a1
Bug 1372381 - Install TEST_HARNESS_FILES in the tup backend. MozReview-Commit-ID: 3PTtvoh8D9L
python/mozbuild/mozbuild/backend/tup.py
--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -51,16 +51,17 @@ from ..frontend.data import (
 )
 from ..util import (
     FileAvoidWrite,
     expand_variables,
 )
 from ..frontend.context import (
     AbsolutePath,
     ObjDirPath,
+    RenamedSourcePath,
 )
 
 
 class BackendTupfile(object):
     """Represents a generated Tupfile.
     """
 
     def __init__(self, objdir, environment, topsrcdir, topobjdir, dry_run):
@@ -682,21 +683,16 @@ class TupBackend(CommonBackend):
                 'dist/xpi-stage',
                 '_tests',
                 'dist/include',
                 'dist/sdk',
             ))
             if not path:
                 raise Exception("Cannot install to " + target)
 
-        if target.startswith('_tests'):
-            # TODO: TEST_HARNESS_FILES present a few challenges for the tup
-            # backend (bug 1372381).
-            return
-
         for path, files in obj.files.walk():
             self._add_features(target, path)
             for f in files:
                 output_group = None
                 if any(mozpath.match(mozpath.basename(f), p)
                        for p in self._compile_env_files):
                     output_group = self._installed_files
 
@@ -714,20 +710,34 @@ class TupBackend(CommonBackend):
                             pass
                         else:
                             def _prefix(s):
                                 for p in mozpath.split(s):
                                     if '*' not in p:
                                         yield p + '/'
                             prefix = ''.join(_prefix(f.full_path))
                             self.backend_input_files.add(prefix)
+
+                            output_dir = ''
+                            # If we have a RenamedSourcePath here, the common backend
+                            # has generated this object from a jar manifest, and we
+                            # can rely on 'path' to be our destination path relative
+                            # to any wildcard match. Otherwise, the output file may
+                            # contribute to our destination directory.
+                            if not isinstance(f, RenamedSourcePath):
+                                output_dir = ''.join(_prefix(mozpath.dirname(f)))
+
                             finder = FileFinder(prefix)
                             for p, _ in finder.find(f.full_path[len(prefix):]):
+                                install_dir = prefix[len(obj.srcdir) + 1:]
+                                output = p
+                                if f.target_basename and '*' not in f.target_basename:
+                                    output = mozpath.join(f.target_basename, output)
                                 backend_file.symlink_rule(mozpath.join(prefix, p),
-                                                          output=mozpath.join(f.target_basename, p),
+                                                          output=mozpath.join(output_dir, output),
                                                           output_group=output_group)
                     else:
                         backend_file.symlink_rule(f.full_path, output=f.target_basename, output_group=output_group)
                 else:
                     if (self.environment.is_artifact_build and
                         any(mozpath.match(f.target_basename, p) for p in self._compile_env_gen_files)):
                         # If we have an artifact build we never would have generated this file,
                         # so do not attempt to install it.