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

Side by Side Diff: client/dom/scripts/dartdomgenerator.py

Issue 9663027: Remove generated directories with 100s of files. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 generator.RenameTypes(common_database, { 92 generator.RenameTypes(common_database, {
93 # W3C -> Dart renames 93 # W3C -> Dart renames
94 'AbstractView': 'Window', 94 'AbstractView': 'Window',
95 'Function': 'EventListener', 95 'Function': 'EventListener',
96 'DOMStringMap': 'Map<String, String>', 96 'DOMStringMap': 'Map<String, String>',
97 'DOMStringList': 'List<String>', 97 'DOMStringList': 'List<String>',
98 }, False) 98 }, False)
99 generator.FilterMembersWithUnidentifiedTypes(common_database) 99 generator.FilterMembersWithUnidentifiedTypes(common_database)
100 webkit_database = common_database.Clone() 100 webkit_database = common_database.Clone()
101 101
102 generated_output_dir = os.path.join(output_dir,
103 '../html/generated' if generate_html_systems else 'generated')
104 if os.path.exists(generated_output_dir):
105 _logger.info('Cleaning output directory %s' % generated_output_dir)
106 shutil.rmtree(generated_output_dir)
107
108
109 # Generate Dart interfaces for the WebKit DOM. 102 # Generate Dart interfaces for the WebKit DOM.
110 webkit_output_dir = generated_output_dir
111 generator.FilterInterfaces(database = webkit_database, 103 generator.FilterInterfaces(database = webkit_database,
112 or_annotations = ['WebKit', 'Dart'], 104 or_annotations = ['WebKit', 'Dart'],
113 exclude_displaced = ['WebKit'], 105 exclude_displaced = ['WebKit'],
114 exclude_suppressed = ['WebKit', 'Dart']) 106 exclude_suppressed = ['WebKit', 'Dart'])
115 generator.RenameTypes(webkit_database, _webkit_renames, False) 107 generator.RenameTypes(webkit_database, _webkit_renames, False)
116 108
117 if generate_html_systems: 109 if generate_html_systems:
118 html_renames = _MakeHtmlRenames(common_database) 110 html_renames = _MakeHtmlRenames(common_database)
119 generator.RenameTypes(webkit_database, html_renames, True) 111 generator.RenameTypes(webkit_database, html_renames, True)
120 html_renames_inverse = dict((v,k) for k, v in html_renames.iteritems()) 112 html_renames_inverse = dict((v,k) for k, v in html_renames.iteritems())
121 else: 113 else:
122 html_renames_inverse = {} 114 html_renames_inverse = {}
123 115
124 webkit_renames_inverse = dict((v,k) for k, v in _webkit_renames.iteritems()) 116 webkit_renames_inverse = dict((v,k) for k, v in _webkit_renames.iteritems())
125 117
126 generator.Generate(database = webkit_database, 118 generator.Generate(database = webkit_database,
127 output_dir = webkit_output_dir, 119 output_dir = output_dir,
128 lib_dir = output_dir, 120 lib_dir = output_dir,
129 module_source_preference = ['WebKit', 'Dart'], 121 module_source_preference = ['WebKit', 'Dart'],
130 source_filter = ['WebKit', 'Dart'], 122 source_filter = ['WebKit', 'Dart'],
131 super_database = common_database, 123 super_database = common_database,
132 common_prefix = 'common', 124 common_prefix = 'common',
133 super_map = webkit_renames_inverse, 125 super_map = webkit_renames_inverse,
134 html_map = html_renames_inverse, 126 html_map = html_renames_inverse,
135 systems = systems) 127 systems = systems)
136 128
137 generator.Flush() 129 generator.Flush()
138 130
139 if 'frog' in systems: 131 if 'frog' in systems:
140 _logger.info('Copy dom_frog to frog/') 132 _logger.info('Copy dom_frog to frog/')
141 subprocess.call(['cd .. ; ../tools/copy_dart.py frog dom_frog.dart'], 133 subprocess.call(['cd ../generated ; '
134 '../../tools/copy_dart.py ../frog dom_frog.dart'],
142 shell=True); 135 shell=True);
143 136
144 if 'htmlfrog' in systems: 137 if 'htmlfrog' in systems:
145 _logger.info('Copy html_frog to ../html/frog/') 138 _logger.info('Copy html_frog to ../html/frog/')
146 subprocess.call(['cd ../../html ; ../tools/copy_dart.py frog html_frog.dart' ], 139 subprocess.call(['cd ../../html/generated ; '
140 '../../tools/copy_dart.py ../frog html_frog.dart'],
147 shell=True); 141 shell=True);
148 142
149 if 'htmldartium' in systems: 143 if 'htmldartium' in systems:
150 _logger.info('Copy html_dartium to ../html/dartium/') 144 _logger.info('Copy html_dartium to ../html/dartium/')
151 subprocess.call(['cd ../../html ; ../tools/copy_dart.py dartium html_dartium .dart'], 145 subprocess.call(['cd ../../html/generated ; '
146 '../../tools/copy_dart.py ../dartium html_dartium.dart'],
147 shell=True);
148
149 # Copy dummy DOM where dartc build expects it.
150 if 'dummy' in systems:
151 _logger.info('Copy dom_dummy to dom.dart')
152 subprocess.call(['cd ../generated ; '
153 '../../tools/copy_dart.py dummy dom_dummy.dart ;'
154 'cp dummy/dom_dummy.dart ../dom.dart'],
152 shell=True); 155 shell=True);
153 156
154 def main(): 157 def main():
155 parser = optparse.OptionParser() 158 parser = optparse.OptionParser()
156 parser.add_option('--systems', dest='systems', 159 parser.add_option('--systems', dest='systems',
157 action='store', type='string', 160 action='store', type='string',
158 default='frog,dummy,wrapping,htmlfrog,htmldartium', 161 default='frog,dummy,wrapping,htmlfrog,htmldartium',
159 help='Systems to generate (frog, native, dummy, ' 162 help='Systems to generate (frog, native, dummy, '
160 'htmlfrog, htmldartium)') 163 'htmlfrog, htmldartium)')
161 parser.add_option('--output-dir', dest='output_dir', 164 parser.add_option('--output-dir', dest='output_dir',
(...skipping 10 matching lines...) Expand all
172 current_dir = os.path.dirname(__file__) 175 current_dir = os.path.dirname(__file__)
173 systems = options.systems.split(',') 176 systems = options.systems.split(',')
174 html_system_names = ['htmldartium', 'htmlfrog'] 177 html_system_names = ['htmldartium', 'htmlfrog']
175 html_systems = [s for s in systems if s in html_system_names] 178 html_systems = [s for s in systems if s in html_system_names]
176 dom_systems = [s for s in systems if s not in html_system_names] 179 dom_systems = [s for s in systems if s not in html_system_names]
177 180
178 use_database_cache = options.use_database_cache 181 use_database_cache = options.use_database_cache
179 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) 182 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf'))
180 183
181 if dom_systems: 184 if dom_systems:
182 output_dir = options.output_dir or os.path.join(current_dir, '..') 185 output_dir = options.output_dir or os.path.join(current_dir,
186 '../generated')
183 GenerateDOM(dom_systems, False, output_dir, use_database_cache) 187 GenerateDOM(dom_systems, False, output_dir, use_database_cache)
184 188
185 # Copy dummy DOM where dartc build expects it.
186 if 'dummy' in systems:
187 # TODO(sra): Make other tools pick this up directly, or do a copy_dart int o
188 # a specific directory.
189 source = os.path.join(output_dir, 'dom_dummy.dart')
190 target = os.path.join(output_dir, 'dom.dart')
191 shutil.copyfile(source, target)
192
193 if html_systems: 189 if html_systems:
194 output_dir = options.output_dir or os.path.join(current_dir, '../../html') 190 output_dir = options.output_dir or os.path.join(current_dir,
191 '../../html/generated')
195 GenerateDOM(html_systems, True, output_dir, use_database_cache or dom_system s) 192 GenerateDOM(html_systems, True, output_dir, use_database_cache or dom_system s)
196 193
197 if __name__ == '__main__': 194 if __name__ == '__main__':
198 sys.exit(main()) 195 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698