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

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

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