Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Utility functions (file reading, simple IDL parsing by regexes) for IDL build . | 5 """Utility functions (file reading, simple IDL parsing by regexes) for IDL build . |
| 6 | 6 |
| 7 Design doc: http://www.chromium.org/developers/design-documents/idl-build | 7 Design doc: http://www.chromium.org/developers/design-documents/idl-build |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import os | 10 import os |
| 11 import cPickle as pickle | 11 import cPickle as pickle |
| 12 import platform | |
| 12 import re | 13 import re |
| 13 import shlex | 14 import shlex |
| 14 import string | 15 import string |
| 15 import subprocess | 16 import subprocess |
| 16 | 17 |
| 17 | 18 |
| 18 KNOWN_COMPONENTS = frozenset(['core', 'modules']) | 19 KNOWN_COMPONENTS = frozenset(['core', 'modules']) |
| 19 KNOWN_COMPONENTS_WITH_TESTING = frozenset(['core', 'modules', 'testing']) | 20 KNOWN_COMPONENTS_WITH_TESTING = frozenset(['core', 'modules', 'testing']) |
| 20 | 21 |
| 21 | 22 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 | 82 |
| 82 @property | 83 @property |
| 83 def typedefs(self): | 84 def typedefs(self): |
| 84 return {} | 85 return {} |
| 85 | 86 |
| 86 @property | 87 @property |
| 87 def union_types(self): | 88 def union_types(self): |
| 88 return set() | 89 return set() |
| 89 | 90 |
| 90 @property | 91 @property |
| 91 def include_path_for_union_types(self): | 92 def include_path_for_union_types(self, name): |
| 92 return None | 93 return None |
| 93 | 94 |
| 94 | 95 |
| 95 class ComponentInfoProviderCore(ComponentInfoProvider): | 96 class ComponentInfoProviderCore(ComponentInfoProvider): |
| 96 def __init__(self, interfaces_info, component_info): | 97 def __init__(self, interfaces_info, component_info): |
| 97 super(ComponentInfoProviderCore, self).__init__() | 98 super(ComponentInfoProviderCore, self).__init__() |
| 98 self._interfaces_info = interfaces_info | 99 self._interfaces_info = interfaces_info |
| 99 self._component_info = component_info | 100 self._component_info = component_info |
| 100 | 101 |
| 101 @property | 102 @property |
| 102 def interfaces_info(self): | 103 def interfaces_info(self): |
| 103 return self._interfaces_info | 104 return self._interfaces_info |
| 104 | 105 |
| 105 @property | 106 @property |
| 106 def component_info(self): | 107 def component_info(self): |
| 107 return self._component_info | 108 return self._component_info |
| 108 | 109 |
| 109 @property | 110 @property |
| 110 def enumerations(self): | 111 def enumerations(self): |
| 111 return self._component_info['enumerations'] | 112 return self._component_info['enumerations'] |
| 112 | 113 |
| 113 @property | 114 @property |
| 114 def typedefs(self): | 115 def typedefs(self): |
| 115 return self._component_info['typedefs'] | 116 return self._component_info['typedefs'] |
| 116 | 117 |
| 117 @property | 118 @property |
| 118 def union_types(self): | 119 def union_types(self): |
| 119 return self._component_info['union_types'] | 120 return self._component_info['union_types'] |
| 120 | 121 |
| 121 @property | 122 def include_path_for_union_types(self, name): |
| 122 def include_path_for_union_types(self): | 123 return 'bindings/core/v8/%s.h' % name |
| 123 return 'bindings/core/v8/UnionTypesCore.h' | |
| 124 | 124 |
| 125 @property | 125 @property |
| 126 def specifier_for_export(self): | 126 def specifier_for_export(self): |
| 127 return 'CORE_EXPORT ' | 127 return 'CORE_EXPORT ' |
| 128 | 128 |
| 129 @property | 129 @property |
| 130 def include_path_for_export(self): | 130 def include_path_for_export(self): |
| 131 return 'core/CoreExport.h' | 131 return 'core/CoreExport.h' |
| 132 | 132 |
| 133 | 133 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 158 typedefs = self._component_info_core['typedefs'].copy() | 158 typedefs = self._component_info_core['typedefs'].copy() |
| 159 typedefs.update(self._component_info_modules['typedefs']) | 159 typedefs.update(self._component_info_modules['typedefs']) |
| 160 return typedefs | 160 return typedefs |
| 161 | 161 |
| 162 @property | 162 @property |
| 163 def union_types(self): | 163 def union_types(self): |
| 164 # Remove duplicate union types from component_info_modules to avoid | 164 # Remove duplicate union types from component_info_modules to avoid |
| 165 # generating multiple container generation. | 165 # generating multiple container generation. |
| 166 return self._component_info_modules['union_types'] - self._component_inf o_core['union_types'] | 166 return self._component_info_modules['union_types'] - self._component_inf o_core['union_types'] |
| 167 | 167 |
| 168 @property | 168 def include_path_for_union_types(self, name): |
| 169 def include_path_for_union_types(self): | 169 core_union_type_names = [union_type.name for union_type |
| 170 return 'bindings/modules/v8/UnionTypesModules.h' | 170 in self._component_info_core['union_types']] |
| 171 if name in core_union_type_names: | |
| 172 return 'bindings/core/v8/%s.h' % name | |
| 173 return 'bindings/modules/v8/%s.h' % name | |
| 171 | 174 |
| 172 @property | 175 @property |
| 173 def specifier_for_export(self): | 176 def specifier_for_export(self): |
| 174 return 'MODULES_EXPORT ' | 177 return 'MODULES_EXPORT ' |
| 175 | 178 |
| 176 @property | 179 @property |
| 177 def include_path_for_export(self): | 180 def include_path_for_export(self): |
| 178 return 'modules/ModulesExport.h' | 181 return 'modules/ModulesExport.h' |
| 179 | 182 |
| 180 | 183 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 | 290 |
| 288 | 291 |
| 289 def write_file(new_text, destination_filename, only_if_changed): | 292 def write_file(new_text, destination_filename, only_if_changed): |
| 290 if only_if_changed and os.path.isfile(destination_filename): | 293 if only_if_changed and os.path.isfile(destination_filename): |
| 291 with open(destination_filename) as destination_file: | 294 with open(destination_filename) as destination_file: |
| 292 if destination_file.read() == new_text: | 295 if destination_file.read() == new_text: |
| 293 return | 296 return |
| 294 destination_dirname = os.path.dirname(destination_filename) | 297 destination_dirname = os.path.dirname(destination_filename) |
| 295 if not os.path.exists(destination_dirname): | 298 if not os.path.exists(destination_dirname): |
| 296 os.makedirs(destination_dirname) | 299 os.makedirs(destination_dirname) |
| 300 # Workaround for http://crbug.com/611437 | |
| 301 # TODO(bashi): Remove this hack once we resolve too-long generated file | |
| 302 # names. | |
| 303 if platform.system() == 'Windows': | |
| 304 # http://stackoverflow.com/questions/14075465 | |
| 305 destination_filename = '\\\\?\\' + ( | |
| 306 os.path.abspath(os.path.join(os.getcwd(), destination_filename))) | |
|
Dirk Pranke
2016/05/13 15:20:43
Do we know for sure that GN, ninja, and any other
Nico
2016/05/13 15:21:31
+1
| |
| 297 with open(destination_filename, 'w') as destination_file: | 307 with open(destination_filename, 'w') as destination_file: |
| 298 destination_file.write(new_text) | 308 destination_file.write(new_text) |
| 299 | 309 |
| 300 | 310 |
| 301 def write_pickle_file(pickle_filename, data, only_if_changed): | 311 def write_pickle_file(pickle_filename, data, only_if_changed): |
| 302 if only_if_changed and os.path.isfile(pickle_filename): | 312 if only_if_changed and os.path.isfile(pickle_filename): |
| 303 with open(pickle_filename) as pickle_file: | 313 with open(pickle_filename) as pickle_file: |
| 304 try: | 314 try: |
| 305 if pickle.load(pickle_file) == data: | 315 if pickle.load(pickle_file) == data: |
| 306 return | 316 return |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 extended_attributes_string = match.group(1) | 387 extended_attributes_string = match.group(1) |
| 378 match = re.search(r'[^=]\bExposed\(([^)]*)\)', file_contents) | 388 match = re.search(r'[^=]\bExposed\(([^)]*)\)', file_contents) |
| 379 if not match: | 389 if not match: |
| 380 return None | 390 return None |
| 381 arguments = [] | 391 arguments = [] |
| 382 for argument in map(string.strip, match.group(1).split(',')): | 392 for argument in map(string.strip, match.group(1).split(',')): |
| 383 exposed, runtime_enabled = argument.split() | 393 exposed, runtime_enabled = argument.split() |
| 384 arguments.append({'exposed': exposed, 'runtime_enabled': runtime_enabled }) | 394 arguments.append({'exposed': exposed, 'runtime_enabled': runtime_enabled }) |
| 385 | 395 |
| 386 return arguments | 396 return arguments |
| OLD | NEW |