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

Side by Side Diff: lib/html/scripts/dartdomgenerator.py

Issue 10917264: Fix dart:html generated directory structure and unify file names between backends. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 """This is the entry point to create Dart APIs from the IDL database.""" 6 """This is the entry point to create Dart APIs from the IDL database."""
7 7
8 import dartgenerator 8 import dartgenerator
9 import database 9 import database
10 import logging.config 10 import logging.config
(...skipping 19 matching lines...) Expand all
30 # TODO(vsm): Maybe Store these renames in the IDLs. 30 # TODO(vsm): Maybe Store these renames in the IDLs.
31 'ApplicationCache': 'DOMApplicationCache', 31 'ApplicationCache': 'DOMApplicationCache',
32 'BarProp': 'BarInfo', 32 'BarProp': 'BarInfo',
33 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext', 33 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext',
34 'FormData': 'DOMFormData', 34 'FormData': 'DOMFormData',
35 'Selection': 'DOMSelection', 35 'Selection': 'DOMSelection',
36 'SharedWorkerGlobalScope': 'SharedWorkerContext', 36 'SharedWorkerGlobalScope': 'SharedWorkerContext',
37 'Window': 'DOMWindow', 37 'Window': 'DOMWindow',
38 'WorkerGlobalScope': 'WorkerContext'} 38 'WorkerGlobalScope': 'WorkerContext'}
39 39
40 def Generate(system_names, database_dir, use_database_cache, 40 def Generate(database_dir, use_database_cache, dart2js_output_dir=None,
41 html_output_dir): 41 dartium_output_dir=None):
42 current_dir = os.path.dirname(__file__) 42 current_dir = os.path.dirname(__file__)
43 auxiliary_dir = os.path.join(current_dir, '..', 'src') 43 auxiliary_dir = os.path.join(current_dir, '..', 'src')
44 template_dir = os.path.join(current_dir, '..', 'templates') 44 template_dir = os.path.join(current_dir, '..', 'templates')
45 45
46 generator = dartgenerator.DartGenerator() 46 generator = dartgenerator.DartGenerator()
47 generator.LoadAuxiliary(auxiliary_dir) 47 generator.LoadAuxiliary(auxiliary_dir)
48 48
49 common_database = database.Database(database_dir) 49 common_database = database.Database(database_dir)
50 if use_database_cache: 50 if use_database_cache:
51 common_database.LoadFromCache() 51 common_database.LoadFromCache()
52 else: 52 else:
53 common_database.Load() 53 common_database.Load()
54 54
55 generator.FilterMembersWithUnidentifiedTypes(common_database) 55 generator.FilterMembersWithUnidentifiedTypes(common_database)
56 webkit_database = common_database.Clone() 56 webkit_database = common_database.Clone()
57 57
58 # Generate Dart interfaces for the WebKit DOM. 58 # Generate Dart interfaces for the WebKit DOM.
59 generator.FilterInterfaces(database = webkit_database, 59 generator.FilterInterfaces(database = webkit_database,
60 or_annotations = ['WebKit', 'Dart'], 60 or_annotations = ['WebKit', 'Dart'],
61 exclude_displaced = ['WebKit'], 61 exclude_displaced = ['WebKit'],
62 exclude_suppressed = ['WebKit', 'Dart']) 62 exclude_suppressed = ['WebKit', 'Dart'])
63 generator.RenameTypes(webkit_database, _webkit_renames, True) 63 generator.RenameTypes(webkit_database, _webkit_renames, True)
64 generator.FixEventTargets(webkit_database) 64 generator.FixEventTargets(webkit_database)
65 generator.AddMissingArguments(webkit_database) 65 generator.AddMissingArguments(webkit_database)
66 66
67 emitters = multiemitter.MultiEmitter()
68 renamer = HtmlRenamer(webkit_database)
69 type_registry = TypeRegistry(webkit_database, renamer)
70
67 def CreateGeneratorOptions(template_paths, conditions, type_registry, output_d ir, 71 def CreateGeneratorOptions(template_paths, conditions, type_registry, output_d ir,
68 renamer=None): 72 renamer=None):
69 template_loader = TemplateLoader(template_dir, template_paths, conditions) 73 template_loader = TemplateLoader(template_dir, template_paths, conditions)
70 return GeneratorOptions( 74 return GeneratorOptions(
71 template_loader, webkit_database, emitters, type_registry, renamer, 75 template_loader, webkit_database, emitters, type_registry, renamer,
72 output_dir) 76 output_dir)
73 77
74 def Generate(system): 78 def Generate(backend, output_dir):
75 generator.Generate(webkit_database, system, 79 options = CreateGeneratorOptions(
80 ['html/interface', 'html/impl', 'html', ''], {},
81 type_registry, output_dir, renamer)
82 html_system = HtmlInterfacesSystem(options, backend)
83 generator.Generate(webkit_database, html_system,
76 super_database=common_database, 84 super_database=common_database,
77 webkit_renames=_webkit_renames) 85 webkit_renames=_webkit_renames)
78 86
79 emitters = multiemitter.MultiEmitter() 87 if dart2js_output_dir:
88 options = CreateGeneratorOptions(
89 ['html/dart2js', 'html/impl', 'html', ''],
90 {'DARTIUM': False, 'DART2JS': True},
91 type_registry, dart2js_output_dir, renamer)
92 backend = HtmlDart2JSSystem(options)
93 Generate(backend, dart2js_output_dir)
80 94
81 for system_name in system_names: 95 if dartium_output_dir:
82 renamer = HtmlRenamer(webkit_database)
83 type_registry = TypeRegistry(webkit_database, renamer)
84 if system_name == 'htmldart2js':
85 options = CreateGeneratorOptions(
86 ['html/dart2js', 'html/impl', 'html', ''],
87 {'DARTIUM': False, 'DART2JS': True},
88 type_registry, html_output_dir, renamer)
89 backend = HtmlDart2JSSystem(options)
90 else:
91 options = CreateGeneratorOptions(
92 ['html/dartium', 'html/impl', ''],
93 {'DARTIUM': True, 'DART2JS': False},
94 type_registry, html_output_dir, renamer)
95 backend = NativeImplementationSystem(options, auxiliary_dir)
96 options = CreateGeneratorOptions( 96 options = CreateGeneratorOptions(
97 ['html/interface', 'html/impl', 'html', ''], {}, 97 ['html/dartium', 'html/impl', ''],
98 type_registry, html_output_dir, renamer) 98 {'DARTIUM': True, 'DART2JS': False},
99 html_system = HtmlInterfacesSystem(options, backend) 99 type_registry, dartium_output_dir, renamer)
100 Generate(html_system) 100 backend = NativeImplementationSystem(options, auxiliary_dir)
101 Generate(backend, dartium_output_dir)
101 102
102 _logger.info('Flush...') 103 _logger.info('Flush...')
103 emitters.Flush() 104 emitters.Flush()
104 105
105 def GenerateSingleFile(systems): 106 def GenerateSingleFile(systems):
106 if 'htmldart2js' in systems: 107 if 'htmldart2js' in systems:
107 _logger.info('Copy html_dart2js to dart2js/') 108 _logger.info('Copy html_dart2js to dart2js/')
108 subprocess.call(['cd ../generated ; ' 109 subprocess.call(['cd ../generated ; '
109 '../../../tools/copy_dart.py ../dart2js html_dart2js.dart'] , 110 '../../../tools/copy_dart.py ../dart2js html_dart2js.dart'] ,
110 shell=True) 111 shell=True)
(...skipping 19 matching lines...) Expand all
130 default=False, 131 default=False,
131 help='''Use the cached database from the previous run to 132 help='''Use the cached database from the previous run to
132 improve startup performance''') 133 improve startup performance''')
133 (options, args) = parser.parse_args() 134 (options, args) = parser.parse_args()
134 135
135 current_dir = os.path.dirname(__file__) 136 current_dir = os.path.dirname(__file__)
136 database_dir = os.path.join(current_dir, '..', 'database') 137 database_dir = os.path.join(current_dir, '..', 'database')
137 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) 138 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf'))
138 systems = options.systems.split(',') 139 systems = options.systems.split(',')
139 140
140 html_output_dir = options.output_dir or os.path.join(current_dir, 141 output_dir = options.output_dir or os.path.join(current_dir, '../generated')
141 '../generated') 142 dart2js_output_dir = None
142 Generate(systems, database_dir, options.use_database_cache, 143 if 'htmldart2js' in systems:
143 html_output_dir) 144 dart2js_output_dir = os.path.join(output_dir, 'dart2js')
145 dartium_output_dir = None
146 if 'htmldartium' in systems:
147 dartium_output_dir = os.path.join(output_dir, 'dartium')
148 Generate(database_dir, options.use_database_cache, dart2js_output_dir,
149 dartium_output_dir)
144 GenerateSingleFile(systems) 150 GenerateSingleFile(systems)
145 151
146 if __name__ == '__main__': 152 if __name__ == '__main__':
147 sys.exit(main()) 153 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698