Chromium Code Reviews| Index: Tools/Scripts/webkitpy/bindings/main.py |
| diff --git a/Tools/Scripts/webkitpy/bindings/main.py b/Tools/Scripts/webkitpy/bindings/main.py |
| index 76467227bc687ba33c4a5c278321f74d856b6663..01a50c4faaff3f4431f04ef0a8585b9dd3cbfddd 100644 |
| --- a/Tools/Scripts/webkitpy/bindings/main.py |
| +++ b/Tools/Scripts/webkitpy/bindings/main.py |
| @@ -24,14 +24,26 @@ |
| import fnmatch |
| import os |
| -import cPickle as pickle |
| import shutil |
| +import sys |
| import tempfile |
| from webkitpy.common.checkout.scm.detection import detect_scm_system |
| from webkitpy.common.system import executive |
| from webkitpy.common.system.executive import ScriptError |
| +# Add Source path to PYTHONPATH to support function calls to bindings/scripts |
| +# for compute_dependencies and idl_compiler |
| +module_path = os.path.dirname(__file__) |
| +source_path = os.path.normpath(os.path.join(module_path, os.pardir, |
| + os.pardir, os.pardir, os.pardir, |
| + 'Source')) |
| +sys.path.append(source_path) |
| + |
| +from bindings.scripts.compute_interfaces_info import compute |
| +from bindings.scripts.idl_compiler import compile_idl |
| + |
| + |
| PASS_MESSAGE = 'All tests PASS!' |
| FAIL_MESSAGE = """Some tests FAIL! |
| To update the reference files, execute: |
| @@ -54,6 +66,9 @@ DEPENDENCY_IDL_FILES = set([ |
| 'TestPartialInterfacePython2.idl', |
| ]) |
| + |
| +EXTENDED_ATTRIBUTES_FILE = 'bindings/IDLExtendedAttributes.txt' |
| + |
| all_input_directory = '.' # Relative to Source/ |
| test_input_directory = os.path.join('bindings', 'tests', 'idls') |
| reference_directory = os.path.join('bindings', 'tests', 'results') |
| @@ -97,6 +112,7 @@ class BindingsTests(object): |
| self.verbose = verbose |
| self.executive = executive.Executive() |
| self.provider = provider |
| + self.reader = None |
|
Nils Barth (inactive)
2014/03/03 01:32:48
If we make the compiler an object, this becomes se
|
| _, self.interface_dependencies_filename = provider.new_temp_file() |
| _, self.interfaces_info_filename = provider.new_temp_file() |
| # Generate output into the reference directory if resetting results, or |
| @@ -113,18 +129,18 @@ class BindingsTests(object): |
| print output |
| def generate_from_idl(self, idl_file): |
| - cmd = ['python', |
| - 'bindings/scripts/idl_compiler.py', |
| - '--output-dir', self.output_directory, |
| - '--idl-attributes-file', 'bindings/IDLExtendedAttributes.txt', |
| - '--interfaces-info-file', self.interfaces_info_filename, |
| - idl_file] |
| try: |
| - self.run_command(cmd) |
| + idl_file_fullpath = os.path.realpath(idl_file) |
| + self.reader = compile_idl(idl_file_fullpath, |
| + self.output_directory, |
| + EXTENDED_ATTRIBUTES_FILE, |
| + self.interfaces_info_filename, |
| + True, self.reader) |
| except ScriptError, e: |
| print 'ERROR: idl_compiler.py: ' + os.path.basename(idl_file) |
| print e.output |
| return e.exit_code |
| + |
| return 0 |
| def generate_interface_dependencies(self): |
| @@ -147,27 +163,28 @@ class BindingsTests(object): |
| os.write(list_file, list_contents) |
| return list_filename |
| + # Faster in-memory file list. |
| + def list_idl_file(idl_paths): |
|
Nils Barth (inactive)
2014/03/03 01:32:48
This is unnecessary, right?
(It's just copying a l
|
| + idls = [] |
| + for idl_path in idl_paths: |
| + idls.append(idl_path) |
| + return idls |
| + |
| def compute_interfaces_info(idl_files_list_filename, |
|
Nils Barth (inactive)
2014/03/03 06:45:49
I'm simplifying this (remove EventInterfaces.in),
|
| event_names_filename): |
| - cmd = ['python', |
| - 'bindings/scripts/compute_interfaces_info.py', |
| - '--idl-files-list', idl_files_list_filename, |
| - '--interface-dependencies-file', self.interface_dependencies_filename, |
| - '--interfaces-info-file', self.interfaces_info_filename, |
| - '--event-names-file', event_names_filename, |
| - '--write-file-only-if-changed', '0'] |
| - self.run_command(cmd) |
| + compute(idl_files_list_filename, self.interfaces_info_filename, |
| + self.interface_dependencies_filename, |
| + event_names_filename, False) |
| - test_idl_files_list_filename = write_list_file(idl_paths(test_input_directory)) |
| - all_idl_files_list_filename = write_list_file(idl_paths_recursive(all_input_directory)) |
| + test_idl_files_list = list_idl_file(idl_paths(test_input_directory)) |
| + all_idl_files_list = list_idl_file(idl_paths_recursive(all_input_directory)) |
| if self.reset_results and self.verbose: |
| print 'Reset results: EventInterfaces.in' |
| try: |
| # We first compute interfaces info for testing files only, |
| # so we can compare EventInterfaces.in. |
| - compute_interfaces_info(test_idl_files_list_filename, |
| - self.event_names_filename) |
| + compute_interfaces_info(test_idl_files_list, self.event_names_filename) |
| # We then compute interfaces info for all IDL files, as code |
| # generator output depends on inheritance (both ancestor chain and |
| @@ -181,12 +198,12 @@ class BindingsTests(object): |
| # |
| # Don't overwrite the event names file generated for testing IDLs |
| _, dummy_event_names_filename = self.provider.new_temp_file() |
| - compute_interfaces_info(all_idl_files_list_filename, |
| - dummy_event_names_filename) |
| + compute_interfaces_info(all_idl_files_list, dummy_event_names_filename) |
| except ScriptError, e: |
| print 'ERROR: compute_interfaces_info.py' |
| print e.output |
| return e.exit_code |
| + |
| return 0 |
| def identical_file(self, reference_filename, output_filename): |
| @@ -253,8 +270,7 @@ class BindingsTests(object): |
| print 'Reset results: %s' % input_filename |
| # Detect all changes |
| - passed = self.identical_file(reference_event_names_filename, |
| - self.event_names_filename) |
| + passed = self.identical_file(reference_event_names_filename, self.event_names_filename) |
| passed &= self.identical_output_files() |
| passed &= self.no_excess_files() |
| return passed |