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

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

Issue 10987019: Refactor file paths handling in generator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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
« no previous file with comments | « no previous file | lib/html/scripts/dartgenerator.py » ('j') | lib/html/scripts/dartgenerator.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 import multiemitter 11 import multiemitter
12 import optparse 12 import optparse
13 import os 13 import os
14 import shutil 14 import shutil
15 import subprocess 15 import subprocess
16 import sys 16 import sys
17 from generator import TypeRegistry 17 from generator import TypeRegistry
18 from htmlrenamer import HtmlRenamer 18 from htmlrenamer import HtmlRenamer
19 from systembase import GeneratorOptions 19 from systembase import GeneratorOptions
20 from systemdart2js import Dart2JSSystem 20 from systemdart2js import Dart2JSSystem
21 from systemhtml import HtmlInterfacesSystem, HtmlDart2JSSystem 21 from systemhtml import DartLibraryGenerator, HtmlInterfacesSystem,
22 HtmlDart2JSSystem
22 from systeminterface import InterfacesSystem 23 from systeminterface import InterfacesSystem
23 from systemnative import NativeImplementationSystem 24 from systemnative import CPPLibraryGenerator, NativeImplementationSystem
24 from templateloader import TemplateLoader 25 from templateloader import TemplateLoader
25 26
26 _logger = logging.getLogger('dartdomgenerator') 27 _logger = logging.getLogger('dartdomgenerator')
27 28
28 _webkit_renames = { 29 _webkit_renames = {
29 # W3C -> WebKit name conversion 30 # W3C -> WebKit name conversion
30 # TODO(vsm): Maybe Store these renames in the IDLs. 31 # TODO(vsm): Maybe Store these renames in the IDLs.
31 'ApplicationCache': 'DOMApplicationCache', 32 'ApplicationCache': 'DOMApplicationCache',
32 'BarProp': 'BarInfo', 33 'BarProp': 'BarInfo',
33 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext', 34 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext',
(...skipping 27 matching lines...) Expand all
61 exclude_displaced = ['WebKit'], 62 exclude_displaced = ['WebKit'],
62 exclude_suppressed = ['WebKit', 'Dart']) 63 exclude_suppressed = ['WebKit', 'Dart'])
63 generator.RenameTypes(webkit_database, _webkit_renames, True) 64 generator.RenameTypes(webkit_database, _webkit_renames, True)
64 generator.FixEventTargets(webkit_database) 65 generator.FixEventTargets(webkit_database)
65 generator.AddMissingArguments(webkit_database) 66 generator.AddMissingArguments(webkit_database)
66 67
67 emitters = multiemitter.MultiEmitter() 68 emitters = multiemitter.MultiEmitter()
68 renamer = HtmlRenamer(webkit_database) 69 renamer = HtmlRenamer(webkit_database)
69 type_registry = TypeRegistry(webkit_database, renamer) 70 type_registry = TypeRegistry(webkit_database, renamer)
70 71
71 def CreateGeneratorOptions(template_paths, conditions, output_dir): 72 def Generate(dart_library_template, dart_output_dir, dart_library_path,
vsm 2012/09/25 16:06:14 Can you use a different name here? It shadows the
podivilov1 2012/09/25 16:40:28 Done.
72 template_loader = TemplateLoader(template_dir, template_paths, conditions) 73 backend):
73 return GeneratorOptions( 74 template_loader = TemplateLoader(template_dir,
74 template_loader, webkit_database, emitters, type_registry, renamer, 75 ['html/interface', 'html/impl', 'html', ''] ,
vsm 2012/09/25 16:06:14 nit: line length
podivilov1 2012/09/25 16:40:28 Done.
75 output_dir, auxiliary_dir) 76 {})
76 77 options = GeneratorOptions(
77 def Generate(backend, output_dir): 78 template_loader, webkit_database, type_registry, renamer)
78 options = CreateGeneratorOptions( 79 dart_library_generator = DartLibraryGenerator(
79 ['html/interface', 'html/impl', 'html', ''], {}, output_dir) 80 emitters, dart_library_template, dart_output_dir)
80 html_system = HtmlInterfacesSystem(options, backend) 81 html_system = HtmlInterfacesSystem(options, dart_library_generator, backend)
81 generator.Generate(webkit_database, html_system, 82 generator.Generate(webkit_database, common_database, _webkit_renames,
82 super_database=common_database, 83 html_system.ProcessInterface,
83 webkit_renames=_webkit_renames) 84 html_system.ProcessCallback)
85 dart_library_generator.GenerateLibrary(dart_library_path, auxiliary_dir)
84 86
85 if dart2js_output_dir: 87 if dart2js_output_dir:
86 options = CreateGeneratorOptions( 88 template_loader = TemplateLoader(template_dir,
87 ['html/dart2js', 'html/impl', 'html', ''], 89 ['html/dart2js', 'html/impl', 'html', ''],
88 {'DARTIUM': False, 'DART2JS': True}, dart2js_output_dir) 90 {'DARTIUM': False, 'DART2JS': True})
89 backend = HtmlDart2JSSystem(options) 91 backend_options = GeneratorOptions(
90 Generate(backend, dart2js_output_dir) 92 template_loader, webkit_database, type_registry, renamer)
93 backend = HtmlDart2JSSystem(backend_options)
94
95 dart_library_template = template_loader.Load('html_dart2js.darttemplate')
96 dart_output_dir = os.path.join(dart2js_output_dir, 'dart')
97 dart_library_path = os.path.join(dart2js_output_dir, 'html_dart2js.dart')
98
99 Generate(dart_library_template, dart_output_dir, dart_library_path, backend)
91 100
92 if dartium_output_dir: 101 if dartium_output_dir:
93 options = CreateGeneratorOptions( 102 template_loader = TemplateLoader(template_dir,
94 ['html/dartium', 'html/impl', ''], 103 ['html/dartium', 'html/impl', ''],
95 {'DARTIUM': True, 'DART2JS': False}, dartium_output_dir) 104 {'DARTIUM': True, 'DART2JS': False})
96 backend = NativeImplementationSystem(options) 105 backend_options = GeneratorOptions(
97 Generate(backend, dartium_output_dir) 106 template_loader, webkit_database, type_registry, renamer)
107 cpp_output_dir = os.path.join(dartium_output_dir, 'cpp')
108 cpp_library_generator = CPPLibraryGenerator(emitters, cpp_output_dir)
109 backend = NativeImplementationSystem(backend_options, cpp_library_generator)
110
111 dart_library_template = template_loader.Load('html_dartium.darttemplate')
112 dart_output_dir = os.path.join(dartium_output_dir, 'dart')
113 dart_library_path = os.path.join(dartium_output_dir, 'html_dartium.dart')
114
115 Generate(dart_library_template, dart_output_dir, dart_library_path, backend)
116 cpp_library_generator.GenerateDerivedSources(
117 template_loader.Load('cpp_derived_sources.template'),
118 dartium_output_dir)
119 cpp_library_generator.GenerateResolver(
120 template_loader.Load('cpp_resolver.template'), dartium_output_dir)
98 121
99 _logger.info('Flush...') 122 _logger.info('Flush...')
100 emitters.Flush() 123 emitters.Flush()
101 124
102 def GenerateSingleFile(library_path, output_dir): 125 def GenerateSingleFile(library_path, output_dir):
103 library_dir = os.path.dirname(library_path) 126 library_dir = os.path.dirname(library_path)
104 library_filename = os.path.basename(library_path) 127 library_filename = os.path.basename(library_path)
105 copy_dart_script = os.path.relpath('../../../tools/copy_dart.py', library_dir) 128 copy_dart_script = os.path.relpath('../../../tools/copy_dart.py', library_dir)
106 output_dir = os.path.relpath(output_dir, library_dir) 129 output_dir = os.path.relpath(output_dir, library_dir)
107 command = ' '.join(['cd', library_dir, ';', 130 command = ' '.join(['cd', library_dir, ';',
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 _logger.info('Copy html_dart2js to dart2js/') 168 _logger.info('Copy html_dart2js to dart2js/')
146 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'), 169 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'),
147 '../dart2js') 170 '../dart2js')
148 if 'htmldartium' in systems: 171 if 'htmldartium' in systems:
149 _logger.info('Copy html_dartium to dartium/') 172 _logger.info('Copy html_dartium to dartium/')
150 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'), 173 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'),
151 '../dartium') 174 '../dartium')
152 175
153 if __name__ == '__main__': 176 if __name__ == '__main__':
154 sys.exit(main()) 177 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | lib/html/scripts/dartgenerator.py » ('j') | lib/html/scripts/dartgenerator.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698