OLD | NEW |
---|---|
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 | 148 |
149 if 'htmldartium' in systems: | 149 if 'htmldartium' in systems: |
150 _logger.info('Copy html_dartium to ../html/dartium/') | 150 _logger.info('Copy html_dartium to ../html/dartium/') |
151 subprocess.call(['cd ../../html ; ../tools/copy_dart.py dartium html_dartium .dart'], | 151 subprocess.call(['cd ../../html ; ../tools/copy_dart.py dartium html_dartium .dart'], |
152 shell=True); | 152 shell=True); |
153 | 153 |
154 def main(): | 154 def main(): |
155 parser = optparse.OptionParser() | 155 parser = optparse.OptionParser() |
156 parser.add_option('--systems', dest='systems', | 156 parser.add_option('--systems', dest='systems', |
157 action='store', type='string', | 157 action='store', type='string', |
158 default='frog,dummy,wrapping', | 158 default='frog,dummy,wrapping,htmlfrog,htmldartium', |
159 help='Systems to generate (frog, native, dummy, ' | 159 help='Systems to generate (frog, native, dummy, ' |
160 'htmlfrog, htmldartium)') | 160 'htmlfrog, htmldartium)') |
161 parser.add_option('--output-dir', dest='output_dir', | 161 parser.add_option('--output-dir', dest='output_dir', |
162 action='store', type='string', | 162 action='store', type='string', |
163 default=None, | 163 default=None, |
164 help='Directory to put the generated files') | 164 help='Directory to put the generated files') |
165 parser.add_option('--use-database-cache', dest='use_database_cache', | 165 parser.add_option('--use-database-cache', dest='use_database_cache', |
166 action='store_true', | 166 action='store_true', |
167 default=False, | 167 default=False, |
168 help='''Use the cached database from the previous run to | 168 help='''Use the cached database from the previous run to |
169 improve startup performance''') | 169 improve startup performance''') |
170 (options, args) = parser.parse_args() | 170 (options, args) = parser.parse_args() |
171 | 171 |
172 current_dir = os.path.dirname(__file__) | 172 current_dir = os.path.dirname(__file__) |
173 systems = options.systems.split(',') | 173 systems = options.systems.split(',') |
174 num_html_systems = ('htmlfrog' in systems) + ('htmldartium' in systems) | 174 html_systems = [] |
175 if num_html_systems > 0 and num_html_systems < len(systems): | 175 dom_systems = [] |
176 print 'Cannot generate html and dom bindings at the same time' | 176 for system in systems: |
177 sys.exit(-1) | 177 if system == 'htmlfrog' or system == 'htmldartium': |
178 html_systems.append(system) | |
179 else: | |
180 dom_systems.append(system) | |
sra1
2012/03/08 00:51:33
OK, but could be:
html_system_names = ['htmldarti
| |
178 | 181 |
179 use_database_cache = options.use_database_cache | 182 use_database_cache = options.use_database_cache |
180 generate_html_systems = ('htmlfrog' in systems) or ('htmldartium' in systems) | |
181 output_dir = options.output_dir or ( | |
182 os.path.join(current_dir, '../../html') if generate_html_systems else | |
183 os.path.join(current_dir, '..')) | |
184 | |
185 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) | 183 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) |
186 | 184 |
187 GenerateDOM(systems, generate_html_systems, output_dir, use_database_cache) | 185 if dom_systems: |
186 output_dir = options.output_dir or os.path.join(current_dir, '..') | |
187 GenerateDOM(dom_systems, False, output_dir, use_database_cache) | |
188 | 188 |
189 # Copy dummy DOM where dartc build expects it. | 189 # Copy dummy DOM where dartc build expects it. |
190 if 'dummy' in systems: | 190 if 'dummy' in systems: |
191 # TODO(sra): Make other tools pick this up directly, or do a copy_dart into | 191 # TODO(sra): Make other tools pick this up directly, or do a copy_dart int o |
192 # a specific directory. | 192 # a specific directory. |
193 source = os.path.join(output_dir, 'dom_dummy.dart') | 193 source = os.path.join(output_dir, 'dom_dummy.dart') |
194 target = os.path.join(output_dir, 'dom.dart') | 194 target = os.path.join(output_dir, 'dom.dart') |
195 shutil.copyfile(source, target) | 195 shutil.copyfile(source, target) |
196 | |
197 if html_systems: | |
198 output_dir = options.output_dir or os.path.join(current_dir, '../../html') | |
199 GenerateDOM(html_systems, True, output_dir, use_database_cache or dom_system s) | |
196 | 200 |
197 if __name__ == '__main__': | 201 if __name__ == '__main__': |
198 sys.exit(main()) | 202 sys.exit(main()) |
OLD | NEW |