29"""Compile an .idl file to Dart bindings (.h and .cpp files).
34from optparse
import OptionParser
38dart_script_path = os.path.dirname(os.path.abspath(__file__))
39script_path = os.path.join(
40 os.path.dirname(os.path.dirname(dart_script_path)),
'scripts')
41sys.path.extend([script_path])
43from dart_compiler
import IdlCompiler
44from code_generator_dart
import CodeGeneratorDart
48 parser = OptionParser()
49 parser.add_option(
'--output-directory')
50 parser.add_option(
'--interfaces-info-file')
51 parser.add_option(
'--write-file-only-if-changed', type=
'int', default=
'1')
52 parser.add_option(
'--generate-global', type=
'int')
55 parser.disable_interspersed_args()
57 options, args = parser.parse_args()
58 if options.output_directory
is None:
59 parser.error(
'Must specify output directory using --output-directory.')
60 options.write_file_only_if_changed = bool(
61 options.write_file_only_if_changed)
62 options.generate_global = bool(options.generate_global)
66 idl_filename = os.path.realpath(args[0])
67 return options, idl_filename
71 basename = os.path.basename(idl_filename)
72 interface_name, _ = os.path.splitext(basename)
79 IdlCompiler.__init__(self, *args, **kwargs)
90 'Dart%s.h' % interface_name)
92 'Dart%s.cpp' % interface_name)
94 (header_filename, cpp_filename))
98 'DartWebkitClassIds.h')
100 'DartWebkitClassIds.cpp')
102 global_cpp_filename))
108 if options.generate_global:
110 options.output_directory,
111 interfaces_info_filename=options.interfaces_info_file,
112 only_if_changed=options.write_file_only_if_changed)
113 idl_compiler.generate_global()
116 options.output_directory,
117 interfaces_info_filename=options.interfaces_info_file,
118 only_if_changed=options.write_file_only_if_changed)
119 idl_compiler.compile_file(idl_filename)
122if __name__ ==
'__main__':
def compile_file(self, idl_filename)
def __init__(self, *args, **kwargs)
def generate_global(self)
def compile_and_write(self, idl_filename, output_filenames)
def generate_global_and_write(self, output_filenames)
def idl_filename_to_interface_name(idl_filename)