Bug 950370 - Capture WebIDL example interfaces in moz.build; r=glandium

Previously, the set of WebIDL example interfaces to build was hardcoded
in the mozwebidlcodegen Python package. Unfortunately, the example
interfaces in that set were dependent on test-only bindings files,
resulting in build failures when tests were disabled (because those
test-only bindings were defined in a test directory).

In this patch, we now declare example interfaces in moz.build files
so the set of example interfaces lives next to the set of defined
bindings files. The example interfaces are defined in a test moz.build
file - in the same file declaring the bindings files that contain the
interfaces - so the example interfaces only get picked up if the
corresponding bindings are defined.

We could probably switch WebIDL moz.build variables to use lists with
flags. That would be good followup fodder. For now, let's fix the build.

--HG--
extra : rebase_source : 00070a6d560625bc84ab9b10d6848ea037f8f5ed
extra : amend_source : 0890ecef444ba58533fcfaa333773d78deafd7f3
This commit is contained in:
Gregory Szorc 2013-12-15 11:43:47 -08:00
parent 0b806c9170
commit c2b654599f
8 changed files with 45 additions and 14 deletions

View File

@ -146,23 +146,17 @@ class WebIDLCodegenManager(LoggingMixin):
'UnionTypes.cpp',
}
# Example interfaces to build along with the tree. Other example
# interfaces will need to be generated manually.
BUILD_EXAMPLE_INTERFACES = {
'TestExampleInterface',
'TestExampleProxyInterface',
}
def __init__(self, config_path, inputs, exported_header_dir,
codegen_dir, state_path, cache_dir=None, make_deps_path=None,
make_deps_target=None):
"""Create an instance that manages WebIDLs in the build system.
config_path refers to a WebIDL config file (e.g. Bindings.conf).
inputs is a 3-tuple describing the input .webidl files and how to
inputs is a 4-tuple describing the input .webidl files and how to
process them. Members are:
(set(.webidl files), set(basenames of exported files),
set(basenames of generated events files))
set(basenames of generated events files),
set(example interface names))
exported_header_dir and codegen_dir are directories where generated
files will be written to.
@ -175,12 +169,13 @@ class WebIDLCodegenManager(LoggingMixin):
"""
self.populate_logger()
input_paths, exported_stems, generated_events_stems = inputs
input_paths, exported_stems, generated_events_stems, example_interfaces = inputs
self._config_path = config_path
self._input_paths = set(input_paths)
self._exported_stems = set(exported_stems)
self._generated_events_stems = set(generated_events_stems)
self._example_interfaces = set(example_interfaces)
self._exported_header_dir = exported_header_dir
self._codegen_dir = codegen_dir
self._state_path = state_path
@ -283,7 +278,7 @@ class WebIDLCodegenManager(LoggingMixin):
)
# Process some special interfaces required for testing.
for interface in self.BUILD_EXAMPLE_INTERFACES:
for interface in self._example_interfaces:
written = self.generate_example_files(interface)
result.created |= written[0]
result.updated |= written[1]
@ -446,7 +441,7 @@ class WebIDLCodegenManager(LoggingMixin):
stem, binding_stem, is_event, header_dir, files = self._binding_info(p)
paths |= {f for f in files if f}
for interface in self.BUILD_EXAMPLE_INTERFACES:
for interface in self._example_interfaces:
for p in self._example_paths(interface):
paths.add(p)
@ -533,7 +528,7 @@ def create_build_system_manager(topsrcdir, topobjdir, dist_dir):
files = json.load(fh)
inputs = (files['webidls'], files['exported_stems'],
files['generated_events_stems'])
files['generated_events_stems'], files['example_interfaces'])
cache_dir = os.path.join(obj_dir, '_cache')
try:

View File

@ -65,7 +65,8 @@ class TestWebIDLCodegenManager(unittest.TestCase):
inputs = (
ip,
{mozpath.splitext(mozpath.basename(p))[0] for p in ip},
set()
set(),
set(),
)
return dict(

View File

@ -26,6 +26,11 @@ PREPROCESSED_TEST_WEBIDL_FILES += [
'TestJSImplGen.webidl',
]
WEBIDL_EXAMPLE_INTERFACES += [
'TestExampleInterface',
'TestExampleProxyInterface',
]
LOCAL_INCLUDES += [
'/dom/bindings',
'/js/xpconnect/src',

View File

@ -14,6 +14,7 @@ from .base import BuildBackend
from ..frontend.data import (
ConfigFileSubstitution,
ExampleWebIDLInterface,
HeaderFileSubstitution,
GeneratedEventWebIDLFile,
GeneratedWebIDLFile,
@ -70,6 +71,7 @@ class WebIDLCollection(object):
self.preprocessed_sources = set()
self.test_sources = set()
self.preprocessed_test_sources = set()
self.example_interfaces = set()
def all_regular_sources(self):
return self.sources | self.generated_sources | \
@ -215,6 +217,9 @@ class CommonBackend(BuildBackend):
self._webidls.preprocessed_sources.add(mozpath.join(
obj.srcdir, obj.basename))
elif isinstance(obj, ExampleWebIDLInterface):
self._webidls.example_interfaces.add(obj.name)
else:
return

View File

@ -1135,6 +1135,7 @@ class RecursiveMakeBackend(CommonBackend):
webidls=sorted(all_inputs),
generated_events_stems=sorted(generated_events_stems),
exported_stems=sorted(exported_stems),
example_interfaces=sorted(webidls.example_interfaces),
)
file_lists = mozpath.join(bindings_dir, 'file-lists.json')

View File

@ -289,6 +289,20 @@ class GeneratedWebIDLFile(SandboxDerived):
self.basename = path
class ExampleWebIDLInterface(SandboxDerived):
"""An individual WebIDL interface to generate."""
__slots__ = (
'name',
)
def __init__(self, sandbox, name):
SandboxDerived.__init__(self, sandbox)
self.name = name
class BaseProgram(SandboxDerived):
"""Sandbox container object for programs, which is a unicode string.

View File

@ -24,6 +24,7 @@ from .data import (
GeneratedEventWebIDLFile,
GeneratedInclude,
GeneratedWebIDLFile,
ExampleWebIDLInterface,
HeaderFileSubstitution,
HostProgram,
HostSimpleProgram,
@ -321,6 +322,7 @@ class TreeMetadataEmitter(LoggingMixin):
('PREPROCESSED_WEBIDL_FILES', PreprocessedWebIDLFile),
('TEST_WEBIDL_FILES', TestWebIDLFile),
('WEBIDL_FILES', WebIDLFile),
('WEBIDL_EXAMPLE_INTERFACES', ExampleWebIDLInterface),
]
for sandbox_var, klass in simple_lists:
for name in sandbox.get(sandbox_var, []):

View File

@ -502,6 +502,14 @@ VARIABLES = {
These will be preprocessed before being parsed and converted.
""", 'export'),
'WEBIDL_EXAMPLE_INTERFACES': (StrictOrderingOnAppendList, list,
"""Names of example WebIDL interfaces to build as part of the build.
Names in this list correspond to WebIDL interface names defined in
WebIDL files included in the build from one of the \*WEBIDL_FILES
variables.
""", 'export'),
# Test declaration.
'A11Y_MANIFESTS': (StrictOrderingOnAppendList, list,
"""List of manifest files defining a11y tests.