OLD | NEW |
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 return posixpath.join(relative_dir_posix, cpp_class_name + '.h') | 93 return posixpath.join(relative_dir_posix, cpp_class_name + '.h') |
94 | 94 |
95 | 95 |
96 def add_paths_to_partials_dict(partial_interface_name, full_path, this_include_p
ath=None): | 96 def add_paths_to_partials_dict(partial_interface_name, full_path, this_include_p
ath=None): |
97 paths_dict = partial_interface_files[partial_interface_name] | 97 paths_dict = partial_interface_files[partial_interface_name] |
98 paths_dict['full_paths'].append(full_path) | 98 paths_dict['full_paths'].append(full_path) |
99 if this_include_path: | 99 if this_include_path: |
100 paths_dict['include_paths'].append(this_include_path) | 100 paths_dict['include_paths'].append(this_include_path) |
101 | 101 |
102 | 102 |
103 def compute_individual_info(idl_filename): | 103 def compute_info_individual(idl_filename): |
104 full_path = os.path.realpath(idl_filename) | 104 full_path = os.path.realpath(idl_filename) |
105 idl_file_contents = get_file_contents(full_path) | 105 idl_file_contents = get_file_contents(full_path) |
106 | 106 |
107 extended_attributes = get_interface_extended_attributes_from_idl(idl_file_co
ntents) | 107 extended_attributes = get_interface_extended_attributes_from_idl(idl_file_co
ntents) |
108 implemented_as = extended_attributes.get('ImplementedAs') | 108 implemented_as = extended_attributes.get('ImplementedAs') |
109 this_include_path = include_path(idl_filename, implemented_as) | 109 this_include_path = include_path(idl_filename, implemented_as) |
110 | 110 |
111 # Handle partial interfaces | 111 # Handle partial interfaces |
112 partial_interface_name = get_partial_interface_name_from_idl(idl_file_conten
ts) | 112 partial_interface_name = get_partial_interface_name_from_idl(idl_file_conten
ts) |
113 if partial_interface_name: | 113 if partial_interface_name: |
(...skipping 24 matching lines...) Expand all Loading... |
138 # Interfaces that are referenced (used as types) and that we introspect | 138 # Interfaces that are referenced (used as types) and that we introspect |
139 # during code generation (beyond interface-level data ([ImplementedAs], | 139 # during code generation (beyond interface-level data ([ImplementedAs], |
140 # is_callback_interface, ancestors, and inherited extended attributes): | 140 # is_callback_interface, ancestors, and inherited extended attributes): |
141 # deep dependencies. | 141 # deep dependencies. |
142 # These cause rebuilds of referrers, due to the dependency, so these | 142 # These cause rebuilds of referrers, due to the dependency, so these |
143 # should be minimized; currently only targets of [PutForwards]. | 143 # should be minimized; currently only targets of [PutForwards]. |
144 'referenced_interfaces': get_put_forward_interfaces_from_idl(idl_file_co
ntents), | 144 'referenced_interfaces': get_put_forward_interfaces_from_idl(idl_file_co
ntents), |
145 } | 145 } |
146 | 146 |
147 | 147 |
| 148 def info_individual(): |
| 149 """Returns info packaged as a dict.""" |
| 150 return { |
| 151 'interfaces_info': interfaces_info, |
| 152 # Can't pickle defaultdict, convert to dict |
| 153 'partial_interface_files': dict(partial_interface_files), |
| 154 } |
| 155 |
| 156 |
148 ################################################################################ | 157 ################################################################################ |
149 | 158 |
150 def main(): | 159 def main(): |
151 options, args = parse_options() | 160 options, args = parse_options() |
152 | 161 |
153 # Static IDL files are passed in a file (generated at GYP time), due to OS | 162 # Static IDL files are passed in a file (generated at GYP time), due to OS |
154 # command line length limits | 163 # command line length limits |
155 with open(options.idl_files_list) as idl_files_list: | 164 with open(options.idl_files_list) as idl_files_list: |
156 idl_files = [line.rstrip('\n') for line in idl_files_list] | 165 idl_files = [line.rstrip('\n') for line in idl_files_list] |
157 # Generated IDL files are passed at the command line, since these are in the | 166 # Generated IDL files are passed at the command line, since these are in the |
158 # build directory, which is determined at build time, not GYP time, so these | 167 # build directory, which is determined at build time, not GYP time, so these |
159 # cannot be included in the file listing static files | 168 # cannot be included in the file listing static files |
160 idl_files.extend(args) | 169 idl_files.extend(args) |
161 | 170 |
162 # Compute information for individual files | 171 # Compute information for individual files |
163 # Information is stored in global variables interfaces_info and | 172 # Information is stored in global variables interfaces_info and |
164 # partial_interface_files. | 173 # partial_interface_files. |
165 for idl_filename in idl_files: | 174 for idl_filename in idl_files: |
166 compute_individual_info(idl_filename) | 175 compute_info_individual(idl_filename) |
167 | 176 |
168 write_pickle_file(options.interfaces_info_file, | 177 write_pickle_file(options.interfaces_info_file, |
169 { | 178 info_individual(), |
170 'interfaces_info': interfaces_info, | |
171 # Can't pickle defaultdict, convert to dict | |
172 'partial_interface_files': dict(partial_interface_file
s), | |
173 }, | |
174 options.write_file_only_if_changed) | 179 options.write_file_only_if_changed) |
175 | 180 |
176 | 181 |
177 if __name__ == '__main__': | 182 if __name__ == '__main__': |
178 sys.exit(main()) | 183 sys.exit(main()) |
OLD | NEW |