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

Side by Side Diff: Source/bindings/scripts/compute_interfaces_info.py

Issue 180273009: Eliminate InterfaceDependencies.txt (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | « Source/bindings/generated_bindings.gyp ('k') | Tools/Scripts/webkitpy/bindings/main.py » ('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 # 2 #
3 # Copyright (C) 2013 Google Inc. All rights reserved. 3 # Copyright (C) 2013 Google Inc. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 'full_path': path to the IDL file, so can lookup an IDL by interface name 67 'full_path': path to the IDL file, so can lookup an IDL by interface name
68 'include_path': path for use in C++ #include directives 68 'include_path': path for use in C++ #include directives
69 'dependencies_full_paths': paths to dependencies (for merging into main) 69 'dependencies_full_paths': paths to dependencies (for merging into main)
70 'dependencies_include_paths': paths for use in C++ #include directives 70 'dependencies_include_paths': paths for use in C++ #include directives
71 71
72 Note that all of these are stable information, unlikely to change without 72 Note that all of these are stable information, unlikely to change without
73 moving or deleting files (hence requiring a full rebuild anyway) or significant 73 moving or deleting files (hence requiring a full rebuild anyway) or significant
74 code changes (for inherited extended attributes). 74 code changes (for inherited extended attributes).
75 75
76 FIXME: also generates EventNames.in; factor out. http://crbug.com/341748 76 FIXME: also generates EventNames.in; factor out. http://crbug.com/341748
77 FIXME: also generates InterfaceDependencies.txt for Perl. http://crbug.com/2397 71
78 77
79 Design doc: http://www.chromium.org/developers/design-documents/idl-build 78 Design doc: http://www.chromium.org/developers/design-documents/idl-build
80 """ 79 """
81 80
82 import optparse 81 import optparse
83 import os 82 import os
84 import posixpath 83 import posixpath
85 import sys 84 import sys
86 85
87 from utilities import get_file_contents, write_file, write_pickle_file, get_inte rface_extended_attributes_from_idl, is_callback_interface_from_idl, get_partial_ interface_name_from_idl, get_implemented_interfaces_from_idl, get_parent_interfa ce, get_put_forward_interfaces_from_idl 86 from utilities import get_file_contents, write_file, write_pickle_file, get_inte rface_extended_attributes_from_idl, is_callback_interface_from_idl, get_partial_ interface_name_from_idl, get_implemented_interfaces_from_idl, get_parent_interfa ce, get_put_forward_interfaces_from_idl
(...skipping 19 matching lines...) Expand all
107 class IdlInterfaceFileNotFoundError(Exception): 106 class IdlInterfaceFileNotFoundError(Exception):
108 """Raised if the IDL file implementing an interface cannot be found.""" 107 """Raised if the IDL file implementing an interface cannot be found."""
109 pass 108 pass
110 109
111 110
112 def parse_options(): 111 def parse_options():
113 usage = 'Usage: %prog [options] [generated1.idl]...' 112 usage = 'Usage: %prog [options] [generated1.idl]...'
114 parser = optparse.OptionParser(usage=usage) 113 parser = optparse.OptionParser(usage=usage)
115 parser.add_option('--event-names-file', help='output file') 114 parser.add_option('--event-names-file', help='output file')
116 parser.add_option('--idl-files-list', help='file listing IDL files') 115 parser.add_option('--idl-files-list', help='file listing IDL files')
117 parser.add_option('--interface-dependencies-file', help='output file')
118 parser.add_option('--interfaces-info-file', help='output pickle file') 116 parser.add_option('--interfaces-info-file', help='output pickle file')
119 parser.add_option('--write-file-only-if-changed', type='int', help='if true, do not write an output file if it would be identical to the existing one, which avoids unnecessary rebuilds in ninja') 117 parser.add_option('--write-file-only-if-changed', type='int', help='if true, do not write an output file if it would be identical to the existing one, which avoids unnecessary rebuilds in ninja')
120 options, args = parser.parse_args() 118 options, args = parser.parse_args()
121 if options.event_names_file is None: 119 if options.event_names_file is None:
122 parser.error('Must specify an output file using --event-names-file.') 120 parser.error('Must specify an output file using --event-names-file.')
123 if options.interface_dependencies_file is None:
124 parser.error('Must specify an output file using --interface-dependencies -file.')
125 if options.interfaces_info_file is None: 121 if options.interfaces_info_file is None:
126 parser.error('Must specify an output file using --interfaces-info-file.' ) 122 parser.error('Must specify an output file using --interfaces-info-file.' )
127 if options.idl_files_list is None: 123 if options.idl_files_list is None:
128 parser.error('Must specify a file listing IDL files using --idl-files-li st.') 124 parser.error('Must specify a file listing IDL files using --idl-files-li st.')
129 if options.write_file_only_if_changed is None: 125 if options.write_file_only_if_changed is None:
130 parser.error('Must specify whether file is only written if changed using --write-file-only-if-changed.') 126 parser.error('Must specify whether file is only written if changed using --write-file-only-if-changed.')
131 options.write_file_only_if_changed = bool(options.write_file_only_if_changed ) 127 options.write_file_only_if_changed = bool(options.write_file_only_if_changed )
132 return options, args 128 return options, args
133 129
134 130
135 ################################################################################ 131 ################################################################################
136 # Write files 132 # Write files
137 ################################################################################ 133 ################################################################################
138 134
139 def write_dependencies_file(dependencies_filename, only_if_changed):
140 """Write the interface dependencies file.
141
142 The format is as follows:
143
144 Document.idl P.idl
145 Event.idl
146 Window.idl Q.idl R.idl S.idl
147 ...
148
149 The above indicates that:
150 Document.idl depends on P.idl,
151 Event.idl depends on no other IDL files, and
152 Window.idl depends on Q.idl, R.idl, and S.idl.
153
154 An IDL that is a dependency of another IDL (e.g. P.idl) does not have its
155 own line in the dependency file.
156 """
157 # FIXME: remove this file once Perl is gone http://crbug.com/239771
158 dependencies_list = sorted(
159 (interface_info['full_path'], sorted(interface_info['dependencies_full_p aths']))
160 for interface_info in interfaces_info.values())
161 lines = ['%s %s\n' % (idl_file, ' '.join(dependency_files))
162 for idl_file, dependency_files in dependencies_list]
163 write_file(lines, dependencies_filename, only_if_changed)
164
165
166 def write_event_names_file(destination_filename, only_if_changed): 135 def write_event_names_file(destination_filename, only_if_changed):
167 # Generate event names for all interfaces that inherit from Event, 136 # Generate event names for all interfaces that inherit from Event,
168 # including Event itself. 137 # including Event itself.
169 # FIXME: factor out. http://crbug.com/341748 138 # FIXME: factor out. http://crbug.com/341748
170 event_names = set( 139 event_names = set(
171 interface_name 140 interface_name
172 for interface_name, interface_info in interfaces_info.iteritems() 141 for interface_name, interface_info in interfaces_info.iteritems()
173 if (interface_name == 'Event' or 142 if (interface_name == 'Event' or
174 ('ancestors' in interface_info and 143 ('ancestors' in interface_info and
175 interface_info['ancestors'][-1] == 'Event'))) 144 interface_info['ancestors'][-1] == 'Event')))
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 with open(options.idl_files_list) as idl_files_list: 325 with open(options.idl_files_list) as idl_files_list:
357 idl_files = [line.rstrip('\n') for line in idl_files_list] 326 idl_files = [line.rstrip('\n') for line in idl_files_list]
358 # Generated IDL files are passed at the command line, since these are in the 327 # Generated IDL files are passed at the command line, since these are in the
359 # build directory, which is determined at build time, not GYP time, so these 328 # build directory, which is determined at build time, not GYP time, so these
360 # cannot be included in the file listing static files 329 # cannot be included in the file listing static files
361 idl_files.extend(args) 330 idl_files.extend(args)
362 331
363 only_if_changed = options.write_file_only_if_changed 332 only_if_changed = options.write_file_only_if_changed
364 compute_interfaces_info(idl_files) 333 compute_interfaces_info(idl_files)
365 write_pickle_file(options.interfaces_info_file, interfaces_info, only_if_cha nged) 334 write_pickle_file(options.interfaces_info_file, interfaces_info, only_if_cha nged)
366 write_dependencies_file(options.interface_dependencies_file, only_if_changed )
367 write_event_names_file(options.event_names_file, only_if_changed) 335 write_event_names_file(options.event_names_file, only_if_changed)
368 336
369 337
370 if __name__ == '__main__': 338 if __name__ == '__main__':
371 sys.exit(main()) 339 sys.exit(main())
OLDNEW
« no previous file with comments | « Source/bindings/generated_bindings.gyp ('k') | Tools/Scripts/webkitpy/bindings/main.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698