Flutter Engine
The Flutter Engine
Classes | Functions | Variables
scripts.dartdomgenerator Namespace Reference

Classes

class  GeneratorOptions
 

Functions

def LoadDatabase (database_dir, use_database_cache)
 
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 GenerateSingleFile (library_path, output_dir, generated_output_dir=None, prefix=None)
 
def UpdateCssProperties ()
 
def main ()
 

Variables

 dart_dir
 
 third_party_dir = os.path.join(dart_dir, 'third_party')
 
 ply_dir = os.path.join(third_party_dir, 'ply')
 
string CACHED_PATCHES
 

Function Documentation

◆ GenerateFromDatabase()

def scripts.dartdomgenerator.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 
)

Definition at line 94 of file dartdomgenerator.py.

100 generate_prototype_events=False):
101 print('\n ----- Accessing DOM using %s -----\n' %
102 ('dart:js' if dart_js_interop else 'C++'))
103
104 start_time = time.time()
105
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')
109
110 _logger.setLevel(logging_level)
111
112 generator = dartgenerator.DartGenerator(logging_level)
113 generator.LoadAuxiliary(auxiliary_dir)
114
115 generator.FilterMembersWithUnidentifiedTypes(common_database)
116 webkit_database = common_database.Clone()
117
118 # Generate Dart interfaces for the WebKit DOM.
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)
127
128 emitters = multiemitter.MultiEmitter(logging_level)
129 metadata = DartMetadata(os.path.join(current_dir, '..', 'dom.json'),
130 os.path.join(current_dir, '..', 'docs.json'),
131 logging_level)
132 renamer = HtmlRenamer(webkit_database, metadata)
133 type_registry = TypeRegistry(webkit_database, renamer)
134
135 print('GenerateFromDatabase %s seconds' % round(
136 (time.time() - start_time), 2))
137
138 def RunGenerator(dart_libraries, dart_output_dir, template_loader,
139 backend_factory, dart_js_interop):
140 options = GeneratorOptions(template_loader, webkit_database,
141 type_registry, renamer, metadata,
142 dart_js_interop)
143 dart_library_emitter = DartLibraryEmitter(emitters, dart_output_dir,
144 dart_libraries)
145 event_generator = HtmlEventGenerator(webkit_database, renamer, metadata,
146 template_loader)
147 prototype_event_generator = Prototype_HtmlEventGenerator(
148 webkit_database, renamer, metadata, event_generator)
149
150 def generate_interface(interface, gl_constants=None):
151 backend = backend_factory(interface)
152 interface_generator = HtmlDartInterfaceGenerator(
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)
158
159 generator.Generate(webkit_database, common_database, generate_interface)
160 if generate_prototype_events:
161 dart_bin = os.path.join(utils.CheckedInSdkPath(), 'bin', 'dart')
162 prototype_event_generator.WriteFile(dart_bin)
163
164 dart_library_emitter.EmitLibraries(auxiliary_dir, dart_js_interop)
165
166 if dart2js_output_dir:
167 template_paths = ['html/dart2js', 'html/impl', 'html/interface', '']
168 template_loader = TemplateLoader(template_dir, template_paths, {
169 'DARTIUM': False,
170 'DART2JS': True,
171 'JSINTEROP': False,
172 'NNBD': True,
173 })
174 backend_options = GeneratorOptions(template_loader, webkit_database,
175 type_registry, renamer, metadata,
176 dart_js_interop)
177
178 backend_factory = lambda interface:\
179 Dart2JSBackend(interface, backend_options, logging_level, generate_static_extensions)
180
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,
184 dart_js_interop)
185 for file in generator._auxiliary_files.values():
186 if file.endswith('darttemplate'):
187 dart_libraries._libraries['html'].AddFile(file)
188
189 print('\nGenerating dart2js:\n')
190 start_time = time.time()
191
192 RunGenerator(dart_libraries, dart_output_dir, template_loader,
193 backend_factory, dart_js_interop)
194
195 print('Generated dart2js in %s seconds' %
196 round(time.time() - start_time, 2))
197
198 emitters.Flush()
199
200 if update_dom_metadata:
201 metadata.Flush()
202
203 monitored.FinishMonitoring(dart2js_output_dir, _logger)
204
205
static void round(SkPoint *p)
def print(*args, **kwargs)
Definition: run_tests.py:49
def CheckedInSdkPath()
Definition: utils.py:499

◆ GenerateSingleFile()

def scripts.dartdomgenerator.GenerateSingleFile (   library_path,
  output_dir,
  generated_output_dir = None,
  prefix = None 
)

Definition at line 206 of file dartdomgenerator.py.

206def GenerateSingleFile(library_path, output_dir, generated_output_dir=None, prefix=None):
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 ""
214 command = ' '.join([
215 prefix_arg, 'cd', library_dir, ';', copy_dart_script, output_dir, library_filename
216 ])
217 subprocess.call([command], shell=True)
218 dart_bin = os.path.join(utils.CheckedInSdkPath(), 'bin', 'dart')
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)
222
223
def GenerateSingleFile(library_path, output_dir, generated_output_dir=None, prefix=None)
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741

◆ LoadDatabase()

def scripts.dartdomgenerator.LoadDatabase (   database_dir,
  use_database_cache 
)

Definition at line 85 of file dartdomgenerator.py.

85def LoadDatabase(database_dir, use_database_cache):
86 common_database = database.Database(database_dir)
87 if use_database_cache:
88 common_database.LoadFromCache()
89 else:
90 common_database.Load()
91 return common_database
92
93
def LoadDatabase(database_dir, use_database_cache)

◆ main()

def scripts.dartdomgenerator.main ( )

Definition at line 251 of file dartdomgenerator.py.

251def main():
252 parser = optparse.OptionParser()
253 parser.add_option(
254 '--parallel',
255 dest='parallel',
256 action='store_true',
257 default=False,
258 help='Use fremontcut in parallel mode.')
259 parser.add_option(
260 '--systems',
261 dest='systems',
262 action='store',
263 type='string',
264 default='htmldart2js,htmldartium,_blink',
265 help='Systems to generate (htmldart2js, htmldartium, _blink)')
266 parser.add_option(
267 '--output-dir',
268 dest='output_dir',
269 action='store',
270 type='string',
271 default=None,
272 help='Directory to put the generated files')
273 parser.add_option(
274 '--use-database-cache',
275 dest='use_database_cache',
276 action='store_true',
277 default=False,
278 help='''Use the cached database from the previous run to
279 improve startup performance''')
280 parser.add_option(
281 '--update-dom-metadata',
282 dest='update_dom_metadata',
283 action='store_true',
284 default=False,
285 help='''Update the metadata list of DOM APIs''')
286 parser.add_option(
287 '--verbose',
288 dest='logging_level',
289 action='store_false',
290 default=logging.WARNING,
291 help='Output all informational messages')
292 parser.add_option(
293 '--examine',
294 dest='examine_idls',
295 action='store_true',
296 default=None,
297 help='Analyze IDL files')
298 parser.add_option(
299 '--logging',
300 dest='logging',
301 type='int',
302 action='store',
303 default=logging.NOTSET,
304 help='Level of logging 20 is Info, 30 is Warnings, 40 is Errors')
305 parser.add_option(
306 '--gen-interop',
307 dest='dart_js_interop',
308 action='store_true',
309 default=False,
310 help='Use JavaScript objects (dart:js) accessing the DOM in _blink')
311 parser.add_option(
312 '--no-cached-patches',
313 dest='no_cached_patches',
314 action='store_true',
315 default=False,
316 help='Do not generate the sdk/lib/js/cached_patches.dart file')
317 parser.add_option(
318 '--generate-static-extensions',
319 dest='generate_static_extensions',
320 action='store_true',
321 default=False,
322 help='Generate static extension members for dart:html classes')
323 parser.add_option(
324 '--generate-prototype-events',
325 dest='generate_prototype_events',
326 action='store_true',
327 default=False,
328 help='Generate event stream library for dart:html prototype')
329
330 (options, args) = parser.parse_args()
331
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(',')
336
337 output_dir = options.output_dir or os.path.join(
338 current_dir, '..', '..', '..', utils.GetBuildDir(utils.GuessOS()),
339 'generated')
340
341 dart2js_output_dir = None
342 if 'htmldart2js' in systems:
343 dart2js_output_dir = os.path.join(output_dir, 'dart2js')
344
345 logging_level = options.logging_level \
346 if options.logging == logging.NOTSET else options.logging
347
348 start_time = time.time()
349
351
352 # Parse the IDL and create the database.
353 database = fremontcutbuilder.main(
354 options.parallel,
355 logging_level=logging_level,
356 examine_idls=options.examine_idls)
357
358 GenerateFromDatabase(database, dart2js_output_dir,
359 options.update_dom_metadata, logging_level,
360 options.dart_js_interop,
361 options.generate_static_extensions,
362 options.generate_prototype_events)
363
364 file_generation_start_time = time.time()
365
366 if 'htmldart2js' in systems:
367 _logger.info('Generating dart2js single files.')
368
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'))
375
376 print('\nGenerating single file %s seconds' %
377 round(time.time() - file_generation_start_time, 2))
378
379 end_time = time.time()
380
381 print('\nDone (dartdomgenerator) %s seconds' %
382 round(end_time - start_time, 2))
383
384
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 GuessOS()
Definition: utils.py:21
def GetBuildDir(host_os)
Definition: utils.py:99

◆ UpdateCssProperties()

def scripts.dartdomgenerator.UpdateCssProperties ( )
Regenerate the CssStyleDeclaration template file with the current CSS
properties.

Definition at line 224 of file dartdomgenerator.py.

225 """Regenerate the CssStyleDeclaration template file with the current CSS
226 properties."""
227 _logger.info('Updating Css Properties.')
228 css_code_generator.GenerateCssTemplateFile()
229
230

Variable Documentation

◆ CACHED_PATCHES

string scripts.dartdomgenerator.CACHED_PATCHES
Initial value:
1= """
2// START_OF_CACHED_PATCHES
3// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
4// for details. All rights reserved. Use of this source code is governed by a
5// BSD-style license that can be found in the LICENSE file.
6
7// DO NOT EDIT GENERATED FILE.
8
9library cached_patches;
10
11var cached_patches = {
12 /********************************************************
13 ***** *****
14 ***** MUST RUN tools/dartium/generate_patches.sh *****
15 ***** *****
16 ********************************************************/
17};
18"""

Definition at line 231 of file dartdomgenerator.py.

◆ dart_dir

scripts.dartdomgenerator.dart_dir
Initial value:
1= os.path.abspath(
2 os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..', '..')))

Definition at line 15 of file dartdomgenerator.py.

◆ ply_dir

scripts.dartdomgenerator.ply_dir = os.path.join(third_party_dir, 'ply')

Definition at line 25 of file dartdomgenerator.py.

◆ third_party_dir

scripts.dartdomgenerator.third_party_dir = os.path.join(dart_dir, 'third_party')

Definition at line 23 of file dartdomgenerator.py.