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 import time | |
12 | 13 |
13 _logger = logging.getLogger('fremontcutbuilder') | 14 _logger = logging.getLogger('fremontcutbuilder') |
14 | 15 |
15 # See: | 16 # See: |
16 # http://src.chromium.org/viewvc/multivm/trunk/webkit/Source/core/features.gypi | 17 # http://src.chromium.org/viewvc/multivm/trunk/webkit/Source/core/features.gypi |
17 # for ENABLE_* flags defined in Chromium / Blink. | 18 # for ENABLE_* flags defined in Chromium / Blink. |
18 # We list all ENABLE flags used in IDL in one of these two lists. | 19 # We list all ENABLE flags used in IDL in one of these two lists. |
19 FEATURE_DISABLED = [ | 20 FEATURE_DISABLED = [ |
20 'ENABLE_CUSTOM_SCHEME_HANDLER', | 21 'ENABLE_CUSTOM_SCHEME_HANDLER', |
21 'ENABLE_MEDIA_CAPTURE', # Only enabled on Android. | 22 'ENABLE_MEDIA_CAPTURE', # Only enabled on Android. |
22 'ENABLE_ORIENTATION_EVENTS', # Only enabled on Android. | 23 'ENABLE_ORIENTATION_EVENTS', # Only enabled on Android. |
23 'ENABLE_WEBVTT_REGIONS', | 24 'ENABLE_WEBVTT_REGIONS', |
24 ] | 25 ] |
25 | 26 |
26 FEATURE_DEFINES = [ | 27 FEATURE_DEFINES = [ |
27 'ENABLE_CALENDAR_PICKER', # Not on Android | 28 'ENABLE_CALENDAR_PICKER', # Not on Android |
28 'ENABLE_ENCRYPTED_MEDIA_V2', | 29 'ENABLE_ENCRYPTED_MEDIA_V2', |
29 'ENABLE_INPUT_SPEECH', # Not on Android | 30 'ENABLE_INPUT_SPEECH', # Not on Android |
30 'ENABLE_LEGACY_NOTIFICATIONS', # Not on Android | 31 'ENABLE_LEGACY_NOTIFICATIONS', # Not on Android |
31 'ENABLE_NAVIGATOR_CONTENT_UTILS', # Not on Android | 32 'ENABLE_NAVIGATOR_CONTENT_UTILS', # Not on Android |
32 'ENABLE_NOTIFICATIONS', # Not on Android | 33 'ENABLE_NOTIFICATIONS', # Not on Android |
33 'ENABLE_SVG_FONTS', | 34 'ENABLE_SVG_FONTS', |
34 'ENABLE_WEB_AUDIO', # Not on Android | 35 'ENABLE_WEB_AUDIO', # Not on Android |
35 ] | 36 ] |
36 | 37 |
37 def build_database(idl_files, database_dir, feature_defines=None, parallel=False ): | 38 def build_database(idl_files, database_dir, feature_defines=None, parallel=False , |
39 blink_parser=False, logging_level=logging.WARNING): | |
38 """This code reconstructs the FremontCut IDL database from W3C, | 40 """This code reconstructs the FremontCut IDL database from W3C, |
39 WebKit and Dart IDL files.""" | 41 WebKit and Dart IDL files.""" |
40 current_dir = os.path.dirname(__file__) | 42 current_dir = os.path.dirname(__file__) |
41 logging.config.fileConfig(os.path.join(current_dir, "logging.conf")) | 43 logging.config.fileConfig(os.path.join(current_dir, "logging.conf")) |
42 | 44 |
45 _logger.setLevel(logging_level) | |
46 | |
43 db = database.Database(database_dir) | 47 db = database.Database(database_dir) |
44 | 48 |
45 # Delete all existing IDLs in the DB. | 49 # Delete all existing IDLs in the DB. |
46 db.Delete() | 50 db.Delete() |
47 | 51 |
48 builder = databasebuilder.DatabaseBuilder(db) | 52 builder = databasebuilder.DatabaseBuilder(db) |
49 | 53 |
50 # TODO(vsm): Move this to a README. | 54 # TODO(vsm): Move this to a README. |
51 # This is the Dart SVN revision. | 55 # This is the Dart SVN revision. |
52 webkit_revision = '1060' | 56 webkit_revision = '1060' |
53 | 57 |
54 # TODO(vsm): Reconcile what is exposed here and inside WebKit code | 58 # TODO(vsm): Reconcile what is exposed here and inside WebKit code |
55 # generation. We need to recheck this periodically for now. | 59 # generation. We need to recheck this periodically for now. |
56 webkit_defines = [ 'LANGUAGE_DART', 'LANGUAGE_JAVASCRIPT' ] | 60 webkit_defines = [ 'LANGUAGE_DART', 'LANGUAGE_JAVASCRIPT' ] |
57 | 61 |
58 if feature_defines is None: | 62 if feature_defines is None: |
59 feature_defines = FEATURE_DEFINES | 63 feature_defines = FEATURE_DEFINES |
60 | 64 |
61 webkit_options = databasebuilder.DatabaseBuilderOptions( | 65 webkit_options = databasebuilder.DatabaseBuilderOptions( |
62 idl_syntax=idlparser.WEBKIT_SYNTAX, | 66 idl_syntax=idlparser.WEBKIT_SYNTAX, |
63 # TODO(vsm): What else should we define as on when processing IDL? | 67 # TODO(vsm): What else should we define as on when processing IDL? |
64 idl_defines=webkit_defines + feature_defines, | 68 idl_defines=webkit_defines + feature_defines, |
65 source='WebKit', | 69 source='WebKit', |
66 source_attributes={'revision': webkit_revision}) | 70 source_attributes={'revision': webkit_revision}, |
71 logging_level=logging_level) | |
67 | 72 |
68 # Import WebKit IDLs. | 73 # Import WebKit IDLs. |
69 builder.import_idl_files(idl_files, webkit_options, parallel) | 74 builder.import_idl_files(idl_files, webkit_options, parallel, blink_parser, Fa lse) |
70 | 75 |
71 # Import Dart idl: | 76 # Import Dart idl: |
72 dart_options = databasebuilder.DatabaseBuilderOptions( | 77 dart_options = databasebuilder.DatabaseBuilderOptions( |
73 idl_syntax=idlparser.FREMONTCUT_SYNTAX, | 78 idl_syntax=idlparser.FREMONTCUT_SYNTAX, |
74 source='Dart', | 79 source='Dart', |
75 rename_operation_arguments_on_merge=True) | 80 rename_operation_arguments_on_merge=True, |
81 logging_level=logging_level) | |
76 | 82 |
77 builder.import_idl_files( | 83 builder.import_idl_files( |
78 [ os.path.join(current_dir, '..', 'idl', 'dart', 'dart.idl') ], | 84 [ os.path.join(current_dir, '..', 'idl', 'dart', |
79 dart_options, | 85 'new_dart.idl' if blink_parser else 'dart.idl') ], |
80 parallel) | 86 dart_options, parallel, blink_parser, True) |
87 | |
88 start_time = time.time() | |
81 | 89 |
82 # Merging: | 90 # Merging: |
83 builder.merge_imported_interfaces() | 91 builder.merge_imported_interfaces(blink_parser) |
84 | 92 |
85 builder.fetch_constructor_data(webkit_options) | 93 builder.fetch_constructor_data(webkit_options) |
86 builder.fix_displacements('WebKit') | 94 builder.fix_displacements('WebKit') |
87 | 95 |
88 # Cleanup: | 96 # Cleanup: |
89 builder.normalize_annotations(['WebKit', 'Dart']) | 97 builder.normalize_annotations(['WebKit', 'Dart']) |
90 | 98 |
91 conditionals_met = set( | 99 conditionals_met = set( |
92 'ENABLE_' + conditional for conditional in builder.conditionals_met) | 100 'ENABLE_' + conditional for conditional in builder.conditionals_met) |
93 known_conditionals = set(FEATURE_DEFINES + FEATURE_DISABLED) | 101 known_conditionals = set(FEATURE_DEFINES + FEATURE_DISABLED) |
94 | 102 |
95 unused_conditionals = known_conditionals - conditionals_met | 103 unused_conditionals = known_conditionals - conditionals_met |
96 if unused_conditionals: | 104 if unused_conditionals: |
97 _logger.warning('There are some unused conditionals %s' % | 105 _logger.warning('There are some unused conditionals %s' % |
98 sorted(unused_conditionals)) | 106 sorted(unused_conditionals)) |
99 _logger.warning('Please update fremontcutbuilder.py') | 107 _logger.warning('Please update fremontcutbuilder.py') |
100 | 108 |
101 unknown_conditionals = conditionals_met - known_conditionals | 109 unknown_conditionals = conditionals_met - known_conditionals |
102 if unknown_conditionals: | 110 if unknown_conditionals: |
103 _logger.warning('There are some unknown conditionals %s' % | 111 _logger.warning('There are some unknown conditionals %s' % |
104 sorted(unknown_conditionals)) | 112 sorted(unknown_conditionals)) |
105 _logger.warning('Please update fremontcutbuilder.py') | 113 _logger.warning('Please update fremontcutbuilder.py') |
106 | 114 |
107 db.Save() | 115 print 'Merging interfaces %s seconds' % round(time.time() - start_time, 2) |
116 | |
117 # TODO(terry): Don't generate the database cache. | |
118 # db.Save() | |
119 | |
108 return db | 120 return db |
109 | 121 |
110 def main(parallel=False): | 122 def main(parallel=False, blink_parser=False, logging_level=logging.WARNING): |
111 current_dir = os.path.dirname(__file__) | 123 current_dir = os.path.dirname(__file__) |
112 | 124 |
113 idl_files = [] | 125 idl_files = [] |
114 | 126 |
115 # Check default location in a regular dart enlistment. | 127 # Check default location in a regular dart enlistment. |
116 webcore_dir = os.path.join(current_dir, '..', '..', '..', 'third_party', | 128 if blink_parser: |
117 'WebCore') | 129 # TODO(terry): Parse the Roll 37 IDLs |
130 webcore_dir = os.path.join(current_dir, '..', '..', '..', 'third_party', | |
vsm
2014/09/03 22:23:41
You'll need to update this path.
terry
2014/09/05 20:22:55
The below old webcore_dir will be used.
| |
131 'chrome', 'third_party', 'WebKit', 'Source') | |
132 else: | |
133 webcore_dir = os.path.join(current_dir, '..', '..', '..', 'third_party', | |
134 'WebCore') | |
118 | 135 |
119 if not os.path.exists(webcore_dir): | 136 if not os.path.exists(webcore_dir): |
120 # Check default location in a dartium enlistment. | 137 # Check default location in a dartium enlistment. |
121 webcore_dir = os.path.join(current_dir, '..', '..', '..', '..', | 138 webcore_dir = os.path.join(current_dir, '..', '..', '..', '..', |
122 'third_party', 'WebKit', 'Source') | 139 'third_party', 'WebKit', 'Source') |
123 | 140 |
124 if not os.path.exists(webcore_dir): | 141 if not os.path.exists(webcore_dir): |
125 raise RuntimeError('directory not found: %s' % webcore_dir) | 142 raise RuntimeError('directory not found: %s' % webcore_dir) |
126 | 143 |
127 DIRS_TO_IGNORE = [ | 144 DIRS_TO_IGNORE = [ |
128 'bindings', # Various test IDLs | 145 'bindings', # Various test IDLs |
129 'testing', # IDLs to expose testing APIs | 146 'testing', # IDLs to expose testing APIs |
130 'networkinfo', # Not yet used in Blink yet | 147 'networkinfo', # Not yet used in Blink yet |
131 'vibration', # Not yet used in Blink yet | 148 'vibration', # Not yet used in Blink yet |
132 'inspector', | 149 'inspector', |
133 ] | 150 ] |
134 | 151 |
152 FILES_TO_IGNORE = [ | |
vsm
2014/09/03 22:23:41
We've got some logic for this in htmlrenamer.py -
terry
2014/09/05 20:22:55
Quickly tried it and it didn't work. I'll look at
| |
153 'InspectorFrontendHostFileSystem.idl', # Uses interfaces in inspector dir (which is ignored) | |
154 'WebKitGamepad.idl', # Gamepad.idl is the new one. | |
155 'WebKitGamepadList.idl', # GamepadList is the new one. | |
156 ] | |
157 | |
135 def visitor(arg, dir_name, names): | 158 def visitor(arg, dir_name, names): |
136 if os.path.basename(dir_name) in DIRS_TO_IGNORE: | 159 if os.path.basename(dir_name) in DIRS_TO_IGNORE: |
137 names[:] = [] # Do not go underneath | 160 names[:] = [] # Do not go underneath |
138 for name in names: | 161 for name in names: |
139 file_name = os.path.join(dir_name, name) | 162 file_name = os.path.join(dir_name, name) |
140 (interface, ext) = os.path.splitext(file_name) | 163 (interface, ext) = os.path.splitext(file_name) |
141 if ext == '.idl': | 164 if ext == '.idl' and not(name in FILES_TO_IGNORE): |
142 idl_files.append(file_name) | 165 idl_files.append(file_name) |
143 | 166 |
144 os.path.walk(webcore_dir, visitor, webcore_dir) | 167 os.path.walk(webcore_dir, visitor, webcore_dir) |
145 | 168 |
146 database_dir = os.path.join(current_dir, '..', 'database') | 169 database_dir = os.path.join(current_dir, '..', 'database') |
147 return build_database(idl_files, database_dir, parallel=parallel) | 170 |
171 return build_database(idl_files, database_dir, parallel=parallel, | |
172 blink_parser=blink_parser, logging_level=logging_level) | |
148 | 173 |
149 if __name__ == '__main__': | 174 if __name__ == '__main__': |
150 sys.exit(main()) | 175 sys.exit(main()) |
OLD | NEW |