Bug 1315810 - Support some FinalTargetFiles in the tup backend; r=chmanchester
authorMike Shal <mshal@mozilla.com>
Sat, 08 Oct 2016 11:49:20 -0400
changeset 323500 cad7e38527b98bbfcc174bea2f00df99d96d1dac
parent 323499 7a1621d1bea10e135a9c9800f067796cbc02ae9c
child 323501 cd077aefefd6f837890d926aef49f5cccd702798
push id84156
push usercbook@mozilla.com
push dateMon, 21 Nov 2016 14:46:47 +0000
treeherdermozilla-inbound@8d986e9d2bd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1315810
milestone53.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 1315810 - Support some FinalTargetFiles in the tup backend; r=chmanchester MozReview-Commit-ID: 68b596wAp8g
python/mozbuild/mozbuild/backend/tup.py
--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -11,24 +11,30 @@ 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 .common import CommonBackend
 from ..frontend.data import (
     ContextDerived,
     Defines,
+    FinalTargetFiles,
     FinalTargetPreprocessedFiles,
     GeneratedFile,
     HostDefines,
     ObjdirPreprocessedFiles,
 )
 from ..util import (
     FileAvoidWrite,
 )
+from ..frontend.context import (
+    AbsolutePath,
+    RenamedSourcePath,
+    ObjDirPath,
+)
 
 
 class BackendTupfile(object):
     """Represents a generated Tupfile.
     """
 
     def __init__(self, srcdir, objdir, environment, topsrcdir, topobjdir):
         self.topsrcdir = topsrcdir
@@ -172,16 +178,18 @@ class TupOnly(CommonBackend, PartialBack
                 # out of order.
                 backend_file.delayed_generated_files.append(obj)
             else:
                 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)
+        elif isinstance(obj, FinalTargetFiles):
+            self._process_final_target_files(obj)
         elif isinstance(obj, FinalTargetPreprocessedFiles):
             self._process_final_target_pp_files(obj, backend_file)
         elif isinstance(obj, ObjdirPreprocessedFiles):
             self._process_final_target_pp_files(obj, backend_file)
 
         return True
 
     def consume_finished(self):
@@ -252,16 +260,56 @@ class TupOnly(CommonBackend, PartialBack
     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
 
+    def _process_final_target_files(self, obj):
+        target = obj.install_target
+        path = mozpath.basedir(target, (
+            'dist/bin',
+            'dist/xpi-stage',
+            '_tests',
+            'dist/include',
+            'dist/branding',
+            'dist/sdk',
+        ))
+        if not path:
+            raise Exception("Cannot install to " + target)
+
+        reltarget = mozpath.relpath(target, path)
+
+        for path, files in obj.files.walk():
+            backend_file = self._get_backend_file(mozpath.join(target, path))
+            for f in files:
+                assert not isinstance(f, RenamedSourcePath)
+                dest = mozpath.join(reltarget, path, f.target_basename)
+                if not isinstance(f, ObjDirPath):
+                    if '*' in f:
+                        if f.startswith('/') or isinstance(f, AbsolutePath):
+                            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
+                        else:
+                            # TODO: This is needed for tests
+                            pass
+                    else:
+                        backend_file.symlink_rule(f.full_path, output_group=self._installed_files)
+                else:
+                    # TODO: Support installing generated files
+                    pass
+
     def _process_final_target_pp_files(self, obj, backend_file):
         for i, (path, files) in enumerate(obj.files.walk()):
             for f in files:
                 self._preprocess(backend_file, f.full_path,
                                  destdir=mozpath.join(self.environment.topobjdir, obj.install_target, path))
 
     def _handle_idl_manager(self, manager):
         dist_idl_backend_file = self._get_backend_file('dist/idl')