Index: Source/bindings/scripts/idl_compiler.py |
diff --git a/Source/bindings/scripts/idl_compiler.py b/Source/bindings/scripts/idl_compiler.py |
index 1748c12bd705b559e017a4fa769daf02c5b85dff..3d8df7e189c6dd331beecaeb37ed8869afc59b8e 100755 |
--- a/Source/bindings/scripts/idl_compiler.py |
+++ b/Source/bindings/scripts/idl_compiler.py |
@@ -41,18 +41,20 @@ We will temporarily have two build flows (see ../derived_sources.gyp): |
We will move IDL files from the Perl build flow [1] to the Python build flow [2] |
incrementally. See http://crbug.com/239771 |
""" |
+import pickle |
haraken
2013/07/16 14:17:51
Nit: alphabetical order please.
Nils Barth (inactive)
2013/07/17 12:05:09
Oops, fixed.
|
import optparse |
import os |
import shlex |
import sys |
-import idl_reader |
import code_generator_v8 |
+import idl_reader |
def parse_options(): |
parser = optparse.OptionParser() |
parser.add_option('--additional-idl-files') |
+ parser.add_option('--dump-json-and-pickle', action='store_true', default=False) |
parser.add_option('--idl-attributes-file') |
parser.add_option('--include', dest='idl_directories', action='append') |
parser.add_option('--output-directory') |
@@ -75,6 +77,19 @@ def parse_options(): |
return options |
+def write_json_and_pickle(definitions, interface_name, output_directory): |
haraken
2013/07/16 14:17:51
I'm OK with leaving this option until you finish m
Nils Barth (inactive)
2013/07/17 12:05:09
(As above.) Done.
|
+ json_string = definitions.to_json() |
+ json_basename = interface_name + '.json' |
+ json_filename = os.path.join(output_directory, json_basename) |
+ with open(json_filename, 'w') as json_file: |
+ json_file.write(json_string) |
+ # Pickle export (for Koji) |
haraken
2013/07/16 14:17:51
Nit: Remove this comment.
Nils Barth (inactive)
2013/07/17 12:05:09
Done.
|
+ pickle_basename = interface_name + '.pkl' |
+ pickle_filename = os.path.join(output_directory, pickle_basename) |
+ with open(pickle_filename, 'wb') as pickle_file: |
+ pickle.dump(definitions, pickle_file) |
+ |
+ |
def main(): |
options = parse_options() |
idl_filename = options.idl_filename |
@@ -84,18 +99,20 @@ def main(): |
if verbose: |
print idl_filename |
- idl_definitions = idl_reader.read_idl_definitions(idl_filename, options.interface_dependencies_file, options.additional_idl_files) |
- # FIXME: add parameters when add validator |
- # idl_definitions = idl_reader.read_idl_interface(idl_filename, options.interface_dependencies_file, options.additional_idl_files, options.idl_attributes_file, verbose=verbose) |
- if not idl_definitions: |
+ definitions = idl_reader.read_idl_definitions(idl_filename, options.interface_dependencies_file, options.additional_idl_files, options.idl_attributes_file, verbose=options.verbose) |
+ if not definitions: |
# We generate dummy .h and .cpp files just to tell build scripts |
# that outputs have been created. |
code_generator_v8.generate_dummy_header_and_cpp(interface_name, options.output_directory) |
return |
+ if options.dump_json_and_pickle: |
+ write_json_and_pickle(definitions, interface_name, options.output_directory) |
+ return |
# FIXME: turn on code generator |
- # Currently idl_definitions must be None (so dummy .h and .cpp files are |
- # generated), as actual code generator not present yet. |
- # code_generator_v8.write_interface(idl_definitions, interface_name, options.output_directory) |
+ # Currently definitions must be None (so dummy .h and .cpp files are |
+ # generated), or --dump-json-and-pickle selected, as actual code generator |
+ # not present yet. |
+ # code_generator_v8.write_interface(definitions, interface_name, options.output_directory) |
raise RuntimeError('Stub: code generator not implemented yet') |