Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
fremontcutbuilder.py
Go to the documentation of this file.
1#!/usr/bin/env python3
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
4# BSD-style license that can be found in the LICENSE file.
5
6import database
7import databasebuilder
8import idlnode
9import logging.config
10import os.path
11import sys
12import time
13import utilities
14import dependency
15from idlnode import IDLType, resolveTypedef
16
17_logger = logging.getLogger('fremontcutbuilder')
18
19# See:
20# http://src.chromium.org/viewvc/multivm/trunk/webkit/Source/core/features.gypi
21# for ENABLE_* flags defined in Chromium / Blink.
22# We list all ENABLE flags used in IDL in one of these two lists.
23FEATURE_DISABLED = [
24 'ENABLE_CUSTOM_SCHEME_HANDLER',
25 'ENABLE_MEDIA_CAPTURE', # Only enabled on Android.
26 'ENABLE_ORIENTATION_EVENTS', # Only enabled on Android.
27 'ENABLE_WEBVTT_REGIONS',
28]
29
30FEATURE_DEFINES = [
31 'ENABLE_CALENDAR_PICKER', # Not on Android
32 'ENABLE_ENCRYPTED_MEDIA_V2',
33 'ENABLE_INPUT_SPEECH', # Not on Android
34 'ENABLE_LEGACY_NOTIFICATIONS', # Not on Android
35 'ENABLE_NAVIGATOR_CONTENT_UTILS', # Not on Android
36 'ENABLE_NOTIFICATIONS', # Not on Android
37 'ENABLE_SVG_FONTS',
38 'ENABLE_WEB_AUDIO', # Not on Android
39]
40
41
42# Resolve all typedefs encountered while parsing (see idlnode.py), resolve any typedefs not resolved
43# during parsing. This must be done before the database is created, merged, and augmented to
44# exact type matching. Typedefs can be encountered in any IDL and usage can cross IDL boundaries.
45def ResolveAllTypedefs(all_interfaces):
46 # Resolve all typedefs.
47 for interface, db_Opts in all_interfaces:
48
49 def IsIdentified(idl_node):
50 node_name = idl_node.id if idl_node.id else 'parent'
51 for idl_type in idl_node.all(idlnode.IDLType):
52 # One last check is the type a typedef in an IDL file (the typedefs
53 # are treated as global).
54 resolvedType = resolveTypedef(idl_type)
55 if (resolvedType != idl_type):
56 idl_type.id = resolvedType.id
57 idl_type.nullable = resolvedType.nullable
58 continue
59 return True
60
61 interface.constants = list(filter(IsIdentified, interface.constants))
62 interface.attributes = list(filter(IsIdentified, interface.attributes))
63 interface.operations = list(filter(IsIdentified, interface.operations))
64 interface.parents = list(filter(IsIdentified, interface.parents))
65
66
67def build_database(idl_files,
68 database_dir,
69 feature_defines=None,
70 logging_level=logging.WARNING,
71 examine_idls=False):
72 """This code reconstructs the FremontCut IDL database from W3C,
73 WebKit and Dart IDL files."""
74 current_dir = os.path.dirname(__file__)
75 logging.config.fileConfig(os.path.join(current_dir, "logging.conf"))
76
77 _logger.setLevel(logging_level)
78
79 db = database.Database(database_dir)
80
81 # Delete all existing IDLs in the DB.
82 db.Delete()
83
86
87 # TODO(vsm): Move this to a README.
88 # This is the Chrome revision.
89 webkit_revision = '63'
90
91 # TODO(vsm): Reconcile what is exposed here and inside WebKit code
92 # generation. We need to recheck this periodically for now.
93 webkit_defines = ['LANGUAGE_DART', 'LANGUAGE_JAVASCRIPT']
94
95 if feature_defines is None:
96 feature_defines = FEATURE_DEFINES
97
99 # TODO(vsm): What else should we define as on when processing IDL?
100 idl_defines=webkit_defines + feature_defines,
101 source='WebKit',
102 source_attributes={'revision': webkit_revision},
103 logging_level=logging_level)
104
105 # Import WebKit IDLs.
106 builder.import_idl_files(idl_files, webkit_options, False)
107
108 # Import Dart idl:
110 source='Dart',
111 rename_operation_arguments_on_merge=True,
112 logging_level=logging_level)
113
114 utilities.KNOWN_COMPONENTS = frozenset(['core', 'modules', 'dart'])
115
116 builder.import_idl_files(
117 [os.path.join(current_dir, '..', 'idl', 'dart', 'dart.idl')],
118 dart_options, True)
119
120 start_time = time.time()
121
122 # All typedefs MUST be resolved here before any database fixups (merging, implements, etc.)
123 ResolveAllTypedefs(builder._imported_interfaces)
124
125 # Merging:
126 builder.merge_imported_interfaces()
127
128 builder.fetch_constructor_data(webkit_options)
129 builder.fix_displacements('WebKit')
130
131 # Cleanup:
132 builder.normalize_annotations(['WebKit', 'Dart'])
133
134 # Map any IDL defined dictionaries to Dictionary.
135 builder.map_dictionaries()
136
137 # Examine all IDL and produce a diagnoses of areas (e.g., list dictionaries
138 # declared and usage, etc.)
139 if examine_idls:
140 builder.examine_database()
141
142 conditionals_met = set(
143 'ENABLE_' + conditional for conditional in builder.conditionals_met)
144 known_conditionals = set(FEATURE_DEFINES + FEATURE_DISABLED)
145
146 unused_conditionals = known_conditionals - conditionals_met
147 if unused_conditionals:
148 _logger.warning('There are some unused conditionals %s' %
149 sorted(unused_conditionals))
150 _logger.warning('Please update fremontcutbuilder.py')
151
152 unknown_conditionals = conditionals_met - known_conditionals
153 if unknown_conditionals:
154 _logger.warning('There are some unknown conditionals %s' %
155 sorted(unknown_conditionals))
156 _logger.warning('Please update fremontcutbuilder.py')
157
158 print('Merging interfaces %s seconds' % round(time.time() - start_time, 2))
159
160 return db
161
162
163def main(parallel=False, logging_level=logging.WARNING, examine_idls=False):
164 current_dir = os.path.dirname(__file__)
165
166 idl_files = []
167
168 # Check default location in a regular dart enlistment.
169 webcore_dir = os.path.join(current_dir, '..', '..', '..', 'third_party',
170 'WebCore')
171
172 if not os.path.exists(webcore_dir):
173 # Check default location in a dartium enlistment.
174 webcore_dir = os.path.join(current_dir, '..', '..', '..', '..',
175 'third_party', 'WebKit', 'Source')
176
177 if not os.path.exists(webcore_dir):
178 raise RuntimeError('directory not found: %s' % webcore_dir)
179
180 DIRS_TO_IGNORE = [
181 'bindings', # Various test IDLs
182 'testing', # IDLs to expose testing APIs
183 'networkinfo', # Not yet used in Blink yet
184 'vibration', # Not yet used in Blink yet
185 'inspector',
186 'idl_parser', # idl_parser has test IDL files.
187 ]
188
189 # TODO(terry): Integrate this into the htmlrenamer's _removed_html_interfaces
190 # (if possible).
191 FILES_TO_IGNORE = [
192 'InspectorFrontendHostFileSystem.idl', # Uses interfaces in inspector dir (which is ignored)
193 'WebKitGamepad.idl', # Gamepad.idl is the new one.
194 'WebKitGamepadList.idl', # GamepadList is the new one.
195 ]
196
197 for (dir_name, dirs, files) in os.walk(webcore_dir):
198 if os.path.basename(dir_name) in DIRS_TO_IGNORE:
199 dirs[:] = [] # Do not go underneath
200 else:
201 for name in files:
202 file_name = os.path.join(dir_name, name)
203 (interface, ext) = os.path.splitext(file_name)
204 if ext == '.idl' and not (name in FILES_TO_IGNORE):
205 idl_files.append(file_name)
206
207 database_dir = os.path.join(current_dir, '..', 'database')
208
209 return build_database(
210 idl_files,
211 database_dir,
212 logging_level=logging_level,
213 examine_idls=examine_idls)
214
215
216if __name__ == '__main__':
217 sys.exit(main())
static void round(SkPoint *p)
void print(void *str)
Definition bridge.cpp:126
set_builder(created_builder)
Definition dependency.py:4
Definition main.py:1
build_database(idl_files, database_dir, feature_defines=None, logging_level=logging.WARNING, examine_idls=False)
ResolveAllTypedefs(all_interfaces)