зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1476973 - part 4 - emit XPIDLModule, rather than multiple XPIDLFile; r=gps
XPIDL files are logically grouped together into a module, but the current model for the moz.build frontend is that we emit individual XPIDLFile objects, and leave it to the backend to reconstruct module-ness from those. This setup causes a small amout of useless work to be done (e.g. see XPIDLFile handling in RecursiveMakeBackend.consume_object; such handling should only be done once), and it would be cleaner to have the objects emitted reflect the build system concepts as closely as possible. To that end, let's emit XPIDLModule objects instead, which fortunately requires relatively few changes.
This commit is contained in:
Родитель
0d5d951951
Коммит
ba613d4737
|
@ -38,7 +38,7 @@ from mozbuild.frontend.data import (
|
|||
SharedLibrary,
|
||||
StaticLibrary,
|
||||
UnifiedSources,
|
||||
XPIDLFile,
|
||||
XPIDLModule,
|
||||
WebIDLCollection,
|
||||
)
|
||||
from mozbuild.jar import (
|
||||
|
@ -80,18 +80,16 @@ class XPIDLManager(object):
|
|||
self._idls = set()
|
||||
self.modules = defaultdict(self.Module)
|
||||
|
||||
def register_idl(self, idl):
|
||||
"""Registers an IDL file with this instance.
|
||||
def link_module(self, module):
|
||||
"""Links an XPIDL module with with this instance."""
|
||||
for idl in module.idl_files:
|
||||
basename = mozpath.basename(idl.full_path)
|
||||
|
||||
The IDL file will be built, installed, etc.
|
||||
"""
|
||||
basename = mozpath.basename(idl.source_path.full_path)
|
||||
if basename in self._idls:
|
||||
raise Exception('IDL already registered: %s' % basename)
|
||||
self._idls.add(basename)
|
||||
|
||||
if basename in self._idls:
|
||||
raise Exception('IDL already registered: %s' % basename)
|
||||
self._idls.add(basename)
|
||||
|
||||
self.modules[idl.module].add_idls([idl.source_path])
|
||||
self.modules[module.name].add_idls(module.idl_files)
|
||||
|
||||
def idl_stems(self):
|
||||
"""Return an iterator of stems of the managed IDL files.
|
||||
|
@ -119,10 +117,10 @@ class CommonBackend(BuildBackend):
|
|||
def consume_object(self, obj):
|
||||
self._configs.add(obj.config)
|
||||
|
||||
if isinstance(obj, XPIDLFile):
|
||||
if isinstance(obj, XPIDLModule):
|
||||
# TODO bug 1240134 tracks not processing XPIDL files during
|
||||
# artifact builds.
|
||||
self._idl_manager.register_idl(obj)
|
||||
self._idl_manager.link_module(obj)
|
||||
|
||||
elif isinstance(obj, ConfigFileSubstitution):
|
||||
# Do not handle ConfigFileSubstitution for Makefiles. Leave that
|
||||
|
|
|
@ -14,7 +14,7 @@ from mozbuild.frontend.data import (
|
|||
FinalTargetPreprocessedFiles,
|
||||
FinalTargetFiles,
|
||||
JARManifest,
|
||||
XPIDLFile,
|
||||
XPIDLModule,
|
||||
)
|
||||
from mozbuild.makeutil import Makefile
|
||||
from mozbuild.util import OrderedDefaultDict
|
||||
|
@ -105,7 +105,7 @@ class FasterMakeBackend(CommonBackend, PartialBackend):
|
|||
self._manifest_entries[top_level].add(entry)
|
||||
self._manifest_entries[obj.path].add(str(obj.entry))
|
||||
|
||||
elif isinstance(obj, XPIDLFile):
|
||||
elif isinstance(obj, XPIDLModule):
|
||||
self._has_xpidl = True
|
||||
# We're not actually handling XPIDL files.
|
||||
return False
|
||||
|
|
|
@ -72,7 +72,7 @@ from ..frontend.data import (
|
|||
StaticLibrary,
|
||||
TestManifest,
|
||||
VariablePassthru,
|
||||
XPIDLFile,
|
||||
XPIDLModule,
|
||||
)
|
||||
from ..util import (
|
||||
ensureParentDir,
|
||||
|
@ -437,10 +437,10 @@ class RecursiveMakeBackend(CommonBackend):
|
|||
|
||||
consumed = CommonBackend.consume_object(self, obj)
|
||||
|
||||
# CommonBackend handles XPIDLFile, but we want to do
|
||||
# CommonBackend handles XPIDLModule, but we want to do
|
||||
# some extra things for them.
|
||||
if isinstance(obj, XPIDLFile):
|
||||
backend_file.xpt_name = '%s.xpt' % obj.module
|
||||
if isinstance(obj, XPIDLModule):
|
||||
backend_file.xpt_name = '%s.xpt' % obj.name
|
||||
self._idl_dirs.add(obj.relobjdir)
|
||||
|
||||
# If CommonBackend acknowledged the object, we're done with it.
|
||||
|
|
|
@ -192,22 +192,20 @@ class ComputedFlags(ContextDerived):
|
|||
flags[dest_var].extend(value)
|
||||
return flags.items()
|
||||
|
||||
class XPIDLFile(ContextDerived):
|
||||
"""Describes an XPIDL file to be compiled."""
|
||||
class XPIDLModule(ContextDerived):
|
||||
"""Describes an XPIDL module to be compiled."""
|
||||
|
||||
__slots__ = (
|
||||
'source_path',
|
||||
'basename',
|
||||
'module',
|
||||
'name',
|
||||
'idl_files',
|
||||
)
|
||||
|
||||
def __init__(self, context, source, module):
|
||||
def __init__(self, context, name, idl_files):
|
||||
ContextDerived.__init__(self, context)
|
||||
|
||||
assert isinstance(source, SourcePath)
|
||||
self.source_path = source
|
||||
self.basename = mozpath.basename(source)
|
||||
self.module = module
|
||||
assert all(isinstance(idl, SourcePath) for idl in idl_files)
|
||||
self.name = name
|
||||
self.idl_files = idl_files
|
||||
|
||||
class BaseDefines(ContextDerived):
|
||||
"""Context derived container object for DEFINES/HOST_DEFINES,
|
||||
|
|
|
@ -72,7 +72,7 @@ from .data import (
|
|||
TestManifest,
|
||||
UnifiedSources,
|
||||
VariablePassthru,
|
||||
XPIDLFile,
|
||||
XPIDLModule,
|
||||
)
|
||||
from mozpack.chrome.manifest import (
|
||||
Manifest,
|
||||
|
@ -1371,15 +1371,17 @@ class TreeMetadataEmitter(LoggingMixin):
|
|||
# XPIDL_MODULE.
|
||||
xpidl_module = context['XPIDL_MODULE']
|
||||
|
||||
if context['XPIDL_SOURCES'] and not xpidl_module:
|
||||
raise SandboxValidationError('XPIDL_MODULE must be defined if '
|
||||
'XPIDL_SOURCES is defined.', context)
|
||||
if not xpidl_module:
|
||||
if context['XPIDL_SOURCES']:
|
||||
raise SandboxValidationError('XPIDL_MODULE must be defined if '
|
||||
'XPIDL_SOURCES is defined.', context)
|
||||
return
|
||||
|
||||
if xpidl_module and not context['XPIDL_SOURCES']:
|
||||
if not context['XPIDL_SOURCES']:
|
||||
raise SandboxValidationError('XPIDL_MODULE cannot be defined '
|
||||
'unless there are XPIDL_SOURCES', context)
|
||||
|
||||
if context['XPIDL_SOURCES'] and context['DIST_INSTALL'] is False:
|
||||
if context['DIST_INSTALL'] is False:
|
||||
self.log(logging.WARN, 'mozbuild_warning', dict(
|
||||
path=context.main_path),
|
||||
'{path}: DIST_INSTALL = False has no effect on XPIDL_SOURCES.')
|
||||
|
@ -1389,7 +1391,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
|||
raise SandboxValidationError('File %s from XPIDL_SOURCES '
|
||||
'does not exist' % idl.full_path, context)
|
||||
|
||||
yield XPIDLFile(context, idl, xpidl_module)
|
||||
yield XPIDLModule(context, xpidl_module, context['XPIDL_SOURCES'])
|
||||
|
||||
def _process_generated_files(self, context):
|
||||
for path in context['CONFIGURE_DEFINE_FILES']:
|
||||
|
|
Загрузка…
Ссылка в новой задаче