Bug 1371817 - Handle FinalTargetFiles with wildcards in the Tup backend. draft
authorChris Manchester <cmanchester@mozilla.com>
Wed, 21 Jun 2017 15:35:19 -0700
changeset 598638 865936535b72bc1847a0c902ed69ecfced1c3e3b
parent 598633 e916ab827babb677ce5ab2cac0390c1401eaca0e
child 598642 779f4c88788701df1a60ba2438b7130a992c891d
push id65266
push userbmo:cmanchester@mozilla.com
push dateWed, 21 Jun 2017 23:18:12 +0000
bugs1371817
milestone56.0a1
Bug 1371817 - Handle FinalTargetFiles with wildcards in the Tup backend. MozReview-Commit-ID: KMJJ8vg7g7s
python/mozbuild/mozbuild/backend/tup.py
--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -8,16 +8,20 @@ import os
 
 import mozpack.path as mozpath
 from mozbuild.base import MozbuildObject
 from mozbuild.backend.base import PartialBackend, HybridBackend
 from mozbuild.backend.recursivemake import RecursiveMakeBackend
 from mozbuild.shellutil import quote as shell_quote
 from mozbuild.util import OrderedDefaultDict
 
+from mozpack.files import (
+    FileFinder,
+)
+
 from .common import CommonBackend
 from ..frontend.data import (
     ChromeManifestEntry,
     ContextDerived,
     Defines,
     FinalTargetFiles,
     FinalTargetPreprocessedFiles,
     GeneratedFile,
@@ -315,18 +319,31 @@ class TupOnly(CommonBackend, PartialBack
                             basepath, wild = os.path.split(f.full_path)
                             if '*' in basepath:
                                 raise Exception("Wildcards are only supported in the filename part of "
                                                 "srcdir-relative or absolute paths.")
 
                             # TODO: This is only needed for Windows, so we can
                             # skip this for now.
                             pass
+                        elif '**' not in f:
+                            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)
+                            finder = FileFinder(prefix)
+                            for p, _ in finder.find(f.full_path[len(prefix):]):
+                                backend_file.symlink_rule(mozpath.join(prefix, p),
+                                                          output=mozpath.join(f.target_basename, p),
+                                                          output_group=self._installed_files)
                         else:
-                            # TODO: This is needed for tests
+                            # TODO: Handle wildcards containing '**' used under '_tests'
+                            # (bug 1372381).
                             pass
                     else:
                         backend_file.symlink_rule(f.full_path, output=f.target_basename, output_group=self._installed_files)
                 else:
                     # TODO: Support installing generated files
                     pass
 
     def _process_final_target_pp_files(self, obj, backend_file):