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

Unified Diff: tools/dom/scripts/dartdomgenerator.py

Issue 444743002: Use Blink IDL parser for dart libraries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merged Created 6 years, 3 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
« no previous file with comments | « tools/dom/scripts/__init__.py ('k') | tools/dom/scripts/dartgenerator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/scripts/dartdomgenerator.py
diff --git a/tools/dom/scripts/dartdomgenerator.py b/tools/dom/scripts/dartdomgenerator.py
index 89b5fe2331de9ea9d398d48dd7ede5137105b877..53b2132b77d034ff3866f3bb5f3062d3e8540019 100755
--- a/tools/dom/scripts/dartdomgenerator.py
+++ b/tools/dom/scripts/dartdomgenerator.py
@@ -6,6 +6,16 @@
"""This is the entry point to create Dart APIs from the IDL database."""
import css_code_generator
+import os
+import sys
+
+# Setup all paths to find our PYTHON code
+dart_dir = os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))
+sys.path.insert(1, os.path.join(dart_dir, 'tools/dom/new_scripts'))
+sys.path.insert(1, os.path.join(dart_dir, 'third_party/WebCore/bindings/scripts'))
+sys.path.insert(1, os.path.join(dart_dir, 'third_party'))
+sys.path.insert(1, os.path.join(dart_dir, 'tools/dom/scripts'))
+
import dartgenerator
import database
import fremontcutbuilder
@@ -13,10 +23,9 @@ import logging
import monitored
import multiemitter
import optparse
-import os
import shutil
import subprocess
-import sys
+import time
from dartmetadata import DartMetadata
from generator import TypeRegistry
from htmleventgenerator import HtmlEventGenerator
@@ -29,8 +38,10 @@ from systemnative import CPPLibraryEmitter, DartiumBackend, \
from templateloader import TemplateLoader
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
+
import utils
+
_logger = logging.getLogger('dartdomgenerator')
class GeneratorOptions(object):
@@ -51,12 +62,17 @@ def LoadDatabase(database_dir, use_database_cache):
return common_database
def GenerateFromDatabase(common_database, dart2js_output_dir,
- dartium_output_dir, update_dom_metadata=False):
+ dartium_output_dir, update_dom_metadata=False,
+ logging_level=logging.WARNING):
+ start_time = time.time()
+
current_dir = os.path.dirname(__file__)
auxiliary_dir = os.path.join(current_dir, '..', 'src')
template_dir = os.path.join(current_dir, '..', 'templates')
- generator = dartgenerator.DartGenerator()
+ _logger.setLevel(logging_level)
+
+ generator = dartgenerator.DartGenerator(logging_level)
generator.LoadAuxiliary(auxiliary_dir)
generator.FilterMembersWithUnidentifiedTypes(common_database)
@@ -70,13 +86,16 @@ def GenerateFromDatabase(common_database, dart2js_output_dir,
generator.FixEventTargets(webkit_database)
generator.AddMissingArguments(webkit_database)
- emitters = multiemitter.MultiEmitter()
+ emitters = multiemitter.MultiEmitter(logging_level)
metadata = DartMetadata(
os.path.join(current_dir, '..', 'dom.json'),
- os.path.join(current_dir, '..', 'docs', 'docs.json'))
+ os.path.join(current_dir, '..', 'docs', 'docs.json'),
+ logging_level)
renamer = HtmlRenamer(webkit_database, metadata)
type_registry = TypeRegistry(webkit_database, renamer)
+ print 'GenerateFromDatabase %s seconds' % round((time.time() - start_time), 2)
+
def RunGenerator(dart_libraries, dart_output_dir,
template_loader, backend_factory):
options = GeneratorOptions(
@@ -106,14 +125,19 @@ def GenerateFromDatabase(common_database, dart2js_output_dir,
template_loader, webkit_database, type_registry, renamer,
metadata)
backend_factory = lambda interface:\
- Dart2JSBackend(interface, backend_options)
+ Dart2JSBackend(interface, backend_options, logging_level)
dart_output_dir = os.path.join(dart2js_output_dir, 'dart')
dart_libraries = DartLibraries(
HTML_LIBRARY_NAMES, template_loader, 'dart2js', dart2js_output_dir)
- RunGenerator(dart_libraries, dart_output_dir,
- template_loader, backend_factory)
+ print '\nGenerating dart2js:\n'
+ start_time = time.time()
+
+ RunGenerator(dart_libraries, dart_output_dir, template_loader,
+ backend_factory)
+
+ print 'Generated dart2js in %s seconds' % round(time.time() - start_time, 2)
if dartium_output_dir:
template_paths = ['html/dartium', 'html/impl', 'html/interface', '']
@@ -135,8 +159,14 @@ def GenerateFromDatabase(common_database, dart2js_output_dir,
cpp_library_emitter, backend_options)
dart_libraries = DartLibraries(
HTML_LIBRARY_NAMES, template_loader, 'dartium', dartium_output_dir)
+
+ print '\nGenerating dartium:\n'
+ start_time = time.time()
+
RunGenerator(dart_libraries, dart_output_dir,
template_loader, backend_factory)
+ print 'Generated dartium in %s seconds' % round(time.time() - start_time, 2)
+
cpp_library_emitter.EmitDerivedSources(
template_loader.Load('cpp_derived_sources.template'),
dartium_output_dir)
@@ -149,7 +179,7 @@ def GenerateFromDatabase(common_database, dart2js_output_dir,
if update_dom_metadata:
metadata.Flush()
- monitored.FinishMonitoring(dart2js_output_dir)
+ monitored.FinishMonitoring(dart2js_output_dir, _logger)
def GenerateSingleFile(library_path, output_dir, generated_output_dir=None):
library_dir = os.path.dirname(library_path)
@@ -192,6 +222,16 @@ def main():
action='store_true',
default=False,
help='''Update the metadata list of DOM APIs''')
+ parser.add_option('--blink-parser', dest='blink_parser',
+ action='store_true', default=False,
+ help='Use New Blink IDL parser.')
+ parser.add_option('--verbose', dest='logging_level',
+ action='store_false', default=logging.WARNING,
+ help='Output all informational messages')
+ parser.add_option('--logging', dest='logging', type='int',
+ action='store', default=logging.NOTSET,
+ help='Level of logging 20 is Info, 30 is Warnings, 40 is Errors')
+
(options, args) = parser.parse_args()
current_dir = os.path.dirname(__file__)
@@ -210,24 +250,40 @@ def main():
if 'htmldartium' in systems:
dartium_output_dir = os.path.join(output_dir, 'dartium')
+ logging_level = options.logging_level \
+ if options.logging == logging.NOTSET else options.logging
+
+ start_time = time.time()
+
UpdateCssProperties()
+
if options.rebuild:
# Parse the IDL and create the database.
- database = fremontcutbuilder.main(options.parallel)
+ database = fremontcutbuilder.main(options.parallel, options.blink_parser,
+ logging_level=logging_level)
else:
+ # TODO(terry): Should be able to remove this...
# Load the previously generated database.
- database = LoadDatabase(database_dir, options.use_database_cache)
+ if not options.blink_parser:
+ database = LoadDatabase(database_dir, options.use_database_cache)
+
GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir,
- options.update_dom_metadata)
+ options.update_dom_metadata, logging_level)
+
+ file_generation_start_time = time.time()
if 'htmldart2js' in systems:
_logger.info('Generating dart2js single files.')
+
for library_name in HTML_LIBRARY_NAMES:
GenerateSingleFile(
os.path.join(dart2js_output_dir, '%s_dart2js.dart' % library_name),
os.path.join('..', '..', '..', 'sdk', 'lib', library_name, 'dart2js'))
+
if 'htmldartium' in systems:
_logger.info('Generating dartium single files.')
+ file_generation_start_time = time.time()
+
for library_name in HTML_LIBRARY_NAMES:
GenerateSingleFile(
os.path.join(dartium_output_dir, '%s_dartium.dart' % library_name),
@@ -236,5 +292,11 @@ def main():
os.path.join(dartium_output_dir, '_blink_dartium.dart'),
os.path.join('..', '..', '..', 'sdk', 'lib', '_blink', 'dartium'))
+ print '\nGenerating single file %s seconds' % round(time.time() - file_generation_start_time, 2)
+
+ end_time = time.time()
+
+ print '\nDone (dartdomgenerator) %s seconds' % round(end_time - start_time, 2)
+
if __name__ == '__main__':
sys.exit(main())
« no previous file with comments | « tools/dom/scripts/__init__.py ('k') | tools/dom/scripts/dartgenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698