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

Unified Diff: sky/engine/bindings-dart/dart/scripts/dart_compiler.py

Issue 875013003: Import Dart bindings as of Blink r188698. This merely copies the files over and does not attach any… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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: sky/engine/bindings-dart/dart/scripts/dart_compiler.py
diff --git a/sky/engine/bindings/scripts/idl_compiler.py b/sky/engine/bindings-dart/dart/scripts/dart_compiler.py
similarity index 55%
copy from sky/engine/bindings/scripts/idl_compiler.py
copy to sky/engine/bindings-dart/dart/scripts/dart_compiler.py
index 23c0bcceaf3995ab483953a9c7d02be16e5a4ea1..35357b3abfeb1f0f958f5e830364465c5a2403d9 100755
--- a/sky/engine/bindings/scripts/idl_compiler.py
+++ b/sky/engine/bindings-dart/dart/scripts/dart_compiler.py
@@ -27,7 +27,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-"""Compile an .idl file to Blink V8 bindings (.h and .cpp files).
+"""Compile an .idl file to Blink C++ bindings (.h and .cpp files) for Dart:HTML.
Design doc: http://www.chromium.org/developers/design-documents/idl-compiler
"""
@@ -36,19 +36,20 @@ import abc
from optparse import OptionParser
import os
import cPickle as pickle
-import sys
-from code_generator_v8 import CodeGeneratorDictionaryImpl, CodeGeneratorV8
from idl_reader import IdlReader
-from utilities import read_idl_files_list_from_file, write_file
+from utilities import write_file
+
+
+# TODO(terry): Temporary whitelist of IDL files to skip code generating. e.g.,
+# adding 'Animation.idl' to this list will skip that IDL file.
+SKIP_IDL_FILES = ['']
def parse_options():
parser = OptionParser()
- parser.add_option('--cache-directory',
- help='cache directory, defaults to output directory')
- parser.add_option('--generate-dictionary-impl',
- action="store_true", default=False)
+ parser.add_option('--idl-attributes-file',
+ help="location of bindings/IDLExtendedAttributes.txt")
parser.add_option('--output-directory')
parser.add_option('--interfaces-info-file')
parser.add_option('--write-file-only-if-changed', type='int')
@@ -81,9 +82,9 @@ class IdlCompiler(object):
"""
__metaclass__ = abc.ABCMeta
- def __init__(self, output_directory, cache_directory='',
- code_generator=None, interfaces_info=None,
- interfaces_info_filename='', only_if_changed=False):
+ def __init__(self, output_directory, code_generator=None,
+ interfaces_info=None, interfaces_info_filename='',
+ only_if_changed=False):
"""
Args:
interfaces_info:
@@ -91,82 +92,43 @@ class IdlCompiler(object):
(avoids auxiliary file in run-bindings-tests)
interfaces_info_file: filename of pickled interfaces_info
"""
- cache_directory = cache_directory or output_directory
- self.cache_directory = cache_directory
self.code_generator = code_generator
if interfaces_info_filename:
with open(interfaces_info_filename) as interfaces_info_file:
interfaces_info = pickle.load(interfaces_info_file)
self.interfaces_info = interfaces_info
+
self.only_if_changed = only_if_changed
self.output_directory = output_directory
- self.reader = IdlReader(interfaces_info, cache_directory)
+ self.reader = IdlReader(interfaces_info, output_directory)
- def compile_and_write(self, idl_filename):
+ def compile_and_write(self, idl_filename, output_filenames):
interface_name = idl_filename_to_interface_name(idl_filename)
+ idl_pickle_filename = os.path.join(self.output_directory,
+ '%s_globals.pickle' % interface_name)
definitions = self.reader.read_idl_definitions(idl_filename)
- output_code_list = self.code_generator.generate_code(
- definitions, interface_name)
- for output_path, output_code in output_code_list:
- write_file(output_code, output_path, self.only_if_changed)
+ output_code_list = self.code_generator.generate_code(definitions,
+ interface_name,
+ idl_pickle_filename,
+ self.only_if_changed)
+
+ # TODO(terry): Temporary to disable code generating an IDL.
+ base_idl_filename = os.path.basename(idl_filename)
+ if base_idl_filename in SKIP_IDL_FILES:
+ print "----- Skipping %s -----" % base_idl_filename
+ else:
+ for output_code, output_filename in zip(output_code_list, output_filenames):
+ write_file(output_code, output_filename, self.only_if_changed)
+
+ def generate_global_and_write(self, global_entries, output_filenames):
+ output_code_list = self.code_generator.generate_globals(global_entries)
+ for output_code, output_filename in zip(output_code_list, output_filenames):
+ write_file(output_code, output_filename, self.only_if_changed)
+
+ def generate_dart_blink_and_write(self, global_entries, output_filename):
+ output_code = self.code_generator.generate_dart_blink(global_entries)
+ write_file(output_code, output_filename, self.only_if_changed)
@abc.abstractmethod
def compile_file(self, idl_filename):
pass
-
-
-class IdlCompilerV8(IdlCompiler):
- def __init__(self, *args, **kwargs):
- IdlCompiler.__init__(self, *args, **kwargs)
- self.code_generator = CodeGeneratorV8(self.interfaces_info,
- self.cache_directory,
- self.output_directory)
-
- def compile_file(self, idl_filename):
- self.compile_and_write(idl_filename)
-
-
-class IdlCompilerDictionaryImpl(IdlCompiler):
- def __init__(self, *args, **kwargs):
- IdlCompiler.__init__(self, *args, **kwargs)
- self.code_generator = CodeGeneratorDictionaryImpl(
- self.interfaces_info, self.cache_directory, self.output_directory)
-
- def compile_file(self, idl_filename):
- self.compile_and_write(idl_filename)
-
-
-def generate_bindings(options, input_filename):
- idl_compiler = IdlCompilerV8(
- options.output_directory,
- cache_directory=options.cache_directory,
- interfaces_info_filename=options.interfaces_info_file,
- only_if_changed=options.write_file_only_if_changed)
- idl_compiler.compile_file(input_filename)
-
-
-def generate_dictionary_impl(options, input_filename):
- idl_compiler = IdlCompilerDictionaryImpl(
- options.output_directory,
- cache_directory=options.cache_directory,
- interfaces_info_filename=options.interfaces_info_file,
- only_if_changed=options.write_file_only_if_changed)
-
- idl_filenames = read_idl_files_list_from_file(input_filename)
- for idl_filename in idl_filenames:
- idl_compiler.compile_file(idl_filename)
-
-
-def main():
- options, input_filename = parse_options()
- if options.generate_dictionary_impl:
- # |input_filename| should be a file which contains a list of IDL
- # dictionary paths.
- generate_dictionary_impl(options, input_filename)
- else:
- # |input_filename| should be a path of an IDL file.
- generate_bindings(options, input_filename)
-
-
-if __name__ == '__main__':
- sys.exit(main())

Powered by Google App Engine
This is Rietveld 408576698