mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 15:25:52 +00:00
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:
parent
2b5200312f
commit
b2f22a11cd
@ -45,9 +45,9 @@ class FasterMakeBackend(CommonBackend):
|
||||
def _add_preprocess(self, obj, path, dest, target=None, **kwargs):
|
||||
if target is None:
|
||||
target = mozpath.basename(path)
|
||||
# This matches what PP_TARGETS do in config/rules.
|
||||
if target.endswith('.in'):
|
||||
target = target[:-3]
|
||||
# This matches what PP_TARGETS do in config/rules.
|
||||
if target.endswith('.in'):
|
||||
target = target[:-3]
|
||||
if target.endswith('.css'):
|
||||
kwargs['marker'] = '%'
|
||||
depfile = mozpath.join(
|
||||
@ -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 \
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user