5"""This is the entry point to create Dart APIs from the IDL database."""
7import css_code_generator
15dart_dir = os.path.abspath(
16 os.path.normpath(os.path.join(os.path.dirname(__file__),
'..',
'..',
'..')))
17sys.path.insert(1, os.path.join(dart_dir,
'tools/dom/new_scripts'))
18sys.path.insert(1, os.path.join(dart_dir,
19 'third_party/WebCore/bindings/scripts'))
23third_party_dir = os.path.join(dart_dir,
'third_party')
25ply_dir = os.path.join(third_party_dir,
'ply')
28if not os.path.exists(ply_dir):
31 third_party_dir = os.path.join(dart_dir,
'..',
'third_party')
32 assert (os.path.exists(third_party_dir))
38 sys.path.insert(1, os.path.join(dart_dir,
'third_party/WebCore'))
40sys.path.insert(1, third_party_dir)
42sys.path.insert(1, os.path.join(dart_dir,
'tools/dom/scripts'))
46import fremontcutbuilder
54from dartmetadata
import DartMetadata
55from generator
import TypeRegistry
56from generate_blink_file
import Generate_Blink
57from htmleventgenerator
import HtmlEventGenerator
58from htmlrenamer
import HtmlRenamer
59from prototype_htmleventgenerator
import Prototype_HtmlEventGenerator
60from systemhtml
import DartLibraryEmitter, Dart2JSBackend,\
61 HtmlDartInterfaceGenerator, DartLibrary, DartLibraries,\
63from systemnative
import CPPLibraryEmitter, DartiumBackend
64from templateloader
import TemplateLoader
66sys.path.append(os.path.join(os.path.dirname(__file__),
'..',
'..'))
70_logger = logging.getLogger(
'dartdomgenerator')
75 def __init__(self, templates, database, type_registry, renamer, metadata,
87 if use_database_cache:
88 common_database.LoadFromCache()
90 common_database.Load()
91 return common_database
96 update_dom_metadata=False,
97 logging_level=logging.WARNING,
98 dart_js_interop=False,
99 generate_static_extensions=False,
100 generate_prototype_events=False):
101 print(
'\n ----- Accessing DOM using %s -----\n' %
102 (
'dart:js' if dart_js_interop
else 'C++'))
104 start_time = time.time()
106 current_dir = os.path.dirname(__file__)
107 auxiliary_dir = os.path.join(current_dir,
'..',
'src')
108 template_dir = os.path.join(current_dir,
'..',
'templates')
110 _logger.setLevel(logging_level)
113 generator.LoadAuxiliary(auxiliary_dir)
115 generator.FilterMembersWithUnidentifiedTypes(common_database)
116 webkit_database = common_database.Clone()
119 generator.FilterInterfaces(
120 database=webkit_database,
121 or_annotations=[
'WebKit',
'Dart'],
122 exclude_displaced=[
'WebKit'],
123 exclude_suppressed=[
'WebKit',
'Dart'])
124 generator.FixEventTargets(webkit_database)
125 generator.AddMissingArguments(webkit_database)
126 generator.CleanupOperationArguments(webkit_database)
129 metadata = DartMetadata(os.path.join(current_dir,
'..',
'dom.json'),
130 os.path.join(current_dir,
'..',
'docs.json'),
132 renamer = HtmlRenamer(webkit_database, metadata)
133 type_registry = TypeRegistry(webkit_database, renamer)
135 print(
'GenerateFromDatabase %s seconds' %
round(
136 (time.time() - start_time), 2))
138 def RunGenerator(dart_libraries, dart_output_dir, template_loader,
139 backend_factory, dart_js_interop):
141 type_registry, renamer, metadata,
148 webkit_database, renamer, metadata, event_generator)
150 def generate_interface(interface, gl_constants=None):
151 backend = backend_factory(interface)
153 options, dart_library_emitter, event_generator,
154 prototype_event_generator, interface, backend)
155 interface_generator.Generate()
156 if len(backend._gl_constants) > 0
and not (gl_constants
is None):
157 gl_constants.extend(backend._gl_constants)
159 generator.Generate(webkit_database, common_database, generate_interface)
160 if generate_prototype_events:
162 prototype_event_generator.WriteFile(dart_bin)
164 dart_library_emitter.EmitLibraries(auxiliary_dir, dart_js_interop)
166 if dart2js_output_dir:
167 template_paths = [
'html/dart2js',
'html/impl',
'html/interface',
'']
175 type_registry, renamer, metadata,
178 backend_factory =
lambda interface:\
179 Dart2JSBackend(interface, backend_options, logging_level, generate_static_extensions)
181 dart_output_dir = os.path.join(dart2js_output_dir,
'dart')
182 dart_libraries =
DartLibraries(HTML_LIBRARY_NAMES, template_loader,
183 'dart2js', dart2js_output_dir,
185 for file
in generator._auxiliary_files.values():
186 if file.endswith(
'darttemplate'):
187 dart_libraries._libraries[
'html'].AddFile(file)
189 print(
'\nGenerating dart2js:\n')
190 start_time = time.time()
192 RunGenerator(dart_libraries, dart_output_dir, template_loader,
193 backend_factory, dart_js_interop)
195 print(
'Generated dart2js in %s seconds' %
196 round(time.time() - start_time, 2))
200 if update_dom_metadata:
203 monitored.FinishMonitoring(dart2js_output_dir, _logger)
207 library_dir = os.path.dirname(library_path)
208 library_filename = os.path.basename(library_path)
209 copy_dart_script = os.path.relpath(
'../../copy_dart.py', library_dir)
210 output_dir = os.path.relpath(output_dir, library_dir)
211 if not os.path.exists(library_dir):
212 os.makedirs(library_dir)
213 prefix_arg =
'export DART_HTML_PREFIX="' + prefix +
'";' if prefix
else ""
215 prefix_arg,
'cd', library_dir,
';', copy_dart_script, output_dir, library_filename
217 subprocess.call([command], shell=
True)
219 sdk_file = os.path.join(library_dir, output_dir, library_filename)
220 formatCommand =
' '.
join([dart_bin,
'format', sdk_file])
221 subprocess.call([formatCommand], shell=
True)
225 """Regenerate the CssStyleDeclaration template file with the current CSS
227 _logger.info('Updating Css Properties.')
228 css_code_generator.GenerateCssTemplateFile()
232// START_OF_CACHED_PATCHES
233// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
234// for details. All rights reserved. Use of this source code
is governed by a
235// BSD-style license that can be found
in the LICENSE file.
237// DO NOT EDIT GENERATED FILE.
239library cached_patches;
241var cached_patches = {
242 /********************************************************
244 ***** MUST RUN tools/dartium/generate_patches.sh *****
246 ********************************************************/
252 parser = optparse.OptionParser()
258 help=
'Use fremontcut in parallel mode.')
264 default=
'htmldart2js,htmldartium,_blink',
265 help=
'Systems to generate (htmldart2js, htmldartium, _blink)')
272 help=
'Directory to put the generated files')
274 '--use-database-cache',
275 dest=
'use_database_cache',
278 help=
'''Use the cached database from the previous run to
279 improve startup performance''')
281 '--update-dom-metadata',
282 dest=
'update_dom_metadata',
285 help=
'''Update the metadata list of DOM APIs''')
288 dest=
'logging_level',
289 action=
'store_false',
290 default=logging.WARNING,
291 help=
'Output all informational messages')
297 help=
'Analyze IDL files')
303 default=logging.NOTSET,
304 help=
'Level of logging 20 is Info, 30 is Warnings, 40 is Errors')
307 dest=
'dart_js_interop',
310 help=
'Use JavaScript objects (dart:js) accessing the DOM in _blink')
312 '--no-cached-patches',
313 dest=
'no_cached_patches',
316 help=
'Do not generate the sdk/lib/js/cached_patches.dart file')
318 '--generate-static-extensions',
319 dest=
'generate_static_extensions',
322 help=
'Generate static extension members for dart:html classes')
324 '--generate-prototype-events',
325 dest=
'generate_prototype_events',
328 help=
'Generate event stream library for dart:html prototype')
330 (options, args) = parser.parse_args()
332 current_dir = os.path.dirname(__file__)
333 database_dir = os.path.join(current_dir,
'..',
'database')
334 logging.config.fileConfig(os.path.join(current_dir,
'logging.conf'))
335 systems = options.systems.split(
',')
337 output_dir = options.output_dir
or os.path.join(
341 dart2js_output_dir =
None
342 if 'htmldart2js' in systems:
343 dart2js_output_dir = os.path.join(output_dir,
'dart2js')
345 logging_level = options.logging_level \
346 if options.logging == logging.NOTSET
else options.logging
348 start_time = time.time()
353 database = fremontcutbuilder.main(
355 logging_level=logging_level,
356 examine_idls=options.examine_idls)
359 options.update_dom_metadata, logging_level,
360 options.dart_js_interop,
361 options.generate_static_extensions,
362 options.generate_prototype_events)
364 file_generation_start_time = time.time()
366 if 'htmldart2js' in systems:
367 _logger.info(
'Generating dart2js single files.')
369 for library_name
in HTML_LIBRARY_NAMES:
370 source = os.path.join(dart2js_output_dir,
371 '%s_dart2js.dart' % library_name)
373 source, os.path.join(
'..',
'..',
'..',
'sdk',
'lib',
374 library_name,
'dart2js'))
376 print(
'\nGenerating single file %s seconds' %
377 round(time.time() - file_generation_start_time, 2))
379 end_time = time.time()
381 print(
'\nDone (dartdomgenerator) %s seconds' %
382 round(end_time - start_time, 2))
385if __name__ ==
'__main__':
static void round(SkPoint *p)
def __init__(self, templates, database, type_registry, renamer, metadata, dart_js_interop)
def print(*args, **kwargs)
def GenerateFromDatabase(common_database, dart2js_output_dir, update_dom_metadata=False, logging_level=logging.WARNING, dart_js_interop=False, generate_static_extensions=False, generate_prototype_events=False)
def LoadDatabase(database_dir, use_database_cache)
def UpdateCssProperties()
def GenerateSingleFile(library_path, output_dir, generated_output_dir=None, prefix=None)
static SkString join(const CommandLineFlags::StringArray &)