--- 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')