Bug 1229241 - Redirect EXTRA{_PP}_COMPONENTS to FINAL_TARGET{,_PP}_FILES.components. r=gps

This commit is contained in:
Mike Hommey 2015-11-27 22:54:39 +09:00
parent e0564fea40
commit 4674cd8a4e
11 changed files with 44 additions and 101 deletions

View File

@ -1172,33 +1172,6 @@ INSTALL_TARGETS += AUTOCFG_JS_EXPORTS
endif
endif
################################################################################
# Copy each element of EXTRA_COMPONENTS to $(FINAL_TARGET)/components
ifdef EXTRA_COMPONENTS
misc:: $(EXTRA_COMPONENTS)
ifndef NO_DIST_INSTALL
EXTRA_COMPONENTS_FILES := $(EXTRA_COMPONENTS)
EXTRA_COMPONENTS_DEST := $(FINAL_TARGET)/components
EXTRA_COMPONENTS_TARGET := misc
INSTALL_TARGETS += EXTRA_COMPONENTS
endif
endif
ifdef EXTRA_PP_COMPONENTS
ifndef NO_DIST_INSTALL
EXTRA_PP_COMPONENTS_PATH := $(FINAL_TARGET)/components
EXTRA_PP_COMPONENTS_TARGET := misc
PP_TARGETS += EXTRA_PP_COMPONENTS
endif
endif
EXTRA_MANIFESTS = $(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS))
ifneq (,$(EXTRA_MANIFESTS))
misc:: $(call mkdir_deps,$(FINAL_TARGET))
$(call py_action,buildlist,$(FINAL_TARGET)/chrome.manifest $(patsubst %,'manifest components/%',$(notdir $(EXTRA_MANIFESTS))))
endif
################################################################################
# SDK
@ -1584,8 +1557,6 @@ FREEZE_VARIABLES = \
DIRS \
LIBRARY \
MODULE \
EXTRA_COMPONENTS \
EXTRA_PP_COMPONENTS \
$(NULL)
$(foreach var,$(FREEZE_VARIABLES),$(eval $(var)_FROZEN := '$($(var))'))

View File

@ -11,7 +11,7 @@ EXTRA_COMPONENTS += [
'DownloadsAPI.manifest',
]
EXTRA_PP_COMPONENTS = [
EXTRA_PP_COMPONENTS += [
'DownloadsAPI.js',
]

View File

@ -15,7 +15,6 @@ from mozbuild.frontend.data import (
JavaScriptModules,
JsPreferenceFile,
Resources,
VariablePassthru,
XPIDLFile,
)
from mozbuild.jar import JarManifestParser
@ -78,30 +77,6 @@ class FasterMakeBackend(CommonBackend):
obj.install_target.startswith('dist/bin'):
self._consume_jar_manifest(obj, defines)
elif isinstance(obj, VariablePassthru) and \
obj.install_target.startswith('dist/bin'):
for f in obj.variables.get('EXTRA_COMPONENTS', {}):
path = mozpath.join(obj.install_target, 'components',
mozpath.basename(f))
self._install_manifests[obj.install_target].add_symlink(
mozpath.join(obj.srcdir, f),
mozpath.join('components', mozpath.basename(f))
)
if f.endswith('.manifest'):
manifest = mozpath.join(obj.install_target,
'chrome.manifest')
self._manifest_entries[manifest].append(
'manifest components/%s' % mozpath.basename(f))
for f in obj.variables.get('EXTRA_PP_COMPONENTS', {}):
self._add_preprocess(obj, f, 'components', defines=defines)
if f.endswith('.manifest'):
manifest = mozpath.join(obj.install_target,
'chrome.manifest')
self._manifest_entries[manifest].append(
'manifest components/%s' % mozpath.basename(f))
elif isinstance(obj, JavaScriptModules) and \
obj.install_target.startswith('dist/bin'):
for path, strings in obj.modules.walk():

View File

@ -1378,6 +1378,9 @@ INSTALL_TARGETS += %(prefix)s
elif target.startswith('dist/xpi-stage'):
install_manifest = self._install_manifests['dist_xpi-stage']
reltarget = mozpath.relpath(target, 'dist/xpi-stage')
elif target.startswith('_tests'):
install_manifest = self._install_manifests['tests']
reltarget = mozpath.relpath(target, '_tests')
else:
raise Exception("Cannot install to " + target)

View File

@ -1001,13 +1001,6 @@ VARIABLES = {
"""Like ``FINAL_TARGET_FILES``, with preprocessing.
""", 'libs'),
'EXTRA_COMPONENTS': (StrictOrderingOnAppendList, list,
"""Additional component files to distribute.
This variable contains a list of files to copy into
``$(FINAL_TARGET)/components/``.
""", 'misc'),
'EXTRA_JS_MODULES': (HierarchicalStringList, list,
"""Additional JavaScript files to distribute.
@ -1034,13 +1027,6 @@ VARIABLES = {
``TESTING_JS_MODULES.foo += ['module.jsm']``.
""", None),
'EXTRA_PP_COMPONENTS': (StrictOrderingOnAppendList, list,
"""Javascript XPCOM files.
This variable contains a list of files to preprocess. Generated
files will be installed in the ``/components`` directory of the distribution.
""", 'misc'),
'FINAL_LIBRARY': (unicode, unicode,
"""Library in which the objects of the current directory will be linked.
@ -1969,6 +1955,21 @@ SPECIAL_VARIABLES = {
Access to an unknown variable will return None.
"""),
'EXTRA_COMPONENTS': (lambda context: context['FINAL_TARGET_FILES'].components._strings, list,
"""Additional component files to distribute.
This variable contains a list of files to copy into
``$(FINAL_TARGET)/components/``.
"""),
'EXTRA_PP_COMPONENTS': (lambda context: context['FINAL_TARGET_PP_FILES'].components._strings, list,
"""Javascript XPCOM files.
This variable contains a list of files to preprocess. Generated
files will be installed in the ``/components`` directory of the distribution.
"""),
}
# Deprecation hints.

View File

@ -76,7 +76,10 @@ from .data import (
WebIDLFile,
XPIDLFile,
)
from mozpack.chrome.manifest import ManifestBinaryComponent
from mozpack.chrome.manifest import (
ManifestBinaryComponent,
Manifest,
)
from .reader import SandboxValidationError
@ -554,17 +557,6 @@ class TreeMetadataEmitter(LoggingMixin):
for obj in self._process_xpidl(context):
yield obj
# Check for manifest declarations in EXTRA_{PP_,}COMPONENTS.
extras = context.get('EXTRA_COMPONENTS', []) + context.get('EXTRA_PP_COMPONENTS', [])
if any(e.endswith('.js') for e in extras) and \
not any(e.endswith('.manifest') for e in extras) and \
not context.get('NO_JS_MANIFEST', False):
raise SandboxValidationError('A .js component was specified in EXTRA_COMPONENTS '
'or EXTRA_PP_COMPONENTS without a matching '
'.manifest file. See '
'https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0 .',
context);
# Proxy some variables as-is until we have richer classes to represent
# them. We should aim to keep this set small because it violates the
# desired abstraction of the build definition away from makefiles.
@ -575,9 +567,7 @@ class TreeMetadataEmitter(LoggingMixin):
'ANDROID_APK_PACKAGE',
'ANDROID_GENERATED_RESFILES',
'DISABLE_STL_WRAPPING',
'EXTRA_COMPONENTS',
'EXTRA_DSO_LDOPTS',
'EXTRA_PP_COMPONENTS',
'USE_STATIC_LIBS',
'PYTHON_UNIT_TESTS',
'RCFILE',
@ -686,6 +676,7 @@ class TreeMetadataEmitter(LoggingMixin):
local_include.full_path), context)
yield LocalInclude(context, local_include)
components = []
for var, cls in (
('FINAL_TARGET_FILES', FinalTargetFiles),
('FINAL_TARGET_PP_FILES', FinalTargetPreprocessedFiles),
@ -697,7 +688,9 @@ class TreeMetadataEmitter(LoggingMixin):
raise SandboxValidationError(
'%s cannot be used with DIST_INSTALL = False' % var,
context)
for _, files in all_files.walk():
for base, files in all_files.walk():
if base == 'components':
components.extend(files)
for f in files:
path = os.path.join(context.srcdir, f)
if not os.path.exists(path):
@ -707,6 +700,22 @@ class TreeMetadataEmitter(LoggingMixin):
yield cls(context, all_files, context['FINAL_TARGET'])
# Check for manifest declarations in EXTRA_{PP_,}COMPONENTS.
if any(e.endswith('.js') for e in components) and \
not any(e.endswith('.manifest') for e in components) and \
not context.get('NO_JS_MANIFEST', False):
raise SandboxValidationError('A .js component was specified in EXTRA_COMPONENTS '
'or EXTRA_PP_COMPONENTS without a matching '
'.manifest file. See '
'https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0 .',
context);
for c in components:
if c.endswith('.manifest'):
yield ChromeManifestEntry(context, 'chrome.manifest',
Manifest('components',
mozpath.basename(c)))
branding_files = context.get('BRANDING_FILES')
if branding_files:
yield BrandingFiles(context, branding_files)

View File

@ -2,9 +2,6 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
EXTRA_COMPONENTS = ['bar.js', 'dummy.manifest', 'foo.js']
EXTRA_PP_COMPONENTS = ['bar.pp.js', 'foo.pp.js']
NO_VISIBILITY_FLAGS = True
DELAYLOAD_DLLS = ['foo.dll', 'bar.dll']

View File

@ -266,15 +266,6 @@ class TestRecursiveMakeBackend(BackendTester):
'DISABLE_STL_WRAPPING': [
'DISABLE_STL_WRAPPING := 1',
],
'EXTRA_COMPONENTS': [
'EXTRA_COMPONENTS += bar.js',
'EXTRA_COMPONENTS += dummy.manifest',
'EXTRA_COMPONENTS += foo.js',
],
'EXTRA_PP_COMPONENTS': [
'EXTRA_PP_COMPONENTS += bar.pp.js',
'EXTRA_PP_COMPONENTS += foo.pp.js',
],
'VISIBILITY_FLAGS': [
'VISIBILITY_FLAGS :=',
],

View File

@ -2,9 +2,6 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
EXTRA_COMPONENTS = ['dummy.manifest', 'fans.js', 'tans.js']
EXTRA_PP_COMPONENTS=['fans.pp.js', 'tans.pp.js']
DIST_INSTALL = False
NO_VISIBILITY_FLAGS = True

View File

@ -156,8 +156,6 @@ class TestEmitterBasic(unittest.TestCase):
wanted = {
'ALLOW_COMPILER_WARNINGS': True,
'DISABLE_STL_WRAPPING': True,
'EXTRA_COMPONENTS': ['dummy.manifest', 'fans.js', 'tans.js'],
'EXTRA_PP_COMPONENTS': ['fans.pp.js', 'tans.pp.js'],
'NO_DIST_INSTALL': True,
'VISIBILITY_FLAGS': '',
'RCFILE': 'foo.rc',

View File

@ -209,6 +209,7 @@ class TestMozbuildSandbox(unittest.TestCase):
def test_special_variables(self):
sandbox = self.sandbox()
sandbox._context.add_source(sandbox.normalize_path('moz.build'))
for k in SPECIAL_VARIABLES:
with self.assertRaises(KeyError):