Chromium Code Reviews| Index: Source/bindings/scripts/compute_dependencies.py |
| diff --git a/Source/bindings/scripts/compute_dependencies.py b/Source/bindings/scripts/compute_dependencies.py |
| index f7e0257e8507a03316f5f74de9b3089041bacfb5..ce6ba814dcf6cd3fbd805df7bdd489bd03e609e0 100755 |
| --- a/Source/bindings/scripts/compute_dependencies.py |
| +++ b/Source/bindings/scripts/compute_dependencies.py |
| @@ -75,7 +75,6 @@ def parse_options(): |
| parser.add_option('--event-names-file', help='output file') |
| parser.add_option('--idl-files-list', help='file listing IDL files') |
| parser.add_option('--interface-dependencies-file', help='output file') |
| - parser.add_option('--interfaces-info-file', help='output pickle file') |
|
Nils Barth (inactive)
2014/02/24 08:38:56
We need this separate file for the build, so could
terry
2014/02/27 23:40:26
Done.
Nils Barth (inactive)
2014/03/03 06:45:48
Just to clarify:
it's fine to not write Interfaces
|
| 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') |
| @@ -325,10 +324,8 @@ def add_paths_to_partials_dict(partial_interface_name, full_path, this_include_p |
| paths_dict['include_paths'].append(this_include_path) |
| -def generate_dependencies(idl_filename): |
| +def generate_dependencies(idl_filename, idl_full_path, idl_file_contents): |
| """Compute dependencies for IDL file, returning True if main (non-partial) interface""" |
| - full_path = os.path.realpath(idl_filename) |
| - idl_file_contents = get_file_contents(full_path) |
| extended_attributes = get_interface_extended_attributes_from_idl(idl_file_contents) |
| implemented_as = extended_attributes.get('ImplementedAs') |
| @@ -339,14 +336,14 @@ def generate_dependencies(idl_filename): |
| # Handle partial interfaces |
| partial_interface_name = get_partial_interface_name_from_idl(idl_file_contents) |
| if partial_interface_name: |
| - add_paths_to_partials_dict(partial_interface_name, full_path, this_include_path) |
| + add_paths_to_partials_dict(partial_interface_name, idl_full_path, this_include_path) |
| return False |
| # If not a partial interface, the basename is the interface name |
| interface_name, _ = os.path.splitext(os.path.basename(idl_filename)) |
| interfaces_info[interface_name] = { |
| - 'full_path': full_path, |
| + 'full_path': idl_full_path, |
| 'implements_interfaces': get_implemented_interfaces_from_idl(idl_file_contents, interface_name), |
| 'is_callback_interface': is_callback_interface_from_idl(idl_file_contents), |
| # Interfaces that are referenced (used as types) and that we introspect |
| @@ -392,10 +389,8 @@ def generate_constructor_attribute_list(interface_name, extended_attributes): |
| return attributes_list |
| -def record_global_constructors_and_extended_attributes(idl_filename, global_constructors): |
| +def record_global_constructors_and_extended_attributes(idl_filename, idl_file_contents, global_constructors): |
| interface_name, _ = os.path.splitext(os.path.basename(idl_filename)) |
| - full_path = os.path.realpath(idl_filename) |
| - idl_file_contents = get_file_contents(full_path) |
| extended_attributes = get_interface_extended_attributes_from_idl(idl_file_contents) |
| # Record extended attributes |
| @@ -475,9 +470,15 @@ def parse_idl_files(idl_files, global_constructors_filenames): |
| # Generate dependencies, and (for main IDL files), record |
| # global_constructors and extended_attributes_by_interface. |
| for idl_filename in idl_files: |
| + interface_name, _ = os.path.splitext(os.path.basename(idl_filename)) |
| + full_path = os.path.realpath(idl_filename) |
| + idl_file_contents = get_file_contents(full_path) |
| + |
| # Test skips partial interfaces |
| - if generate_dependencies(idl_filename): |
| - record_global_constructors_and_extended_attributes(idl_filename, global_constructors) |
| + if generate_dependencies(idl_filename, full_path, idl_file_contents): |
| + record_global_constructors_and_extended_attributes(idl_filename, |
| + idl_file_contents, |
| + global_constructors) |
| for interface_name in interfaces_info: |
| generate_ancestors_and_inherited_extended_attributes(interface_name) |
| @@ -520,6 +521,40 @@ def parse_idl_files(idl_files, global_constructors_filenames): |
| return global_constructors |
| +def clear_globals(): |
| + interfaces_info.clear() |
| + partial_interface_files.clear() |
| + parent_interfaces.clear() |
| + extended_attributes_by_interface.clear() # interface name -> extended attributes |
| + |
| + |
| +def compute(idl_files_list, interface_dependencies_file, |
| + window_constructors_file, workerglobalscope_constructors_file, |
| + sharedworkerglobalscope_constructors_file, |
| + dedicatedworkerglobalscope_constructors_file, |
| + serviceworkerglobalscope_constructors_file, |
| + event_names_file, only_if_changed): |
| + |
| + clear_globals() |
| + |
| + global_constructors_filenames = { |
| + 'Window': window_constructors_file, |
| + 'WorkerGlobalScope': workerglobalscope_constructors_file, |
| + 'SharedWorkerGlobalScope': sharedworkerglobalscope_constructors_file, |
| + 'DedicatedWorkerGlobalScope': dedicatedworkerglobalscope_constructors_file, |
| + 'ServiceWorkerGlobalScope': serviceworkerglobalscope_constructors_file, |
| + } |
| + |
| + global_constructors = parse_idl_files(idl_files_list, global_constructors_filenames) |
| + |
| + write_dependencies_file(interface_dependencies_file, only_if_changed) |
| + for interface_name, filename in global_constructors_filenames.iteritems(): |
| + if interface_name in interfaces_info: |
| + write_global_constructors_partial_interface(interface_name, filename, global_constructors[interface_name], only_if_changed) |
| + write_event_names_file(event_names_file, only_if_changed) |
| + return interfaces_info |
| + |
| + |
| ################################################################################ |
| def main(): |
| @@ -534,24 +569,15 @@ def main(): |
| # cannot be included in the file listing static files |
| idl_files.extend(args) |
| - only_if_changed = options.write_file_only_if_changed |
| - global_constructors_filenames = { |
| - 'Window': options.window_constructors_file, |
| - 'WorkerGlobalScope': options.workerglobalscope_constructors_file, |
| - 'SharedWorkerGlobalScope': options.sharedworkerglobalscope_constructors_file, |
| - 'DedicatedWorkerGlobalScope': options.dedicatedworkerglobalscope_constructors_file, |
| - 'ServiceWorkerGlobalScope': options.serviceworkerglobalscope_constructors_file, |
| - } |
| - |
| - global_constructors = parse_idl_files(idl_files, global_constructors_filenames) |
| - |
| - write_dependencies_file(options.interface_dependencies_file, only_if_changed) |
| - write_pickle_file(options.interfaces_info_file, interfaces_info, only_if_changed) |
| - for interface_name, filename in global_constructors_filenames.iteritems(): |
| - if interface_name in interfaces_info: |
| - write_global_constructors_partial_interface(interface_name, filename, global_constructors[interface_name], only_if_changed) |
| - write_event_names_file(options.event_names_file, only_if_changed) |
| - |
| + compute(idl_files, |
| + options.interface_dependencies_file, |
| + options.window_constructors_file, |
| + options.workerglobalscope_constructors_file, |
| + options.sharedworkerglobalscope_constructors_file, |
| + options.dedicatedworkerglobalscope_constructors_file, |
| + options.serviceworkerglobalscope_constructors_file, |
| + options.event_names_file, |
| + options.write_file_only_if_changed) |
| if __name__ == '__main__': |
| main() |