Bug 1235021 - Add a RenamedSourcePath helper class. r=gps

This class will be used to represent files that are copied with a different
name, which we have plenty of in jar manifests.
This commit is contained in:
Mike Hommey 2015-12-24 08:55:26 +09:00
parent 2b5200312f
commit b2f22a11cd
4 changed files with 31 additions and 7 deletions

View File

@ -76,11 +76,12 @@ class FasterMakeBackend(CommonBackend):
for f in files:
if isinstance(obj, FinalTargetPreprocessedFiles):
self._add_preprocess(obj, f.full_path, path,
target=f.target_basename,
defines=defines)
else:
self._install_manifests[obj.install_target].add_symlink(
f.full_path,
mozpath.join(path, mozpath.basename(f))
mozpath.join(path, f.target_basename)
)
elif isinstance(obj, ChromeManifestEntry) and \

View File

@ -26,6 +26,7 @@ import mozpack.path as mozpath
from mozbuild.frontend.context import (
Path,
RenamedSourcePath,
SourcePath,
ObjDirPath,
)
@ -1273,8 +1274,8 @@ INSTALL_TARGETS += %(prefix)s
if path else target).replace('/', '_')
have_objdir_files = False
for f in files:
dest = mozpath.join(reltarget, path,
mozpath.basename(f.full_path))
assert not isinstance(f, RenamedSourcePath)
dest = mozpath.join(reltarget, path, f.target_basename)
if not isinstance(f, ObjDirPath):
install_manifest.add_symlink(f.full_path, dest)
else:

View File

@ -398,6 +398,10 @@ class Path(ContextDerivedValue, unicode):
def __hash__(self):
return hash(self.full_path)
@memoized_property
def target_basename(self):
return mozpath.basename(self.full_path)
class SourcePath(Path):
"""Like Path, but limited to paths in the source directory."""
@ -433,6 +437,24 @@ class SourcePath(Path):
return ObjDirPath(self.context, '!%s' % self).full_path
class RenamedSourcePath(SourcePath):
"""Like SourcePath, but with a different base name when installed.
The constructor takes a tuple of (source, target_basename).
This class is not meant to be exposed to moz.build sandboxes as of now,
and is not supported by the RecursiveMake backend.
"""
def __init__(self, context, value):
assert isinstance(value, tuple)
source, self._target_basename = value
super(RenamedSourcePath, self).__init__(context, source)
@property
def target_basename(self):
return self._target_basename
class ObjDirPath(Path):
"""Like Path, but limited to paths in the object directory."""
def __init__(self, context, value=None):

View File

@ -681,7 +681,7 @@ class TreeMetadataEmitter(LoggingMixin):
'File listed in %s does not exist: %s'
% (var, path), context)
else:
if mozpath.basename(f.full_path) not in generated_files:
if f.target_basename not in generated_files:
raise SandboxValidationError(
('Objdir file listed in %s not in ' +
'GENERATED_FILES: %s') % (var, f), context)