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

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/compute_interfaces_info_individual.py

Issue 1544373002: Use relative include path to gen-dir to include multiple-stage-generated header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | no next file » | 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 import posixpath 47 import posixpath
48 import sys 48 import sys
49 49
50 from idl_compiler import idl_filename_to_interface_name 50 from idl_compiler import idl_filename_to_interface_name
51 from idl_definitions import Visitor 51 from idl_definitions import Visitor
52 from idl_reader import IdlReader 52 from idl_reader import IdlReader
53 from utilities import get_file_contents, read_file_to_list, idl_filename_to_inte rface_name, idl_filename_to_component, write_pickle_file, get_interface_extended _attributes_from_idl, is_callback_interface_from_idl, merge_dict_recursively 53 from utilities import get_file_contents, read_file_to_list, idl_filename_to_inte rface_name, idl_filename_to_component, write_pickle_file, get_interface_extended _attributes_from_idl, is_callback_interface_from_idl, merge_dict_recursively
54 54
55 module_path = os.path.dirname(__file__) 55 module_path = os.path.dirname(__file__)
56 source_path = os.path.normpath(os.path.join(module_path, os.pardir, os.pardir)) 56 source_path = os.path.normpath(os.path.join(module_path, os.pardir, os.pardir))
57 gen_path = os.path.join('gen', 'blink')
57 58
58 59
59 class IdlBadFilenameError(Exception): 60 class IdlBadFilenameError(Exception):
60 """Raised if an IDL filename disagrees with the interface name in the file." "" 61 """Raised if an IDL filename disagrees with the interface name in the file." ""
61 pass 62 pass
62 63
63 64
64 def parse_options(): 65 def parse_options():
65 usage = 'Usage: %prog [options] [generated1.idl]...' 66 usage = 'Usage: %prog [options] [generated1.idl]...'
66 parser = optparse.OptionParser(usage=usage) 67 parser = optparse.OptionParser(usage=usage)
(...skipping 11 matching lines...) Expand all
78 if options.write_file_only_if_changed is None: 79 if options.write_file_only_if_changed is None:
79 parser.error('Must specify whether file is only written if changed using --write-file-only-if-changed.') 80 parser.error('Must specify whether file is only written if changed using --write-file-only-if-changed.')
80 options.write_file_only_if_changed = bool(options.write_file_only_if_changed ) 81 options.write_file_only_if_changed = bool(options.write_file_only_if_changed )
81 return options, args 82 return options, args
82 83
83 84
84 ################################################################################ 85 ################################################################################
85 # Computations 86 # Computations
86 ################################################################################ 87 ################################################################################
87 88
88 def relative_dir_posix(idl_filename): 89 def relative_dir_posix(idl_filename, base_path):
89 """Returns relative path to the directory of idl_file in POSIX format.""" 90 """Returns relative path to the directory of idl_file in POSIX format."""
90 relative_path_local = os.path.relpath(idl_filename, source_path) 91 relative_path_local = os.path.relpath(idl_filename, base_path)
91 relative_dir_local = os.path.dirname(relative_path_local) 92 relative_dir_local = os.path.dirname(relative_path_local)
92 return relative_dir_local.replace(os.path.sep, posixpath.sep) 93 return relative_dir_local.replace(os.path.sep, posixpath.sep)
93 94
94 95
95 def include_path(idl_filename, implemented_as=None): 96 def include_path(idl_filename, implemented_as=None):
96 """Returns relative path to header file in POSIX format; used in includes. 97 """Returns relative path to header file in POSIX format; used in includes.
97 98
98 POSIX format is used for consistency of output, so reference tests are 99 POSIX format is used for consistency of output, so reference tests are
99 platform-independent. 100 platform-independent.
100 """ 101 """
101 relative_dir = relative_dir_posix(idl_filename) 102 if idl_filename.startswith(gen_path):
103 relative_dir = relative_dir_posix(idl_filename, gen_path)
104 else:
105 relative_dir = relative_dir_posix(idl_filename, source_path)
102 106
103 # IDL file basename is used even if only a partial interface file 107 # IDL file basename is used even if only a partial interface file
104 cpp_class_name = implemented_as or idl_filename_to_interface_name(idl_filena me) 108 cpp_class_name = implemented_as or idl_filename_to_interface_name(idl_filena me)
105 109
106 return posixpath.join(relative_dir, cpp_class_name + '.h') 110 return posixpath.join(relative_dir, cpp_class_name + '.h')
107 111
108 112
109 def get_implements_from_definitions(definitions, definition_name): 113 def get_implements_from_definitions(definitions, definition_name):
110 left_interfaces = [] 114 left_interfaces = []
111 right_interfaces = [] 115 right_interfaces = []
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 'full_path': full_path, 297 'full_path': full_path,
294 'has_union_types': bool(this_union_types), 298 'has_union_types': bool(this_union_types),
295 'implemented_as': implemented_as, 299 'implemented_as': implemented_as,
296 'implemented_by_interfaces': left_interfaces, 300 'implemented_by_interfaces': left_interfaces,
297 'implements_interfaces': right_interfaces, 301 'implements_interfaces': right_interfaces,
298 'include_path': this_include_path, 302 'include_path': this_include_path,
299 # FIXME: temporary private field, while removing old treatement of 303 # FIXME: temporary private field, while removing old treatement of
300 # 'implements': http://crbug.com/360435 304 # 'implements': http://crbug.com/360435
301 'is_legacy_treat_as_partial_interface': 'LegacyTreatAsPartialInterfa ce' in extended_attributes, 305 'is_legacy_treat_as_partial_interface': 'LegacyTreatAsPartialInterfa ce' in extended_attributes,
302 'parent': definition.parent, 306 'parent': definition.parent,
303 'relative_dir': relative_dir_posix(idl_filename), 307 'relative_dir': relative_dir_posix(idl_filename, source_path),
304 }) 308 })
305 merge_dict_recursively(self.interfaces_info[definition.name], interface_ info) 309 merge_dict_recursively(self.interfaces_info[definition.name], interface_ info)
306 310
307 def get_info_as_dict(self): 311 def get_info_as_dict(self):
308 """Returns info packaged as a dict.""" 312 """Returns info packaged as a dict."""
309 return { 313 return {
310 'interfaces_info': self.interfaces_info, 314 'interfaces_info': self.interfaces_info,
311 # Can't pickle defaultdict, convert to dict 315 # Can't pickle defaultdict, convert to dict
312 # FIXME: this should be included in get_component_info. 316 # FIXME: this should be included in get_component_info.
313 'partial_interface_files': dict(self.partial_interface_files), 317 'partial_interface_files': dict(self.partial_interface_files),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 349
346 write_pickle_file(options.interfaces_info_file, 350 write_pickle_file(options.interfaces_info_file,
347 info_collector.get_info_as_dict(), 351 info_collector.get_info_as_dict(),
348 options.write_file_only_if_changed) 352 options.write_file_only_if_changed)
349 write_pickle_file(options.component_info_file, 353 write_pickle_file(options.component_info_file,
350 info_collector.get_component_info_as_dict(), 354 info_collector.get_component_info_as_dict(),
351 options.write_file_only_if_changed) 355 options.write_file_only_if_changed)
352 356
353 if __name__ == '__main__': 357 if __name__ == '__main__':
354 sys.exit(main()) 358 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698