Chromium Code Reviews| 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 os.path | 9 import os.path |
| 10 import tempfile | |
| 10 import logging.config | 11 import logging.config |
| 11 import sys | 12 import sys |
| 12 | 13 |
| 13 | 14 def build_database(idl_list_file_name): |
| 14 def main(): | |
| 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(os.path.join(current_dir, '..', 'database')) |
| 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 # Import WebKit IDL files: | |
| 28 webkit_dirs = [ | |
| 29 'Modules/speech', | |
| 30 'Modules/indexeddb', | |
| 31 'css', | |
| 32 'dom', | |
| 33 'fileapi', | |
| 34 'Modules/filesystem', | |
| 35 'html', | |
| 36 'html/canvas', | |
| 37 'inspector', | |
| 38 'loader', | |
| 39 'loader/appcache', | |
| 40 'Modules/mediastream', | |
| 41 'Modules/geolocation', | |
| 42 'notifications', | |
| 43 'page', | |
| 44 'plugins', | |
| 45 'storage', | |
| 46 'Modules/webdatabase', | |
| 47 'svg', | |
| 48 'Modules/webaudio', | |
| 49 'Modules/websockets', | |
| 50 'workers', | |
| 51 'xml', | |
| 52 ] | |
| 53 | |
| 54 # TODO(vsm): Move this to a README. | 27 # TODO(vsm): Move this to a README. |
| 55 # This is the Dart SVN revision. | 28 # This is the Dart SVN revision. |
| 56 webkit_revision = '1060' | 29 webkit_revision = '1060' |
| 57 | 30 |
| 58 # TODO(vsm): Reconcile what is exposed here and inside WebKit code | 31 # TODO(vsm): Reconcile what is exposed here and inside WebKit code |
| 59 # generation. We need to recheck this periodically for now. | 32 # generation. We need to recheck this periodically for now. |
| 60 webkit_defines = [ | 33 webkit_defines = [ |
| 61 'LANGUAGE_DART', | 34 'LANGUAGE_DART', |
| 62 'LANGUAGE_JAVASCRIPT', | 35 'LANGUAGE_JAVASCRIPT', |
| 63 | 36 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 'Exception': 'DOMException', # NotificationCenter.createNotification | 116 'Exception': 'DOMException', # NotificationCenter.createNotification |
| 144 'SharedWorkerContext': 'SharedWorkerGlobalScope', | 117 'SharedWorkerContext': 'SharedWorkerGlobalScope', |
| 145 'WorkerContext': 'WorkerGlobalScope', | 118 'WorkerContext': 'WorkerGlobalScope', |
| 146 }) | 119 }) |
| 147 | 120 |
| 148 optional_argument_whitelist = [ | 121 optional_argument_whitelist = [ |
| 149 ('CSSStyleDeclaration', 'setProperty', 'priority'), | 122 ('CSSStyleDeclaration', 'setProperty', 'priority'), |
| 150 ('IDBDatabase', 'transaction', 'mode'), | 123 ('IDBDatabase', 'transaction', 'mode'), |
| 151 ] | 124 ] |
| 152 | 125 |
| 153 # Assume Dartium checkout. | 126 # Import WebKit IDLs. |
| 154 webcore_path = os.path.join(current_dir, '..', '..', '..', '..', | 127 idl_list_file = open(idl_list_file_name, 'r') |
| 155 'third_party', 'WebKit', 'Source', 'WebCore') | 128 for file_name in idl_list_file: |
| 156 | 129 file_name = file_name.rstrip() |
|
Anton Muhin
2012/04/09 13:26:29
nit: just strip to be slightly safer?
| |
| 157 if not os.path.exists(webcore_path): | 130 idl_file_name = os.path.join(os.path.dirname(idl_list_file_name), file_name) |
| 158 # Fall back to standard Dart checkout. | 131 builder.import_idl_file(idl_file_name, webkit_options) |
| 159 webcore_path = os.path.join(current_dir, '..', '..', '..', | 132 idl_list_file.close() |
| 160 'third_party', 'WebCore') | |
| 161 | |
| 162 for dir_name in webkit_dirs: | |
| 163 dir_path = os.path.join(webcore_path, dir_name) | |
| 164 builder.import_idl_directory(dir_path, webkit_options) | |
| 165 | 133 |
| 166 webkit_supplemental_options = databasebuilder.DatabaseBuilderOptions( | 134 webkit_supplemental_options = databasebuilder.DatabaseBuilderOptions( |
| 167 idl_syntax=idlparser.FREMONTCUT_SYNTAX, | 135 idl_syntax=idlparser.FREMONTCUT_SYNTAX, |
| 168 source='WebKit', | 136 source='WebKit', |
| 169 rename_operation_arguments_on_merge=True) | 137 rename_operation_arguments_on_merge=True) |
| 170 builder.import_idl_file( | 138 builder.import_idl_file( |
| 171 os.path.join(current_dir, '..', 'idl', 'dart', 'webkit-supplemental.idl'), | 139 os.path.join(current_dir, '..', 'idl', 'dart', 'webkit-supplemental.idl'), |
| 172 webkit_supplemental_options) | 140 webkit_supplemental_options) |
| 173 | 141 |
| 174 # Import Dart idl: | 142 # Import Dart idl: |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 189 # Merging: | 157 # Merging: |
| 190 builder.merge_imported_interfaces(optional_argument_whitelist) | 158 builder.merge_imported_interfaces(optional_argument_whitelist) |
| 191 | 159 |
| 192 builder.fix_displacements('WebKit') | 160 builder.fix_displacements('WebKit') |
| 193 | 161 |
| 194 # Cleanup: | 162 # Cleanup: |
| 195 builder.normalize_annotations(['WebKit', 'Dart']) | 163 builder.normalize_annotations(['WebKit', 'Dart']) |
| 196 | 164 |
| 197 db.Save() | 165 db.Save() |
| 198 | 166 |
| 167 def main(): | |
| 168 webkit_dirs = [ | |
| 169 'Modules/speech', | |
| 170 'Modules/indexeddb', | |
| 171 'css', | |
| 172 'dom', | |
| 173 'fileapi', | |
| 174 'Modules/filesystem', | |
| 175 'html', | |
| 176 'html/canvas', | |
| 177 'inspector', | |
| 178 'loader', | |
| 179 'loader/appcache', | |
| 180 'Modules/mediastream', | |
| 181 'Modules/geolocation', | |
| 182 'notifications', | |
| 183 'page', | |
| 184 'plugins', | |
| 185 'storage', | |
| 186 'Modules/webdatabase', | |
| 187 'svg', | |
| 188 'Modules/webaudio', | |
| 189 'Modules/websockets', | |
| 190 'workers', | |
| 191 'xml', | |
| 192 ] | |
| 193 | |
| 194 (idl_list_file, idl_list_file_name) = tempfile.mkstemp() | |
| 195 | |
| 196 webcore_dir = os.path.join(os.path.dirname(__file__), '..', '..', '..', | |
| 197 'third_party', 'WebCore') | |
| 198 if not os.path.exists(webcore_dir): | |
| 199 raise RuntimeError('directory not found: %s' % webcore_dir) | |
| 200 | |
| 201 def visitor(arg, dir_name, names): | |
| 202 for name in names: | |
| 203 file_name = os.path.join(dir_name, name) | |
| 204 (interface, ext) = os.path.splitext(file_name) | |
| 205 if ext == '.idl' and not name.startswith('._'): | |
| 206 path = os.path.relpath(file_name, os.path.dirname(idl_list_file_name)) | |
| 207 os.write(idl_list_file, '%s\n' % path) | |
| 208 | |
| 209 for dir_name in webkit_dirs: | |
| 210 dir_path = os.path.join(webcore_dir, dir_name) | |
| 211 os.path.walk(dir_path, visitor, None) | |
| 212 | |
| 213 os.close(idl_list_file) | |
| 214 | |
| 215 return build_database(idl_list_file_name) | |
| 216 | |
| 199 if __name__ == '__main__': | 217 if __name__ == '__main__': |
| 200 sys.exit(main()) | 218 sys.exit(main()) |
| OLD | NEW |