| 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 sys | 11 import sys |
| 12 | 12 |
| 13 # TODO(antonm): most probably should go away or be autogenerated on IDLs roll. | 13 FEATURE_DISABLED = [ |
| 14 DEFAULT_FEATURE_DEFINES = [ | |
| 15 # Enabled Chrome WebKit build. | |
| 16 'ENABLE_3D_PLUGIN', | |
| 17 'ENABLE_3D_RENDERING', | |
| 18 'ENABLE_ACCELERATED_2D_CANVAS', | |
| 19 'ENABLE_BATTERY_STATUS', | 14 'ENABLE_BATTERY_STATUS', |
| 15 # Triage. |
| 16 'ENABLE_CANVAS_PATH', |
| 17 'ENABLE_CANVAS_PROXY', |
| 18 'ENABLE_CSS3_CONDITIONAL_RULES', |
| 19 'ENABLE_CSS_DEVICE_ADAPTATION', |
| 20 'ENABLE_CSS_REGIONS', |
| 21 'ENABLE_CUSTOM_ELEMENTS', |
| 22 'ENABLE_DIALOG_ELEMENT', |
| 23 'ENABLE_ENCRYPTED_MEDIA_V2', |
| 24 'ENABLE_FONT_LOAD_EVENTS', |
| 25 'ENABLE_INSPECTOR', |
| 26 'ENABLE_MEDIA_CAPTURE', |
| 27 'ENABLE_MICRODATA', |
| 28 'ENABLE_NAVIGATOR_CONTENT_UTILS', |
| 29 'ENABLE_ORIENTATION_EVENTS', |
| 30 'ENABLE_PERFORMANCE_TIMELINE', |
| 31 'ENABLE_PROXIMITY_EVENTS', |
| 32 'ENABLE_REQUEST_AUTOCOMPLETE', |
| 33 'ENABLE_RESOURCE_TIMING', |
| 34 'ENABLE_SPEECH_SYNTHESIS', |
| 35 'ENABLE_USER_TIMING', |
| 36 'ENABLE_VIDEO_TRACK ', |
| 37 'ENABLE_XHR_TIMEOUT' |
| 38 ] |
| 39 |
| 40 FEATURE_DEFINES = [ |
| 20 'ENABLE_BLOB', | 41 'ENABLE_BLOB', |
| 21 'ENABLE_BLOB_SLICE', | |
| 22 'ENABLE_CALENDAR_PICKER', | 42 'ENABLE_CALENDAR_PICKER', |
| 23 'ENABLE_CHANNEL_MESSAGING', | |
| 24 'ENABLE_CSS_FILTERS', | 43 'ENABLE_CSS_FILTERS', |
| 25 'ENABLE_CSS_IMAGE_SET', | |
| 26 'ENABLE_CSS_SHADERS', | 44 'ENABLE_CSS_SHADERS', |
| 27 'ENABLE_DART', | |
| 28 'ENABLE_DATA_TRANSFER_ITEMS', | |
| 29 'ENABLE_DATALIST_ELEMENT', | 45 'ENABLE_DATALIST_ELEMENT', |
| 30 'ENABLE_DETAILS', | |
| 31 'ENABLE_DETAILS_ELEMENT', | 46 'ENABLE_DETAILS_ELEMENT', |
| 32 'ENABLE_DEVICE_ORIENTATION', | 47 'ENABLE_DEVICE_ORIENTATION', |
| 33 'ENABLE_DIRECTORY_UPLOAD', | 48 'ENABLE_DIRECTORY_UPLOAD', |
| 34 'ENABLE_DOWNLOAD_ATTRIBUTE', | 49 'ENABLE_DOWNLOAD_ATTRIBUTE', |
| 35 'ENABLE_ENCRYPTED_MEDIA', | 50 'ENABLE_ENCRYPTED_MEDIA', |
| 36 'ENABLE_FILE_SYSTEM', | 51 'ENABLE_FILE_SYSTEM', |
| 37 'ENABLE_FILTERS', | 52 'ENABLE_FILTERS', |
| 38 'ENABLE_FULLSCREEN_API', | |
| 39 'ENABLE_GAMEPAD', | 53 'ENABLE_GAMEPAD', |
| 40 'ENABLE_GEOLOCATION', | 54 'ENABLE_GEOLOCATION', |
| 41 'ENABLE_GESTURE_EVENTS', | |
| 42 'ENABLE_INDEXED_DATABASE', | |
| 43 'ENABLE_INPUT_SPEECH', | 55 'ENABLE_INPUT_SPEECH', |
| 44 'ENABLE_INPUT_TYPE_COLOR', | |
| 45 'ENABLE_INPUT_TYPE_DATE', | |
| 46 'ENABLE_JAVASCRIPT_DEBUGGER', | 56 'ENABLE_JAVASCRIPT_DEBUGGER', |
| 47 'ENABLE_JAVASCRIPT_I18N_API', | |
| 48 'ENABLE_LEGACY_NOTIFICATIONS', | 57 'ENABLE_LEGACY_NOTIFICATIONS', |
| 49 'ENABLE_LINK_PREFETCH', | |
| 50 'ENABLE_MEDIA_SOURCE', | |
| 51 'ENABLE_MEDIA_STATISTICS', | 58 'ENABLE_MEDIA_STATISTICS', |
| 52 'ENABLE_MEDIA_STREAM', | 59 'ENABLE_MEDIA_STREAM', |
| 53 'ENABLE_METER_ELEMENT', | 60 'ENABLE_METER_ELEMENT', |
| 54 'ENABLE_METER_TAG', | |
| 55 'ENABLE_MHTML', | |
| 56 'ENABLE_NOTIFICATIONS', | 61 'ENABLE_NOTIFICATIONS', |
| 57 'ENABLE_OVERFLOW_SCROLLING', | |
| 58 'ENABLE_PAGE_POPUP', | 62 'ENABLE_PAGE_POPUP', |
| 59 'ENABLE_PAGE_VISIBILITY_API', | |
| 60 'ENABLE_POINTER_LOCK', | 63 'ENABLE_POINTER_LOCK', |
| 61 'ENABLE_PROGRESS_ELEMENT', | 64 'ENABLE_PROGRESS_ELEMENT', |
| 62 'ENABLE_PROGRESS_TAG', | |
| 63 'ENABLE_QUOTA', | 65 'ENABLE_QUOTA', |
| 64 'ENABLE_REGISTER_PROTOCOL_HANDLER', | |
| 65 'ENABLE_REQUEST_ANIMATION_FRAME', | 66 'ENABLE_REQUEST_ANIMATION_FRAME', |
| 66 'ENABLE_RUBY', | |
| 67 'ENABLE_SANDBOX', | |
| 68 'ENABLE_SCRIPTED_SPEECH', | 67 'ENABLE_SCRIPTED_SPEECH', |
| 69 'ENABLE_SHADOW_DOM', | 68 'ENABLE_SHADOW_DOM', |
| 70 'ENABLE_SHARED_WORKERS', | 69 'ENABLE_SHARED_WORKERS', |
| 71 'ENABLE_SMOOTH_SCROLLING', | |
| 72 'ENABLE_SQL_DATABASE', | 70 'ENABLE_SQL_DATABASE', |
| 73 'ENABLE_STYLE_SCOPED', | 71 'ENABLE_STYLE_SCOPED', |
| 74 'ENABLE_SVG', | 72 'ENABLE_SVG', |
| 75 'ENABLE_SVG_FONTS', | 73 'ENABLE_SVG_FONTS', |
| 76 'ENABLE_TOUCH_EVENTS', | 74 'ENABLE_TOUCH_EVENTS', |
| 77 'ENABLE_V8_SCRIPT_DEBUG_SERVER', | |
| 78 'ENABLE_VIDEO', | 75 'ENABLE_VIDEO', |
| 79 'ENABLE_VIDEO_TRACK', | 76 'ENABLE_VIDEO_TRACK', |
| 80 'ENABLE_VIEWPORT', | |
| 81 'ENABLE_WEBGL', | 77 'ENABLE_WEBGL', |
| 82 'ENABLE_WEB_AUDIO', | 78 'ENABLE_WEB_AUDIO', |
| 83 'ENABLE_WEB_INTENTS', | |
| 84 'ENABLE_WEB_SOCKETS', | 79 'ENABLE_WEB_SOCKETS', |
| 85 'ENABLE_WEB_TIMING', | 80 'ENABLE_WEB_TIMING', |
| 86 'ENABLE_WORKERS', | 81 'ENABLE_WORKERS', |
| 87 'ENABLE_XHR_RESPONSE_BLOB', | |
| 88 'ENABLE_XSLT', | 82 'ENABLE_XSLT', |
| 89 ] | 83 ] |
| 90 | 84 |
| 91 def build_database(idl_files, database_dir, feature_defines=None, | 85 def build_database(idl_files, database_dir, parallel=False): |
| 92 parallel=False): | |
| 93 """This code reconstructs the FremontCut IDL database from W3C, | 86 """This code reconstructs the FremontCut IDL database from W3C, |
| 94 WebKit and Dart IDL files.""" | 87 WebKit and Dart IDL files.""" |
| 95 current_dir = os.path.dirname(__file__) | 88 current_dir = os.path.dirname(__file__) |
| 96 logging.config.fileConfig(os.path.join(current_dir, "logging.conf")) | 89 logging.config.fileConfig(os.path.join(current_dir, "logging.conf")) |
| 97 | 90 |
| 98 db = database.Database(database_dir) | 91 db = database.Database(database_dir) |
| 99 | 92 |
| 100 # Delete all existing IDLs in the DB. | 93 # Delete all existing IDLs in the DB. |
| 101 db.Delete() | 94 db.Delete() |
| 102 | 95 |
| 103 builder = databasebuilder.DatabaseBuilder(db) | 96 builder = databasebuilder.DatabaseBuilder(db) |
| 104 | 97 |
| 105 # TODO(vsm): Move this to a README. | 98 # TODO(vsm): Move this to a README. |
| 106 # This is the Dart SVN revision. | 99 # This is the Dart SVN revision. |
| 107 webkit_revision = '1060' | 100 webkit_revision = '1060' |
| 108 | 101 |
| 109 # TODO(vsm): Reconcile what is exposed here and inside WebKit code | 102 # TODO(vsm): Reconcile what is exposed here and inside WebKit code |
| 110 # generation. We need to recheck this periodically for now. | 103 # generation. We need to recheck this periodically for now. |
| 111 webkit_defines = [ 'LANGUAGE_DART', 'LANGUAGE_JAVASCRIPT' ] | 104 webkit_defines = [ 'LANGUAGE_DART', 'LANGUAGE_JAVASCRIPT' ] |
| 112 if feature_defines is None: | |
| 113 feature_defines = DEFAULT_FEATURE_DEFINES | |
| 114 | 105 |
| 115 webkit_options = databasebuilder.DatabaseBuilderOptions( | 106 webkit_options = databasebuilder.DatabaseBuilderOptions( |
| 116 idl_syntax=idlparser.WEBKIT_SYNTAX, | 107 idl_syntax=idlparser.WEBKIT_SYNTAX, |
| 117 # TODO(vsm): What else should we define as on when processing IDL? | 108 # TODO(vsm): What else should we define as on when processing IDL? |
| 118 idl_defines=webkit_defines + feature_defines, | 109 idl_defines=webkit_defines + FEATURE_DEFINES, |
| 119 source='WebKit', | 110 source='WebKit', |
| 120 source_attributes={'revision': webkit_revision}) | 111 source_attributes={'revision': webkit_revision}) |
| 121 | 112 |
| 122 # Import WebKit IDLs. | 113 # Import WebKit IDLs. |
| 123 builder.import_idl_files(idl_files, webkit_options, parallel) | 114 builder.import_idl_files(idl_files, webkit_options, parallel) |
| 124 | 115 |
| 125 # Import Dart idl: | 116 # Import Dart idl: |
| 126 dart_options = databasebuilder.DatabaseBuilderOptions( | 117 dart_options = databasebuilder.DatabaseBuilderOptions( |
| 127 idl_syntax=idlparser.FREMONTCUT_SYNTAX, | 118 idl_syntax=idlparser.FREMONTCUT_SYNTAX, |
| 128 source='Dart', | 119 source='Dart', |
| 129 rename_operation_arguments_on_merge=True) | 120 rename_operation_arguments_on_merge=True) |
| 130 | 121 |
| 131 builder.import_idl_files( | 122 builder.import_idl_files( |
| 132 [ os.path.join(current_dir, '..', 'idl', 'dart', 'dart.idl') ], | 123 [ os.path.join(current_dir, '..', 'idl', 'dart', 'dart.idl') ], |
| 133 dart_options, | 124 dart_options, |
| 134 parallel) | 125 parallel) |
| 135 | 126 |
| 136 # Merging: | 127 # Merging: |
| 137 builder.merge_imported_interfaces() | 128 builder.merge_imported_interfaces() |
| 138 | 129 |
| 139 builder.fetch_constructor_data(webkit_options) | 130 builder.fetch_constructor_data(webkit_options) |
| 140 builder.fix_displacements('WebKit') | 131 builder.fix_displacements('WebKit') |
| 141 | 132 |
| 142 # Cleanup: | 133 # Cleanup: |
| 143 builder.normalize_annotations(['WebKit', 'Dart']) | 134 builder.normalize_annotations(['WebKit', 'Dart']) |
| 144 | 135 |
| 136 conditionals_met = set( |
| 137 'ENABLE_' + conditional for conditional in builder.conditionals_met) |
| 138 known_conditionals = set(FEATURE_DEFINES + FEATURE_DISABLED) |
| 139 |
| 140 unused_conditionals = known_conditionals - conditionals_met |
| 141 if unused_conditionals: |
| 142 raise Exception('There are some unused conditionals %s' % |
| 143 sorted(unused_conditionals)) |
| 144 |
| 145 unknown_conditionals = conditionals_met - known_conditionals |
| 146 if unknown_conditionals: |
| 147 raise Exception('There are some unknown conditionals %s' % |
| 148 sorted(unknown_conditionals)) |
| 149 |
| 145 db.Save() | 150 db.Save() |
| 146 return db | 151 return db |
| 147 | 152 |
| 148 def main(parallel=False): | 153 def main(parallel=False): |
| 149 current_dir = os.path.dirname(__file__) | 154 current_dir = os.path.dirname(__file__) |
| 150 | 155 |
| 151 ignored_idls = [ | 156 ignored_idls = [ |
| 152 'AbstractView.idl', | 157 'AbstractView.idl', |
| 153 ] | 158 ] |
| 154 | 159 |
| 155 idl_files = [] | 160 idl_files = [] |
| 156 | 161 |
| 157 webcore_dir = os.path.join(current_dir, '..', '..', '..', 'third_party', | 162 webcore_dir = os.path.join(current_dir, '..', '..', '..', 'third_party', |
| 158 'WebCore') | 163 'WebCore') |
| 159 if not os.path.exists(webcore_dir): | 164 if not os.path.exists(webcore_dir): |
| 160 raise RuntimeError('directory not found: %s' % webcore_dir) | 165 raise RuntimeError('directory not found: %s' % webcore_dir) |
| 161 | 166 |
| 167 DIRS_TO_IGNORE = [ |
| 168 'bindings', # Various test IDLs |
| 169 'testing', # IDLs to expose testing APIs |
| 170 'networkinfo', # Not yet used in Blink yet |
| 171 'vibration', # Not yet used in Blink yet |
| 172 ] |
| 173 |
| 162 def visitor(arg, dir_name, names): | 174 def visitor(arg, dir_name, names): |
| 163 if os.path.basename(dir_name) in ['bindings', 'testing']: | 175 if os.path.basename(dir_name) in DIRS_TO_IGNORE: |
| 164 names[:] = [] # Do not go underneath | 176 names[:] = [] # Do not go underneath |
| 165 for name in names: | 177 for name in names: |
| 166 file_name = os.path.join(dir_name, name) | 178 file_name = os.path.join(dir_name, name) |
| 167 (interface, ext) = os.path.splitext(file_name) | 179 (interface, ext) = os.path.splitext(file_name) |
| 168 if ext == '.idl' and name not in ignored_idls: | 180 if ext == '.idl' and name not in ignored_idls: |
| 169 idl_files.append(file_name) | 181 idl_files.append(file_name) |
| 170 | 182 |
| 171 os.path.walk(webcore_dir, visitor, webcore_dir) | 183 os.path.walk(webcore_dir, visitor, webcore_dir) |
| 172 | 184 |
| 173 database_dir = os.path.join(current_dir, '..', 'database') | 185 database_dir = os.path.join(current_dir, '..', 'database') |
| 174 return build_database(idl_files, database_dir, parallel=parallel) | 186 return build_database(idl_files, database_dir, parallel=parallel) |
| 175 | 187 |
| 176 if __name__ == '__main__': | 188 if __name__ == '__main__': |
| 177 sys.exit(main()) | 189 sys.exit(main()) |
| OLD | NEW |