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):
|
def _add_preprocess(self, obj, path, dest, target=None, **kwargs):
|
||||||
if target is None:
|
if target is None:
|
||||||
target = mozpath.basename(path)
|
target = mozpath.basename(path)
|
||||||
# This matches what PP_TARGETS do in config/rules.
|
# This matches what PP_TARGETS do in config/rules.
|
||||||
if target.endswith('.in'):
|
if target.endswith('.in'):
|
||||||
target = target[:-3]
|
target = target[:-3]
|
||||||
if target.endswith('.css'):
|
if target.endswith('.css'):
|
||||||
kwargs['marker'] = '%'
|
kwargs['marker'] = '%'
|
||||||
depfile = mozpath.join(
|
depfile = mozpath.join(
|
||||||
@ -76,11 +76,12 @@ class FasterMakeBackend(CommonBackend):
|
|||||||
for f in files:
|
for f in files:
|
||||||
if isinstance(obj, FinalTargetPreprocessedFiles):
|
if isinstance(obj, FinalTargetPreprocessedFiles):
|
||||||
self._add_preprocess(obj, f.full_path, path,
|
self._add_preprocess(obj, f.full_path, path,
|
||||||
|
target=f.target_basename,
|
||||||
defines=defines)
|
defines=defines)
|
||||||
else:
|
else:
|
||||||
self._install_manifests[obj.install_target].add_symlink(
|
self._install_manifests[obj.install_target].add_symlink(
|
||||||
f.full_path,
|
f.full_path,
|
||||||
mozpath.join(path, mozpath.basename(f))
|
mozpath.join(path, f.target_basename)
|
||||||
)
|
)
|
||||||
|
|
||||||
elif isinstance(obj, ChromeManifestEntry) and \
|
elif isinstance(obj, ChromeManifestEntry) and \
|
||||||
|
@ -26,6 +26,7 @@ import mozpack.path as mozpath
|
|||||||
|
|
||||||
from mozbuild.frontend.context import (
|
from mozbuild.frontend.context import (
|
||||||
Path,
|
Path,
|
||||||
|
RenamedSourcePath,
|
||||||
SourcePath,
|
SourcePath,
|
||||||
ObjDirPath,
|
ObjDirPath,
|
||||||
)
|
)
|
||||||
@ -1273,8 +1274,8 @@ INSTALL_TARGETS += %(prefix)s
|
|||||||
if path else target).replace('/', '_')
|
if path else target).replace('/', '_')
|
||||||
have_objdir_files = False
|
have_objdir_files = False
|
||||||
for f in files:
|
for f in files:
|
||||||
dest = mozpath.join(reltarget, path,
|
assert not isinstance(f, RenamedSourcePath)
|
||||||
mozpath.basename(f.full_path))
|
dest = mozpath.join(reltarget, path, f.target_basename)
|
||||||
if not isinstance(f, ObjDirPath):
|
if not isinstance(f, ObjDirPath):
|
||||||
install_manifest.add_symlink(f.full_path, dest)
|
install_manifest.add_symlink(f.full_path, dest)
|
||||||
else:
|
else:
|
||||||
|
@ -398,6 +398,10 @@ class Path(ContextDerivedValue, unicode):
|
|||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash(self.full_path)
|
return hash(self.full_path)
|
||||||
|
|
||||||
|
@memoized_property
|
||||||
|
def target_basename(self):
|
||||||
|
return mozpath.basename(self.full_path)
|
||||||
|
|
||||||
|
|
||||||
class SourcePath(Path):
|
class SourcePath(Path):
|
||||||
"""Like Path, but limited to paths in the source directory."""
|
"""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
|
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):
|
class ObjDirPath(Path):
|
||||||
"""Like Path, but limited to paths in the object directory."""
|
"""Like Path, but limited to paths in the object directory."""
|
||||||
def __init__(self, context, value=None):
|
def __init__(self, context, value=None):
|
||||||
|
@ -681,7 +681,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
|||||||
'File listed in %s does not exist: %s'
|
'File listed in %s does not exist: %s'
|
||||||
% (var, path), context)
|
% (var, path), context)
|
||||||
else:
|
else:
|
||||||
if mozpath.basename(f.full_path) not in generated_files:
|
if f.target_basename not in generated_files:
|
||||||
raise SandboxValidationError(
|
raise SandboxValidationError(
|
||||||
('Objdir file listed in %s not in ' +
|
('Objdir file listed in %s not in ' +
|
||||||
'GENERATED_FILES: %s') % (var, f), context)
|
'GENERATED_FILES: %s') % (var, f), context)
|
||||||
|
Loading…
Reference in New Issue
Block a user