| 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 import database | 6 import database |
| 7 import databasebuilder | 7 import databasebuilder |
| 8 import idlparser | 8 import idlparser |
| 9 import logging.config | 9 import logging.config |
| 10 import os.path | 10 import os.path |
| 11 import tempfile | 11 import tempfile |
| 12 import sys | 12 import sys |
| 13 | 13 |
| 14 def build_database(idl_list_file_name): | 14 def build_database(idl_list_file_name, database_dir): |
| 15 """This code reconstructs the FremontCut IDL database from W3C, | 15 """This code reconstructs the FremontCut IDL database from W3C, |
| 16 WebKit and Dart IDL files.""" | 16 WebKit and Dart IDL files.""" |
| 17 current_dir = os.path.dirname(__file__) | 17 current_dir = os.path.dirname(__file__) |
| 18 logging.config.fileConfig(os.path.join(current_dir, "logging.conf")) | 18 logging.config.fileConfig(os.path.join(current_dir, "logging.conf")) |
| 19 | 19 |
| 20 db = database.Database(os.path.join(current_dir, '..', 'database')) | 20 db = database.Database(database_dir) |
| 21 | 21 |
| 22 # Delete all existing IDLs in the DB. | 22 # Delete all existing IDLs in the DB. |
| 23 db.Delete() | 23 db.Delete() |
| 24 | 24 |
| 25 builder = databasebuilder.DatabaseBuilder(db) | 25 builder = databasebuilder.DatabaseBuilder(db) |
| 26 | 26 |
| 27 # TODO(vsm): Move this to a README. | 27 # TODO(vsm): Move this to a README. |
| 28 # This is the Dart SVN revision. | 28 # This is the Dart SVN revision. |
| 29 webkit_revision = '1060' | 29 webkit_revision = '1060' |
| 30 | 30 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 builder.merge_imported_interfaces(optional_argument_whitelist) | 153 builder.merge_imported_interfaces(optional_argument_whitelist) |
| 154 | 154 |
| 155 builder.fix_displacements('WebKit') | 155 builder.fix_displacements('WebKit') |
| 156 | 156 |
| 157 # Cleanup: | 157 # Cleanup: |
| 158 builder.normalize_annotations(['WebKit', 'Dart']) | 158 builder.normalize_annotations(['WebKit', 'Dart']) |
| 159 | 159 |
| 160 db.Save() | 160 db.Save() |
| 161 | 161 |
| 162 def main(): | 162 def main(): |
| 163 current_dir = os.path.dirname(__file__) |
| 164 |
| 163 webkit_dirs = [ | 165 webkit_dirs = [ |
| 164 'Modules/speech', | 166 'Modules/speech', |
| 165 'Modules/indexeddb', | 167 'Modules/indexeddb', |
| 166 'css', | 168 'css', |
| 167 'dom', | 169 'dom', |
| 168 'fileapi', | 170 'fileapi', |
| 169 'Modules/filesystem', | 171 'Modules/filesystem', |
| 170 'html', | 172 'html', |
| 171 'html/canvas', | 173 'html/canvas', |
| 172 'inspector', | 174 'inspector', |
| 173 'loader', | 175 'loader', |
| 174 'loader/appcache', | 176 'loader/appcache', |
| 175 'Modules/mediastream', | 177 'Modules/mediastream', |
| 176 'Modules/geolocation', | 178 'Modules/geolocation', |
| 177 'notifications', | 179 'notifications', |
| 178 'page', | 180 'page', |
| 179 'plugins', | 181 'plugins', |
| 180 'storage', | 182 'storage', |
| 181 'Modules/webdatabase', | 183 'Modules/webdatabase', |
| 182 'svg', | 184 'svg', |
| 183 'Modules/webaudio', | 185 'Modules/webaudio', |
| 184 'Modules/websockets', | 186 'Modules/websockets', |
| 185 'workers', | 187 'workers', |
| 186 'xml', | 188 'xml', |
| 187 ] | 189 ] |
| 188 | 190 |
| 189 (idl_list_file, idl_list_file_name) = tempfile.mkstemp() | 191 (idl_list_file, idl_list_file_name) = tempfile.mkstemp() |
| 190 | 192 |
| 191 webcore_dir = os.path.join(os.path.dirname(__file__), '..', '..', '..', | 193 webcore_dir = os.path.join(current_dir, '..', '..', '..', |
| 192 'third_party', 'WebCore') | 194 'third_party', 'WebCore') |
| 193 if not os.path.exists(webcore_dir): | 195 if not os.path.exists(webcore_dir): |
| 194 raise RuntimeError('directory not found: %s' % webcore_dir) | 196 raise RuntimeError('directory not found: %s' % webcore_dir) |
| 195 | 197 |
| 196 def visitor(arg, dir_name, names): | 198 def visitor(arg, dir_name, names): |
| 197 for name in names: | 199 for name in names: |
| 198 file_name = os.path.join(dir_name, name) | 200 file_name = os.path.join(dir_name, name) |
| 199 (interface, ext) = os.path.splitext(file_name) | 201 (interface, ext) = os.path.splitext(file_name) |
| 200 if ext == '.idl' and not name.startswith('._'): | 202 if ext == '.idl' and not name.startswith('._'): |
| 201 path = os.path.relpath(file_name, os.path.dirname(idl_list_file_name)) | 203 path = os.path.relpath(file_name, os.path.dirname(idl_list_file_name)) |
| 202 os.write(idl_list_file, '%s\n' % path) | 204 os.write(idl_list_file, '%s\n' % path) |
| 203 | 205 |
| 204 for dir_name in webkit_dirs: | 206 for dir_name in webkit_dirs: |
| 205 dir_path = os.path.join(webcore_dir, dir_name) | 207 dir_path = os.path.join(webcore_dir, dir_name) |
| 206 os.path.walk(dir_path, visitor, None) | 208 os.path.walk(dir_path, visitor, None) |
| 207 | 209 |
| 208 os.close(idl_list_file) | 210 os.close(idl_list_file) |
| 209 | 211 |
| 210 return build_database(idl_list_file_name) | 212 database_dir = os.path.join(current_dir, '..', 'database') |
| 213 return build_database(idl_list_file_name, database_dir) |
| 211 | 214 |
| 212 if __name__ == '__main__': | 215 if __name__ == '__main__': |
| 213 sys.exit(main()) | 216 sys.exit(main()) |
| OLD | NEW |