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

Side by Side Diff: pylib/gyp/input.py

Issue 115922: Add a generic way for generator info to get passed to input to affect process... (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: '' Created 11 years, 6 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 | « pylib/gyp/generator/xcode.py ('k') | 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 import copy 3 import copy
4 import gyp.common 4 import gyp.common
5 import optparse 5 import optparse
6 import os.path 6 import os.path
7 import re 7 import re
8 import shlex 8 import shlex
9 import subprocess 9 import subprocess
10 import sys 10 import sys
11 11
12 12
13 # A list of types that are treated as linkable. 13 # A list of types that are treated as linkable.
14 linkable_types = ['executable', 'shared_library', 'loadable_module'] 14 linkable_types = ['executable', 'shared_library', 'loadable_module']
15 15
16 # A list of sections that contain links to other targets. 16 # A list of sections that contain links to other targets.
17 dependency_sections = ['dependencies', 'export_dependent_settings'] 17 dependency_sections = ['dependencies', 'export_dependent_settings']
18 18
19 # A list of sections that contain pathnames. You should probably call 19 # base_path_sections is a list of sections defined by GYP that contain
20 # IsPathSection instead, which has other checks. 20 # pathnames. The generators can provide more keys, the two lists are merged
21 path_sections = [ 21 # into path_sections, but you should call IsPathSection instead of using either
22 # list directly.
23 base_path_sections = [
22 'destination', 24 'destination',
23 'files', 25 'files',
24 'include_dirs', 26 'include_dirs',
25 'inputs', 27 'inputs',
26 'libraries', 28 'libraries',
27 'mac_bundle_resources',
28 'mac_framework_dirs',
29 'msvs_cygwin_dirs',
30 'msvs_props',
31 'outputs', 29 'outputs',
32 'sources', 30 'sources',
33 ] 31 ]
34 32 path_sections = []
35 33
36 def IsPathSection(section): 34 def IsPathSection(section):
37 if section in path_sections or \ 35 if section in path_sections or \
38 section.endswith('_dir') or section.endswith('_dirs') or \ 36 section.endswith('_dir') or section.endswith('_dirs') or \
39 section.endswith('_file') or section.endswith('_files') or \ 37 section.endswith('_file') or section.endswith('_files') or \
40 section.endswith('_path') or section.endswith('_paths'): 38 section.endswith('_path') or section.endswith('_paths'):
41 return True 39 return True
42 return False 40 return False
43 41
44 42
43 # base_non_configuraiton_keys is a list of key names that belong in the target
44 # itself and should not be propagated into its configurations. It is merged
45 # with a list that can come from the generator to create non_configuration_keys
46 base_non_configuration_keys = [
47 # Sections that must exist inside targets and not configurations.
48 'actions',
49 'configurations',
50 'copies',
51 'default_configuration',
52 'dependencies',
53 'link_languages',
54 'libraries',
55 'postbuilds',
56 'product_dir',
57 'product_extension',
58 'product_name',
59 'rules',
60 'sources',
61 'suppress_wildcard',
62 'target_name',
63 'test',
64 'type',
65 'variants',
66
67 # Sections that can be found inside targets or configurations, but that
68 # should not be propagated from targets into their configurations.
69 'variables',
70 ]
71 non_configuration_keys = []
72
73
45 def ExceptionAppend(e, msg): 74 def ExceptionAppend(e, msg):
46 if not e.args: 75 if not e.args:
47 e.args = [msg] 76 e.args = [msg]
48 elif len(e.args) == 1: 77 elif len(e.args) == 1:
49 e.args = [str(e.args[0]) + ' ' + msg] 78 e.args = [str(e.args[0]) + ' ' + msg]
50 else: 79 else:
51 e.args = [str(e.args[0]) + ' ' + msg, e.args[1:]] 80 e.args = [str(e.args[0]) + ' ' + msg, e.args[1:]]
52 81
53 82
54 def GetIncludedBuildFiles(build_file_path, aux_data, included=None): 83 def GetIncludedBuildFiles(build_file_path, aux_data, included=None):
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 # always replaced, appended to, or prepended to. 1218 # always replaced, appended to, or prepended to.
1190 is_paths = IsPathSection(list_base) 1219 is_paths = IsPathSection(list_base)
1191 MergeLists(to[list_base], v, to_file, fro_file, is_paths, append) 1220 MergeLists(to[list_base], v, to_file, fro_file, is_paths, append)
1192 else: 1221 else:
1193 raise TypeError, \ 1222 raise TypeError, \
1194 'Attempt to merge dict value of unsupported type ' + \ 1223 'Attempt to merge dict value of unsupported type ' + \
1195 v.__class__.__name__ + ' for key ' + k 1224 v.__class__.__name__ + ' for key ' + k
1196 1225
1197 1226
1198 def SetUpConfigurations(target, target_dict): 1227 def SetUpConfigurations(target, target_dict):
1199 # non_configuraiton_keys is a list of key names that belong in the target 1228 global non_configuration_keys
1200 # itself and should not be propagated into its configurations.
1201 # TODO(mark/tvl): we need a way for this list to be extended by the
1202 # generators.
1203 non_configuration_keys = [
1204 # Sections that must exist inside targets and not configurations.
1205 'actions',
1206 'configurations',
1207 'copies',
1208 'default_configuration',
1209 'dependencies',
1210 'link_languages',
1211 'libraries',
1212 'mac_bundle',
1213 'mac_bundle_resources',
1214 'postbuilds',
1215 'product_dir',
1216 'product_extension',
1217 'product_name',
1218 'rules',
1219 'sources',
1220 'suppress_wildcard',
1221 'target_name',
1222 'test',
1223 'type',
1224 'variants',
1225 'xcode_create_dependents_test_runner',
1226
1227 # Sections that can be found inside targets or configurations, but that
1228 # should not be propagated from targets into their configurations.
1229 'variables',
1230 ]
1231 # key_suffixes is a list of key suffixes that might appear on key names. 1229 # key_suffixes is a list of key suffixes that might appear on key names.
1232 # These suffixes are handled in conditional evaluations (for =, +, and ?) 1230 # These suffixes are handled in conditional evaluations (for =, +, and ?)
1233 # and rules/exclude processing (for ! and /). Keys with these suffixes 1231 # and rules/exclude processing (for ! and /). Keys with these suffixes
1234 # should be treated the same as keys without. 1232 # should be treated the same as keys without.
1235 key_suffixes = ['=', '+', '?', '!', '/'] 1233 key_suffixes = ['=', '+', '?', '!', '/']
1236 1234
1237 build_file = gyp.common.BuildFileAndTarget('', target)[0] 1235 build_file = gyp.common.BuildFileAndTarget('', target)[0]
1238 1236
1239 # Provide a single configuration by default if none exists. 1237 # Provide a single configuration by default if none exists.
1240 # TODO(mark): Signal an error if default_configurations exists but 1238 # TODO(mark): Signal an error if default_configurations exists but
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 (source_root, source_extension) = os.path.splitext(source) 1498 (source_root, source_extension) = os.path.splitext(source)
1501 if source_extension.startswith('.'): 1499 if source_extension.startswith('.'):
1502 source_extension = source_extension[1:] 1500 source_extension = source_extension[1:]
1503 if source_extension == extension: 1501 if source_extension == extension:
1504 rule_sources.append(source) 1502 rule_sources.append(source)
1505 1503
1506 if len(rule_sources) > 0: 1504 if len(rule_sources) > 0:
1507 rule['rule_sources'] = rule_sources 1505 rule['rule_sources'] = rule_sources
1508 1506
1509 1507
1510 def Load(build_files, variables, includes, depth): 1508 def Load(build_files, variables, includes, depth, generator_input_info):
1509 # Set up path_sections and non_configuration_keys with the default data plus
1510 # the generator specifc data.
1511 global path_sections
1512 path_sections = base_path_sections[:]
1513 path_sections.extend(generator_input_info['path_sections'])
1514
1515 global non_configuration_keys
1516 non_configuration_keys = base_non_configuration_keys[:]
1517 non_configuration_keys.extend(generator_input_info['non_configuration_keys'])
1518
1519 # TODO(mark) handle variants if the generator doesn't want them directly.
1520 generator_handles_variants = \
1521 generator_input_info['generator_handles_variants']
1522
1511 # Load build files. This loads every target-containing build file into 1523 # Load build files. This loads every target-containing build file into
1512 # the |data| dictionary such that the keys to |data| are build file names, 1524 # the |data| dictionary such that the keys to |data| are build file names,
1513 # and the values are the entire build file contents after "early" or "pre" 1525 # and the values are the entire build file contents after "early" or "pre"
1514 # processing has been done and includes have been resolved. 1526 # processing has been done and includes have been resolved.
1515 data = {} 1527 data = {}
1516 aux_data = {} 1528 aux_data = {}
1517 for build_file in build_files: 1529 for build_file in build_files:
1518 # Normalize paths everywhere. This is important because paths will be 1530 # Normalize paths everywhere. This is important because paths will be
1519 # used as keys to the data dict and for references between input files. 1531 # used as keys to the data dict and for references between input files.
1520 build_file = os.path.normpath(build_file) 1532 build_file = os.path.normpath(build_file)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 # needed. Not all generators will need to use the rule_sources lists, but 1581 # needed. Not all generators will need to use the rule_sources lists, but
1570 # some may, and it seems best to build the list in a common spot. 1582 # some may, and it seems best to build the list in a common spot.
1571 for target in flat_list: 1583 for target in flat_list:
1572 target_dict = targets[target] 1584 target_dict = targets[target]
1573 ValidateRulesInTarget(target, target_dict) 1585 ValidateRulesInTarget(target, target_dict)
1574 1586
1575 # TODO(mark): Return |data| for now because the generator needs a list of 1587 # TODO(mark): Return |data| for now because the generator needs a list of
1576 # build files that came in. In the future, maybe it should just accept 1588 # build files that came in. In the future, maybe it should just accept
1577 # a list, and not the whole data dict. 1589 # a list, and not the whole data dict.
1578 return [flat_list, targets, data] 1590 return [flat_list, targets, data]
OLDNEW
« no previous file with comments | « pylib/gyp/generator/xcode.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698