Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tools/dom/scripts/fremontcutbuilder.py

Issue 444743002: Use Blink IDL parser for dart libraries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merged Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/dom/scripts/databasebuilder.py ('k') | tools/dom/scripts/go.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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', 'dart.idl') ],
79 dart_options, 85 dart_options, parallel, blink_parser, True)
80 parallel) 86
87 start_time = time.time()
81 88
82 # Merging: 89 # Merging:
83 builder.merge_imported_interfaces() 90 builder.merge_imported_interfaces(blink_parser)
84 91
85 builder.fetch_constructor_data(webkit_options) 92 builder.fetch_constructor_data(webkit_options)
86 builder.fix_displacements('WebKit') 93 builder.fix_displacements('WebKit')
87 94
88 # Cleanup: 95 # Cleanup:
89 builder.normalize_annotations(['WebKit', 'Dart']) 96 builder.normalize_annotations(['WebKit', 'Dart'])
90 97
91 conditionals_met = set( 98 conditionals_met = set(
92 'ENABLE_' + conditional for conditional in builder.conditionals_met) 99 'ENABLE_' + conditional for conditional in builder.conditionals_met)
93 known_conditionals = set(FEATURE_DEFINES + FEATURE_DISABLED) 100 known_conditionals = set(FEATURE_DEFINES + FEATURE_DISABLED)
94 101
95 unused_conditionals = known_conditionals - conditionals_met 102 unused_conditionals = known_conditionals - conditionals_met
96 if unused_conditionals: 103 if unused_conditionals:
97 _logger.warning('There are some unused conditionals %s' % 104 _logger.warning('There are some unused conditionals %s' %
98 sorted(unused_conditionals)) 105 sorted(unused_conditionals))
99 _logger.warning('Please update fremontcutbuilder.py') 106 _logger.warning('Please update fremontcutbuilder.py')
100 107
101 unknown_conditionals = conditionals_met - known_conditionals 108 unknown_conditionals = conditionals_met - known_conditionals
102 if unknown_conditionals: 109 if unknown_conditionals:
103 _logger.warning('There are some unknown conditionals %s' % 110 _logger.warning('There are some unknown conditionals %s' %
104 sorted(unknown_conditionals)) 111 sorted(unknown_conditionals))
105 _logger.warning('Please update fremontcutbuilder.py') 112 _logger.warning('Please update fremontcutbuilder.py')
106 113
107 db.Save() 114 print 'Merging interfaces %s seconds' % round(time.time() - start_time, 2)
115
116 # TODO(terry): Don't generate the database cache.
117 # db.Save()
118
108 return db 119 return db
109 120
110 def main(parallel=False): 121 def main(parallel=False, blink_parser=False, logging_level=logging.WARNING):
111 current_dir = os.path.dirname(__file__) 122 current_dir = os.path.dirname(__file__)
112 123
113 idl_files = [] 124 idl_files = []
114 125
115 # Check default location in a regular dart enlistment. 126 # Check default location in a regular dart enlistment.
116 webcore_dir = os.path.join(current_dir, '..', '..', '..', 'third_party', 127 webcore_dir = os.path.join(current_dir, '..', '..', '..', 'third_party',
117 'WebCore') 128 'WebCore')
118 129
119 if not os.path.exists(webcore_dir): 130 if not os.path.exists(webcore_dir):
120 # Check default location in a dartium enlistment. 131 # Check default location in a dartium enlistment.
121 webcore_dir = os.path.join(current_dir, '..', '..', '..', '..', 132 webcore_dir = os.path.join(current_dir, '..', '..', '..', '..',
122 'third_party', 'WebKit', 'Source') 133 'third_party', 'WebKit', 'Source')
123 134
124 if not os.path.exists(webcore_dir): 135 if not os.path.exists(webcore_dir):
125 raise RuntimeError('directory not found: %s' % webcore_dir) 136 raise RuntimeError('directory not found: %s' % webcore_dir)
126 137
127 DIRS_TO_IGNORE = [ 138 DIRS_TO_IGNORE = [
128 'bindings', # Various test IDLs 139 'bindings', # Various test IDLs
129 'testing', # IDLs to expose testing APIs 140 'testing', # IDLs to expose testing APIs
130 'networkinfo', # Not yet used in Blink yet 141 'networkinfo', # Not yet used in Blink yet
131 'vibration', # Not yet used in Blink yet 142 'vibration', # Not yet used in Blink yet
132 'inspector', 143 'inspector',
133 ] 144 ]
134 145
146 # TODO(terry): Integrate this into the htmlrenamer's _removed_html_interfaces
147 # (if possible).
148 FILES_TO_IGNORE = [
149 'InspectorFrontendHostFileSystem.idl', # Uses interfaces in inspector dir (which is ignored)
150 'WebKitGamepad.idl', # Gamepad.idl is the new one.
151 'WebKitGamepadList.idl', # GamepadList is the new one.
152 ]
153
135 def visitor(arg, dir_name, names): 154 def visitor(arg, dir_name, names):
136 if os.path.basename(dir_name) in DIRS_TO_IGNORE: 155 if os.path.basename(dir_name) in DIRS_TO_IGNORE:
137 names[:] = [] # Do not go underneath 156 names[:] = [] # Do not go underneath
138 for name in names: 157 for name in names:
139 file_name = os.path.join(dir_name, name) 158 file_name = os.path.join(dir_name, name)
140 (interface, ext) = os.path.splitext(file_name) 159 (interface, ext) = os.path.splitext(file_name)
141 if ext == '.idl': 160 if ext == '.idl' and not(name in FILES_TO_IGNORE):
142 idl_files.append(file_name) 161 idl_files.append(file_name)
143 162
144 os.path.walk(webcore_dir, visitor, webcore_dir) 163 os.path.walk(webcore_dir, visitor, webcore_dir)
145 164
146 database_dir = os.path.join(current_dir, '..', 'database') 165 database_dir = os.path.join(current_dir, '..', 'database')
147 return build_database(idl_files, database_dir, parallel=parallel) 166
167 return build_database(idl_files, database_dir, parallel=parallel,
168 blink_parser=blink_parser, logging_level=logging_level)
148 169
149 if __name__ == '__main__': 170 if __name__ == '__main__':
150 sys.exit(main()) 171 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/dom/scripts/databasebuilder.py ('k') | tools/dom/scripts/go.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698