Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Unified Diff: Source/bindings/scripts/compute_dependencies.py

Issue 24053003: Support partial interface for test support idls (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/scripts/compute_dependencies.py
diff --git a/Source/bindings/scripts/compute_dependencies.py b/Source/bindings/scripts/compute_dependencies.py
index 816b5b237dab754b87f9915967abad33fb62d5bd..0d9139c50d264e28cedb1aa51298e2f45b010ad1 100755
--- a/Source/bindings/scripts/compute_dependencies.py
+++ b/Source/bindings/scripts/compute_dependencies.py
@@ -50,6 +50,8 @@ def parse_options():
parser.add_option('--event-names-file', help='output file')
parser.add_option('--idl-files-list', help='file listing all IDLs')
parser.add_option('--interface-dependencies-file', help='output file')
+ parser.add_option('--test-support-idl-files-list', help='file listing all test support IDLs')
+ parser.add_option('--test-support-interface-dependencies-file', help='output file')
parser.add_option('--window-constructors-file', help='output file')
parser.add_option('--workerglobalscope-constructors-file', help='output file')
parser.add_option('--sharedworkerglobalscope-constructors-file', help='output file')
@@ -60,6 +62,8 @@ def parse_options():
parser.error('Must specify an output file using --event-names-file.')
if options.interface_dependencies_file is None:
parser.error('Must specify an output file using --interface-dependencies-file.')
+ if options.test_support_interface_dependencies_file is None:
+ parser.error('Must specify an output file using --test-support-interface-dependencies-file')
if options.window_constructors_file is None:
parser.error('Must specify an output file using --window-constructors-file.')
if options.workerglobalscope_constructors_file is None:
@@ -70,6 +74,8 @@ def parse_options():
parser.error('Must specify an output file using --dedicatedworkerglobalscope-constructors-file.')
if options.idl_files_list is None:
parser.error('Must specify the file listing all IDLs using --idl-files-list.')
+ if options.test_support_idl_files_list is None:
+ parser.error('Must specify the file listing all IDLs using --test-support-idl-files-list.')
if options.write_file_only_if_changed is None:
parser.error('Must specify whether file is only written if changed using --write-file-only-if-changed.')
options.write_file_only_if_changed = bool(options.write_file_only_if_changed)
@@ -200,38 +206,16 @@ def generate_global_constructors_partial_interface(interface_name, destination_f
write_file(lines, destination_filename, only_if_changed)
-def parse_idl_files(idl_files, global_constructors_filenames):
- """Return dependencies between IDL files, constructors on global objects, and events.
-
- Returns:
- interfaces:
- set of all interfaces
- dependencies:
- dict of main IDL filename (for a given interface) -> list of partial IDL filenames (for that interface)
- The keys (main IDL files) are the files for which bindings are
- generated. This does not include IDL files for interfaces
- implemented by another interface.
- global_constructors:
- dict of global objects -> list of constructors on that object
- event_names:
- dict of interfaces that inherit from Event -> list of extended attributes for the interface
- """
- interfaces = set()
- dependencies = {}
- partial_interface_files = {}
- implements_interfaces = {}
- implemented_somewhere = set()
-
- global_constructors = {}
- for global_object in global_constructors_filenames.keys():
- global_constructors[global_object] = []
-
- # Parents and extended attributes (of interfaces with parents) are
- # used in generating event names
- parent_interface = {}
- interface_extended_attribute = {}
-
- interface_name_to_idl_file = {}
+def generate_interface_name_to_idl_file(idl_files,
+ interface_name_to_idl_file,
+ partial_interface_files,
+ interfaces,
+ dependencies,
+ implements_interfaces,
+ implemented_somewhere,
+ global_constructors,
+ parent_interface,
+ interface_extended_attribute):
for idl_file_name in idl_files:
full_path = os.path.realpath(idl_file_name)
interface_name, _ = os.path.splitext(os.path.basename(idl_file_name))
@@ -260,11 +244,12 @@ def parse_idl_files(idl_files, global_constructors_filenames):
implemented_somewhere |= set(implemented_interfaces)
# Record global constructors
- if not is_callback_interface_from_idl(idl_file_contents) and 'NoInterfaceObject' not in extended_attributes:
- global_contexts = extended_attributes.get('GlobalContext', 'Window').split('&')
- new_constructor_list = generate_constructor_attribute_list(interface_name, extended_attributes)
- for global_object in global_contexts:
- global_constructors[global_object].extend(new_constructor_list)
+ if global_constructors:
+ if not is_callback_interface_from_idl(idl_file_contents) and 'NoInterfaceObject' not in extended_attributes:
+ global_contexts = extended_attributes.get('GlobalContext', 'Window').split('&')
+ new_constructor_list = generate_constructor_attribute_list(interface_name, extended_attributes)
+ for global_object in global_contexts:
+ global_constructors[global_object].extend(new_constructor_list)
# Record parents and extended attributes for generating event names
if interface_name == 'Event':
@@ -274,10 +259,80 @@ def parse_idl_files(idl_files, global_constructors_filenames):
parent_interface[interface_name] = parent
interface_extended_attribute[interface_name] = extended_attributes
+
+def parse_idl_files(idl_files, test_support_idl_files, global_constructors_filenames):
+ """Return dependencies between IDL files, constructors on global objects, and events.
+
+ Returns:
+ interfaces:
+ set of all interfaces
+ dependencies:
+ dict of main IDL filename (for a given interface) -> list of partial IDL filenames (for that interface)
+ The keys (main IDL files) are the files for which bindings are
+ generated. This does not include IDL files for interfaces
+ implemented by another interface.
+ test_support_dependencies:
+ dict of test support IDL filename (for a given interface) -> list of partial IDL filenames (for that interface)
+ The keys (main IDL files) are the files for which bindings are
+ generated. This does not include IDL files for interfaces
+ implemented by another interface.
+ global_constructors:
+ dict of global objects -> list of constructors on that object
+ event_names:
+ dict of interfaces that inherit from Event -> list of extended attributes for the interface
+ """
+ interfaces = set()
+ dependencies = {}
+ partial_interface_files = {}
+ implements_interfaces = {}
+ implemented_somewhere = set()
+
+ test_support_interfaces = set()
+ test_support_dependencies = {}
+ test_support_partial_interface_files = {}
+ test_support_implements_interfaces = {}
+ test_support_implemented_somewhere = set()
+
+ global_constructors = {}
+ for global_object in global_constructors_filenames.keys():
+ global_constructors[global_object] = []
+
+ # Parents and extended attributes (of interfaces with parents) are
+ # used in generating event names
+ parent_interface = {}
+ interface_extended_attribute = {}
+
+ interface_name_to_idl_file = {}
+ generate_interface_name_to_idl_file(idl_files,
+ interface_name_to_idl_file,
+ partial_interface_files,
+ interfaces,
+ dependencies,
+ implements_interfaces,
+ implemented_somewhere,
+ global_constructors,
+ parent_interface,
+ interface_extended_attribute)
+
+ test_support_interface_name_to_idl_file = {}
+ generate_interface_name_to_idl_file(test_support_idl_files,
+ test_support_interface_name_to_idl_file,
+ test_support_partial_interface_files,
+ test_support_interfaces,
+ test_support_dependencies,
+ test_support_implements_interfaces,
+ test_support_implemented_somewhere,
+ None,
+ parent_interface,
+ interface_extended_attribute)
+
# Add constructors on global objects to partial interfaces
+
for global_object, filename in global_constructors_filenames.iteritems():
if global_object in interfaces:
partial_interface_files[global_object].append(filename)
+ if global_object in test_support_interfaces:
do-not-use 2013/09/09 07:27:10 elif?
Nils Barth (inactive) 2013/09/10 09:52:10 I'm actually confused about whether we want to be
+ test_support_partial_interface_files[global_object].append(filename)
# Interfaces that are implemented by another interface do not have
# their own bindings generated, as this would be redundant with the
@@ -286,6 +341,10 @@ def parse_idl_files(idl_files, global_constructors_filenames):
full_path = interface_name_to_idl_file[implemented_interface]
del dependencies[full_path]
+ for test_support_implemented_interface in test_support_implemented_somewhere:
+ full_path = test_support_interface_name_to_idl_file[test_support_implemented_interface]
+ del test_support_dependencies[full_path]
+
# An IDL file's dependencies are partial interface files that extend it,
# and files for other interfaces that this interfaces implements.
for idl_file_path in dependencies.iterkeys():
@@ -297,6 +356,15 @@ def parse_idl_files(idl_files, global_constructors_filenames):
raise IdlInterfaceFileNotFoundError('Could not find the IDL file where the following implemented interface is defined: %s' % key_name)
dependencies[idl_file_path] = sorted(partial_interface_files[interface_name] + interface_paths)
+ for test_support_idl_file_path in test_support_dependencies.iterkeys():
+ interface_name, _ = os.path.splitext(os.path.basename(test_support_idl_file_path))
+ test_support_implemented_interfaces = test_support_implements_interfaces[interface_name]
+ try:
+ interface_paths = map(lambda x: test_support_interface_name_to_idl_file[x], test_support_implemented_interfaces)
+ except KeyError, key_name:
+ raise IdlInterfaceFileNotFoundError('Could not find the IDL file where the following implemented interface is defined: %s' % key_name)
+ test_support_dependencies[test_support_idl_file_path] = sorted(test_support_partial_interface_files[interface_name] + interface_paths)
+
# Generate event names for all interfaces that inherit from Event,
# including Event itself.
event_names = {}
@@ -308,7 +376,7 @@ def parse_idl_files(idl_files, global_constructors_filenames):
if parent == 'Event':
event_names[interface_name_to_idl_file[interface]] = interface_extended_attribute[interface]
- return interfaces, dependencies, global_constructors, event_names
+ return interfaces, dependencies, test_support_dependencies, global_constructors, event_names
def write_dependency_file(filename, dependencies, only_if_changed):
@@ -334,12 +402,17 @@ def write_dependency_file(filename, dependencies, only_if_changed):
write_file(lines, filename, only_if_changed)
+
def main():
options = parse_options()
idl_files = []
with open(options.idl_files_list) as idl_files_list_file:
for line in idl_files_list_file:
idl_files.append(string.rstrip(line, '\n'))
+ test_support_idl_files = []
+ with open(options.test_support_idl_files_list) as test_support_idl_files_list_file:
+ for line in test_support_idl_files_list_file:
+ test_support_idl_files.append(string.rstrip(line, '\n'))
only_if_changed = options.write_file_only_if_changed
global_constructors_filenames = {
'Window': options.window_constructors_file,
@@ -348,9 +421,10 @@ def main():
'DedicatedWorkerGlobalScope': options.dedicatedworkerglobalscope_constructors_file,
}
- interfaces, dependencies, global_constructors, event_names = parse_idl_files(idl_files, global_constructors_filenames)
+ interfaces, dependencies, test_support_dependencies, global_constructors, event_names = parse_idl_files(idl_files, test_support_idl_files, global_constructors_filenames)
write_dependency_file(options.interface_dependencies_file, dependencies, only_if_changed)
+ write_dependency_file(options.test_support_interface_dependencies_file, test_support_dependencies, only_if_changed)
for interface_name, filename in global_constructors_filenames.iteritems():
if interface_name in interfaces:
generate_global_constructors_partial_interface(interface_name, filename, global_constructors[interface_name], only_if_changed)

Powered by Google App Engine
This is Rietveld 408576698