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_system_names = ['htmldartium', 'htmlfrog'] |
175 if num_html_systems > 0 and num_html_systems < len(systems): | 175 html_systems = [s for s in systems if s in html_system_names] |
176 print 'Cannot generate html and dom bindings at the same time' | 176 dom_systems = [s for s in systems if s not in html_system_names] |
177 sys.exit(-1) | |
178 | 177 |
179 use_database_cache = options.use_database_cache | 178 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')) | 179 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) |
186 | 180 |
187 GenerateDOM(systems, generate_html_systems, output_dir, use_database_cache) | 181 if dom_systems: |
| 182 output_dir = options.output_dir or os.path.join(current_dir, '..') |
| 183 GenerateDOM(dom_systems, False, output_dir, use_database_cache) |
188 | 184 |
189 # Copy dummy DOM where dartc build expects it. | 185 # Copy dummy DOM where dartc build expects it. |
190 if 'dummy' in systems: | 186 if 'dummy' in systems: |
191 # TODO(sra): Make other tools pick this up directly, or do a copy_dart into | 187 # TODO(sra): Make other tools pick this up directly, or do a copy_dart int
o |
192 # a specific directory. | 188 # a specific directory. |
193 source = os.path.join(output_dir, 'dom_dummy.dart') | 189 source = os.path.join(output_dir, 'dom_dummy.dart') |
194 target = os.path.join(output_dir, 'dom.dart') | 190 target = os.path.join(output_dir, 'dom.dart') |
195 shutil.copyfile(source, target) | 191 shutil.copyfile(source, target) |
| 192 |
| 193 if html_systems: |
| 194 output_dir = options.output_dir or os.path.join(current_dir, '../../html') |
| 195 GenerateDOM(html_systems, True, output_dir, use_database_cache or dom_system
s) |
196 | 196 |
197 if __name__ == '__main__': | 197 if __name__ == '__main__': |
198 sys.exit(main()) | 198 sys.exit(main()) |
OLD | NEW |