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

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

Issue 271019: Adding cross-compile ability to the make build (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: '' Created 11 years, 2 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') | test/toolsets/gyptest-toolsets.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 from compiler.ast import Const 3 from compiler.ast import Const
4 from compiler.ast import Dict 4 from compiler.ast import Dict
5 from compiler.ast import Discard 5 from compiler.ast import Discard
6 from compiler.ast import List 6 from compiler.ast import List
7 from compiler.ast import Module 7 from compiler.ast import Module
8 from compiler.ast import Node 8 from compiler.ast import Node
9 from compiler.ast import Stmt 9 from compiler.ast import Stmt
10 import compiler 10 import compiler
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 'postbuilds', 66 'postbuilds',
67 'product_dir', 67 'product_dir',
68 'product_extension', 68 'product_extension',
69 'product_name', 69 'product_name',
70 'rules', 70 'rules',
71 'run_as', 71 'run_as',
72 'sources', 72 'sources',
73 'suppress_wildcard', 73 'suppress_wildcard',
74 'target_name', 74 'target_name',
75 'test', 75 'test',
76 'toolset',
77 'toolsets',
76 'type', 78 'type',
77 'variants', 79 'variants',
78 80
79 # Sections that can be found inside targets or configurations, but that 81 # Sections that can be found inside targets or configurations, but that
80 # should not be propagated from targets into their configurations. 82 # should not be propagated from targets into their configurations.
81 'variables', 83 'variables',
82 ] 84 ]
83 non_configuration_keys = [] 85 non_configuration_keys = []
84 86
85 # Controls how the generator want the build file paths. 87 # Controls how the generator want the build file paths.
86 absolute_build_file_paths = False 88 absolute_build_file_paths = False
87 89
90 # Controls whether or not the generator supports multiple toolsets.
91 multiple_toolsets = False
92
88 93
89 def GetIncludedBuildFiles(build_file_path, aux_data, included=None): 94 def GetIncludedBuildFiles(build_file_path, aux_data, included=None):
90 """Return a list of all build files included into build_file_path. 95 """Return a list of all build files included into build_file_path.
91 96
92 The returned list will contain build_file_path as well as all other files 97 The returned list will contain build_file_path as well as all other files
93 that it included, either directly or indirectly. Note that the list may 98 that it included, either directly or indirectly. Note that the list may
94 contain files that were included into a conditional section that evaluated 99 contain files that were included into a conditional section that evaluated
95 to false and was not merged into build_file_path's dict. 100 to false and was not merged into build_file_path's dict.
96 101
97 aux_data is a dict containing a key for each build file or included build 102 aux_data is a dict containing a key for each build file or included build
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 def LoadBuildFileIncludesIntoList(sublist, sublist_path, data, aux_data, 255 def LoadBuildFileIncludesIntoList(sublist, sublist_path, data, aux_data,
251 variables, check): 256 variables, check):
252 for item in sublist: 257 for item in sublist:
253 if item.__class__ == dict: 258 if item.__class__ == dict:
254 LoadBuildFileIncludesIntoDict(item, sublist_path, data, aux_data, 259 LoadBuildFileIncludesIntoDict(item, sublist_path, data, aux_data,
255 variables, None, check) 260 variables, None, check)
256 elif item.__class__ == list: 261 elif item.__class__ == list:
257 LoadBuildFileIncludesIntoList(item, sublist_path, data, aux_data, 262 LoadBuildFileIncludesIntoList(item, sublist_path, data, aux_data,
258 variables, check) 263 variables, check)
259 264
265 # Processes toolsets in all the targets. This recurses into condition entries
266 # since they can contain toolsets as well.
267 def ProcessToolsetsInDict(data):
268 if 'targets' in data:
269 target_list = data['targets']
270 new_target_list = []
271 for target in target_list:
272 global multiple_toolsets
273 if multiple_toolsets:
274 toolsets = target.get('toolsets', ['target'])
275 else:
276 toolsets = ['target']
277 if len(toolsets) > 0:
278 # Optimization: only do copies if more than one toolset is specified.
279 for build in toolsets[1:]:
280 new_target = copy.deepcopy(target)
281 new_target['toolset'] = build
282 new_target_list.append(new_target)
283 target['toolset'] = toolsets[0]
284 new_target_list.append(target)
285 data['targets'] = new_target_list
286 if 'conditions' in data:
287 for condition in data['conditions']:
288 if isinstance(condition, list):
289 for condition_dict in condition[1:]:
290 ProcessToolsetsInDict(condition_dict)
291
260 292
261 # TODO(mark): I don't love this name. It just means that it's going to load 293 # TODO(mark): I don't love this name. It just means that it's going to load
262 # a build file that contains targets and is expected to provide a targets dict 294 # a build file that contains targets and is expected to provide a targets dict
263 # that contains the targets... 295 # that contains the targets...
264 def LoadTargetBuildFile(build_file_path, data, aux_data, variables, includes, 296 def LoadTargetBuildFile(build_file_path, data, aux_data, variables, includes,
265 depth, check): 297 depth, check):
266 global absolute_build_file_paths 298 global absolute_build_file_paths
267 299
268 # If depth is set, predefine the DEPTH variable to be a relative path from 300 # If depth is set, predefine the DEPTH variable to be a relative path from
269 # this build file's directory to the directory identified by depth. 301 # this build file's directory to the directory identified by depth.
270 if depth: 302 if depth:
271 d = gyp.common.RelativePath(depth, os.path.dirname(build_file_path)) 303 d = gyp.common.RelativePath(depth, os.path.dirname(build_file_path))
272 if d == '': 304 if d == '':
273 variables['DEPTH'] = '.' 305 variables['DEPTH'] = '.'
274 else: 306 else:
275 variables['DEPTH'] = d 307 variables['DEPTH'] = d
276 308
277 # If the generator needs absolue paths, then do so. 309 # If the generator needs absolue paths, then do so.
278 if absolute_build_file_paths: 310 if absolute_build_file_paths:
279 build_file_path = os.path.abspath(build_file_path) 311 build_file_path = os.path.abspath(build_file_path)
280 312
281 if build_file_path in data: 313 if build_file_path in data['target_build_files']:
282 # Already loaded. 314 # Already loaded.
283 return 315 return
316 data['target_build_files'].add(build_file_path)
284 317
285 gyp.DebugOutput(gyp.DEBUG_INCLUDES, 318 gyp.DebugOutput(gyp.DEBUG_INCLUDES,
286 "Loading Target Build File '%s'" % build_file_path) 319 "Loading Target Build File '%s'" % build_file_path)
287 320
288 build_file_data = LoadOneBuildFile(build_file_path, data, aux_data, variables, 321 build_file_data = LoadOneBuildFile(build_file_path, data, aux_data, variables,
289 includes, True, check) 322 includes, True, check)
290 323
291 # Store DEPTH for later use in generators. 324 # Store DEPTH for later use in generators.
292 build_file_data['_DEPTH'] = depth 325 build_file_data['_DEPTH'] = depth
293 326
294 # Set up the included_files key indicating which .gyp files contributed to 327 # Set up the included_files key indicating which .gyp files contributed to
295 # this target dict. 328 # this target dict.
296 if 'included_files' in build_file_data: 329 if 'included_files' in build_file_data:
297 raise KeyError, build_file_path + ' must not contain included_files key' 330 raise KeyError, build_file_path + ' must not contain included_files key'
298 331
299 included = GetIncludedBuildFiles(build_file_path, aux_data) 332 included = GetIncludedBuildFiles(build_file_path, aux_data)
300 build_file_data['included_files'] = [] 333 build_file_data['included_files'] = []
301 for included_file in included: 334 for included_file in included:
302 # included_file is relative to the current directory, but it needs to 335 # included_file is relative to the current directory, but it needs to
303 # be made relative to build_file_path's directory. 336 # be made relative to build_file_path's directory.
304 included_relative = \ 337 included_relative = \
305 gyp.common.RelativePath(included_file, 338 gyp.common.RelativePath(included_file,
306 os.path.dirname(build_file_path)) 339 os.path.dirname(build_file_path))
307 build_file_data['included_files'].append(included_relative) 340 build_file_data['included_files'].append(included_relative)
308 341
342 ProcessToolsetsInDict(build_file_data)
343
309 # Apply "pre"/"early" variable expansions and condition evaluations. 344 # Apply "pre"/"early" variable expansions and condition evaluations.
310 ProcessVariablesAndConditionsInDict(build_file_data, False, variables.copy(), 345 ProcessVariablesAndConditionsInDict(build_file_data, False, variables.copy(),
311 build_file_path) 346 build_file_path)
312 347
313 # Look at each project's target_defaults dict, and merge settings into 348 # Look at each project's target_defaults dict, and merge settings into
314 # targets. 349 # targets.
315 if 'target_defaults' in build_file_data: 350 if 'target_defaults' in build_file_data:
316 index = 0 351 index = 0
317 if 'targets' in build_file_data: 352 if 'targets' in build_file_data:
318 while index < len(build_file_data['targets']): 353 while index < len(build_file_data['targets']):
(...skipping 21 matching lines...) Expand all
340 # after "pre" conditionals and variable expansion, but before "post" - 375 # after "pre" conditionals and variable expansion, but before "post" -
341 # in other words, you can't put a "dependencies" section inside a "post" 376 # in other words, you can't put a "dependencies" section inside a "post"
342 # conditional within a target. 377 # conditional within a target.
343 378
344 if 'targets' in build_file_data: 379 if 'targets' in build_file_data:
345 for target_dict in build_file_data['targets']: 380 for target_dict in build_file_data['targets']:
346 if 'dependencies' not in target_dict: 381 if 'dependencies' not in target_dict:
347 continue 382 continue
348 for dependency in target_dict['dependencies']: 383 for dependency in target_dict['dependencies']:
349 other_build_file = \ 384 other_build_file = \
350 gyp.common.BuildFileAndTarget(build_file_path, dependency)[0] 385 gyp.common.ResolveTarget(build_file_path, dependency, None)[0]
351 try: 386 try:
352 LoadTargetBuildFile(other_build_file, data, aux_data, variables, 387 LoadTargetBuildFile(other_build_file, data, aux_data, variables,
353 includes, depth, check) 388 includes, depth, check)
354 except Exception, e: 389 except Exception, e:
355 gyp.common.ExceptionAppend( 390 gyp.common.ExceptionAppend(
356 e, 'while loading dependencies of %s' % build_file_path) 391 e, 'while loading dependencies of %s' % build_file_path)
357 raise 392 raise
358 393
359 return data 394 return data
360 395
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 current directory. Values in |data| are build file contents. For each 913 current directory. Values in |data| are build file contents. For each
879 |data| value with a "targets" key, the value of the "targets" key is taken 914 |data| value with a "targets" key, the value of the "targets" key is taken
880 as a list containing target dicts. Each target's fully-qualified name is 915 as a list containing target dicts. Each target's fully-qualified name is
881 constructed from the pathname of the build file (|data| key) and its 916 constructed from the pathname of the build file (|data| key) and its
882 "target_name" property. These fully-qualified names are used as the keys 917 "target_name" property. These fully-qualified names are used as the keys
883 in the returned dict. These keys provide access to the target dicts, 918 in the returned dict. These keys provide access to the target dicts,
884 the dicts in the "targets" lists. 919 the dicts in the "targets" lists.
885 """ 920 """
886 921
887 targets = {} 922 targets = {}
888 for build_file in data: 923 for build_file in data['target_build_files']:
889 for target in data[build_file].get('targets', []): 924 for target in data[build_file].get('targets', []):
890 target_name = gyp.common.QualifiedTarget(build_file, 925 target_name = gyp.common.QualifiedTarget(build_file,
891 target['target_name']) 926 target['target_name'],
927 target['toolset'])
892 if target_name in targets: 928 if target_name in targets:
893 raise KeyError, 'Duplicate target definitions for ' + target_name 929 raise KeyError, 'Duplicate target definitions for ' + target_name
894 targets[target_name] = target 930 targets[target_name] = target
895 931
896 return targets 932 return targets
897 933
898 934
899 def QualifyDependencies(targets): 935 def QualifyDependencies(targets):
900 """Make dependency links fully-qualified relative to the current directory. 936 """Make dependency links fully-qualified relative to the current directory.
901 937
902 |targets| is a dict mapping fully-qualified target names to their target 938 |targets| is a dict mapping fully-qualified target names to their target
903 dicts. For each target in this dict, keys known to contain dependency 939 dicts. For each target in this dict, keys known to contain dependency
904 links are examined, and any dependencies referenced will be rewritten 940 links are examined, and any dependencies referenced will be rewritten
905 so that they are fully-qualified and relative to the current directory. 941 so that they are fully-qualified and relative to the current directory.
906 All rewritten dependencies are suitable for use as keys to |targets| or a 942 All rewritten dependencies are suitable for use as keys to |targets| or a
907 similar dict. 943 similar dict.
908 """ 944 """
909 945
910 for target, target_dict in targets.iteritems(): 946 for target, target_dict in targets.iteritems():
911 target_build_file = gyp.common.BuildFileAndTarget('', target)[0] 947 target_build_file = gyp.common.BuildFile(target)
948 toolset = target_dict['toolset']
912 for dependency_key in dependency_sections: 949 for dependency_key in dependency_sections:
913 dependencies = target_dict.get(dependency_key, []) 950 dependencies = target_dict.get(dependency_key, [])
914 for index in xrange(0, len(dependencies)): 951 for index in xrange(0, len(dependencies)):
915 dependency = gyp.common.QualifiedTarget(target_build_file, 952 dep_file, dep_target, dep_toolset = gyp.common.ResolveTarget(
916 dependencies[index]) 953 target_build_file, dependencies[index], toolset)
954 global multiple_toolsets
955 if not multiple_toolsets:
956 # Ignore toolset specification in the dependency if it is specified.
957 dep_toolset = toolset
958 dependency = gyp.common.QualifiedTarget(dep_file,
959 dep_target,
960 dep_toolset)
917 dependencies[index] = dependency 961 dependencies[index] = dependency
918 962
919 # Make sure anything appearing in a list other than "dependencies" also 963 # Make sure anything appearing in a list other than "dependencies" also
920 # appears in the "dependencies" list. 964 # appears in the "dependencies" list.
921 if dependency_key != 'dependencies' and \ 965 if dependency_key != 'dependencies' and \
922 dependency not in target_dict['dependencies']: 966 dependency not in target_dict['dependencies']:
923 raise KeyError, 'Found ' + dependency + ' in ' + dependency_key + \ 967 raise KeyError, 'Found ' + dependency + ' in ' + dependency_key + \
924 ' of ' + target + ', but not in dependencies' 968 ' of ' + target + ', but not in dependencies'
925 969
926 970
927 def ExpandWildcardDependencies(targets, data): 971 def ExpandWildcardDependencies(targets, data):
928 """Expands dependencies specified as build_file:*. 972 """Expands dependencies specified as build_file:*.
929 973
930 For each target in |targets|, examines sections containing links to other 974 For each target in |targets|, examines sections containing links to other
931 targets. If any such section contains a link of the form build_file:*, it 975 targets. If any such section contains a link of the form build_file:*, it
932 is taken as a wildcard link, and is expanded to list each target in 976 is taken as a wildcard link, and is expanded to list each target in
933 build_file. The |data| dict provides access to build file dicts. 977 build_file. The |data| dict provides access to build file dicts.
934 978
935 Any target that does not wish to be included by wildcard can provide an 979 Any target that does not wish to be included by wildcard can provide an
936 optional "suppress_wildcard" key in its target dict. When present and 980 optional "suppress_wildcard" key in its target dict. When present and
937 true, a wildcard dependency link will not include such targets. 981 true, a wildcard dependency link will not include such targets.
938 982
939 All dependency names, including the keys to |targets| and the values in each 983 All dependency names, including the keys to |targets| and the values in each
940 dependency list, must be qualified when this function is called. 984 dependency list, must be qualified when this function is called.
941 """ 985 """
942 986
943 for target, target_dict in targets.iteritems(): 987 for target, target_dict in targets.iteritems():
944 target_build_file = gyp.common.BuildFileAndTarget('', target)[0] 988 toolset = target_dict['toolset']
989 target_build_file = gyp.common.BuildFile(target)
945 for dependency_key in dependency_sections: 990 for dependency_key in dependency_sections:
946 dependencies = target_dict.get(dependency_key, []) 991 dependencies = target_dict.get(dependency_key, [])
947 992
948 # Loop this way instead of "for dependency in" or "for index in xrange" 993 # Loop this way instead of "for dependency in" or "for index in xrange"
949 # because the dependencies list will be modified within the loop body. 994 # because the dependencies list will be modified within the loop body.
950 index = 0 995 index = 0
951 while index < len(dependencies): 996 while index < len(dependencies):
952 (dependency_build_file, dependency_target) = \ 997 (dependency_build_file, dependency_target, dependency_toolset) = \
953 gyp.common.BuildFileAndTarget('', dependencies[index])[0:2] 998 gyp.common.ParseQualifiedTarget(dependencies[index])
954 if dependency_target != '*': 999 if dependency_target != '*' and dependency_toolset != '*':
955 # Not a wildcard. Keep it moving. 1000 # Not a wildcard. Keep it moving.
956 index = index + 1 1001 index = index + 1
957 continue 1002 continue
958 1003
959 if dependency_build_file == target_build_file: 1004 if dependency_build_file == target_build_file:
960 # It's an error for a target to depend on all other targets in 1005 # It's an error for a target to depend on all other targets in
961 # the same file, because a target cannot depend on itself. 1006 # the same file, because a target cannot depend on itself.
962 raise KeyError, 'Found wildcard in ' + dependency_key + ' of ' + \ 1007 raise KeyError, 'Found wildcard in ' + dependency_key + ' of ' + \
963 target + ' referring to same build file' 1008 target + ' referring to same build file'
964 1009
965 # Take the wildcard out and adjust the index so that the next 1010 # Take the wildcard out and adjust the index so that the next
966 # dependency in the list will be processed the next time through the 1011 # dependency in the list will be processed the next time through the
967 # loop. 1012 # loop.
968 del dependencies[index] 1013 del dependencies[index]
969 index = index - 1 1014 index = index - 1
970 1015
971 # Loop through the targets in the other build file, adding them to 1016 # Loop through the targets in the other build file, adding them to
972 # this target's list of dependencies in place of the removed 1017 # this target's list of dependencies in place of the removed
973 # wildcard. 1018 # wildcard.
974 dependency_target_dicts = data[dependency_build_file]['targets'] 1019 dependency_target_dicts = data[dependency_build_file]['targets']
975 for dependency_target_dict in dependency_target_dicts: 1020 for dependency_target_dict in dependency_target_dicts:
976 if dependency_target_dict.get('suppress_wildcard', False): 1021 if dependency_target_dict.get('suppress_wildcard', False):
977 continue 1022 continue
978 dependency_target_name = dependency_target_dict['target_name'] 1023 dependency_target_name = dependency_target_dict['target_name']
1024 if (dependency_target != '*' and
1025 dependency_target != dependency_target_name):
1026 continue
1027 dependency_target_toolset = dependency_target_dict['toolset']
1028 if (dependency_toolset != '*' and
1029 dependency_toolset != dependency_target_toolset):
1030 continue
979 dependency = gyp.common.QualifiedTarget(dependency_build_file, 1031 dependency = gyp.common.QualifiedTarget(dependency_build_file,
980 dependency_target_name) 1032 dependency_target_name,
1033 dependency_target_toolset)
981 index = index + 1 1034 index = index + 1
982 dependencies.insert(index, dependency) 1035 dependencies.insert(index, dependency)
983 1036
984 index = index + 1 1037 index = index + 1
985 1038
986 1039
987 class DependencyGraphNode(object): 1040 class DependencyGraphNode(object):
988 """ 1041 """
989 1042
990 Attributes: 1043 Attributes:
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 dependency_nodes = {} 1242 dependency_nodes = {}
1190 for target, spec in targets.iteritems(): 1243 for target, spec in targets.iteritems():
1191 if not target in dependency_nodes: 1244 if not target in dependency_nodes:
1192 dependency_nodes[target] = DependencyGraphNode(target) 1245 dependency_nodes[target] = DependencyGraphNode(target)
1193 1246
1194 # Set up the dependency links. Targets that have no dependencies are treated 1247 # Set up the dependency links. Targets that have no dependencies are treated
1195 # as dependent on root_node. 1248 # as dependent on root_node.
1196 root_node = DependencyGraphNode(None) 1249 root_node = DependencyGraphNode(None)
1197 for target, spec in targets.iteritems(): 1250 for target, spec in targets.iteritems():
1198 target_node = dependency_nodes[target] 1251 target_node = dependency_nodes[target]
1199 target_build_file = gyp.common.BuildFileAndTarget('', target)[0] 1252 target_build_file = gyp.common.BuildFile(target)
1200 if not 'dependencies' in spec or len(spec['dependencies']) == 0: 1253 if not 'dependencies' in spec or len(spec['dependencies']) == 0:
1201 target_node.dependencies = [root_node] 1254 target_node.dependencies = [root_node]
1202 root_node.dependents.append(target_node) 1255 root_node.dependents.append(target_node)
1203 else: 1256 else:
1204 dependencies = spec['dependencies'] 1257 dependencies = spec['dependencies']
1205 for index in xrange(0, len(dependencies)): 1258 for index in xrange(0, len(dependencies)):
1206 try: 1259 try:
1207 dependency = dependencies[index] 1260 dependency = dependencies[index]
1208 dependency_node = dependency_nodes[dependency] 1261 dependency_node = dependency_nodes[dependency]
1209 target_node.dependencies.append(dependency_node) 1262 target_node.dependencies.append(dependency_node)
(...skipping 14 matching lines...) Expand all
1224 1277
1225 return [dependency_nodes, flat_list] 1278 return [dependency_nodes, flat_list]
1226 1279
1227 1280
1228 def DoDependentSettings(key, flat_list, targets, dependency_nodes): 1281 def DoDependentSettings(key, flat_list, targets, dependency_nodes):
1229 # key should be one of all_dependent_settings, direct_dependent_settings, 1282 # key should be one of all_dependent_settings, direct_dependent_settings,
1230 # or link_settings. 1283 # or link_settings.
1231 1284
1232 for target in flat_list: 1285 for target in flat_list:
1233 target_dict = targets[target] 1286 target_dict = targets[target]
1234 build_file = gyp.common.BuildFileAndTarget('', target)[0] 1287 build_file = gyp.common.BuildFile(target)
1235 1288
1236 if key == 'all_dependent_settings': 1289 if key == 'all_dependent_settings':
1237 dependencies = dependency_nodes[target].DeepDependencies() 1290 dependencies = dependency_nodes[target].DeepDependencies()
1238 elif key == 'direct_dependent_settings': 1291 elif key == 'direct_dependent_settings':
1239 dependencies = \ 1292 dependencies = \
1240 dependency_nodes[target].DirectAndImportedDependencies(targets) 1293 dependency_nodes[target].DirectAndImportedDependencies(targets)
1241 elif key == 'link_settings': 1294 elif key == 'link_settings':
1242 dependencies = dependency_nodes[target].LinkDependencies(targets) 1295 dependencies = dependency_nodes[target].LinkDependencies(targets)
1243 else: 1296 else:
1244 raise KeyError, "DoDependentSettings doesn't know how to determine " + \ 1297 raise KeyError, "DoDependentSettings doesn't know how to determine " + \
1245 'dependencies for ' + key 1298 'dependencies for ' + key
1246 1299
1247 for dependency in dependencies: 1300 for dependency in dependencies:
1248 dependency_dict = targets[dependency] 1301 dependency_dict = targets[dependency]
1249 if not key in dependency_dict: 1302 if not key in dependency_dict:
1250 continue 1303 continue
1251 dependency_build_file = gyp.common.BuildFileAndTarget('', dependency)[0] 1304 dependency_build_file = gyp.common.BuildFile(dependency)
1252 MergeDicts(target_dict, dependency_dict[key], 1305 MergeDicts(target_dict, dependency_dict[key],
1253 build_file, dependency_build_file) 1306 build_file, dependency_build_file)
1254 1307
1255 1308
1256 def AdjustStaticLibraryDependencies(flat_list, targets, dependency_nodes): 1309 def AdjustStaticLibraryDependencies(flat_list, targets, dependency_nodes):
1257 # Recompute target "dependencies" properties. For each static library 1310 # Recompute target "dependencies" properties. For each static library
1258 # target, remove "dependencies" entries referring to other static libraries, 1311 # target, remove "dependencies" entries referring to other static libraries,
1259 # unless the dependency has the "hard_dependency" attribute set. For each 1312 # unless the dependency has the "hard_dependency" attribute set. For each
1260 # linkable target, add a "dependencies" entry referring to all of the 1313 # linkable target, add a "dependencies" entry referring to all of the
1261 # target's computed list of link dependencies (including static libraries 1314 # target's computed list of link dependencies (including static libraries
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 1548
1496 1549
1497 def SetUpConfigurations(target, target_dict): 1550 def SetUpConfigurations(target, target_dict):
1498 global non_configuration_keys 1551 global non_configuration_keys
1499 # key_suffixes is a list of key suffixes that might appear on key names. 1552 # key_suffixes is a list of key suffixes that might appear on key names.
1500 # These suffixes are handled in conditional evaluations (for =, +, and ?) 1553 # These suffixes are handled in conditional evaluations (for =, +, and ?)
1501 # and rules/exclude processing (for ! and /). Keys with these suffixes 1554 # and rules/exclude processing (for ! and /). Keys with these suffixes
1502 # should be treated the same as keys without. 1555 # should be treated the same as keys without.
1503 key_suffixes = ['=', '+', '?', '!', '/'] 1556 key_suffixes = ['=', '+', '?', '!', '/']
1504 1557
1505 build_file = gyp.common.BuildFileAndTarget('', target)[0] 1558 build_file = gyp.common.BuildFile(target)
1506 1559
1507 # Provide a single configuration by default if none exists. 1560 # Provide a single configuration by default if none exists.
1508 # TODO(mark): Signal an error if default_configurations exists but 1561 # TODO(mark): Signal an error if default_configurations exists but
1509 # configurations does not. 1562 # configurations does not.
1510 if not 'configurations' in target_dict: 1563 if not 'configurations' in target_dict:
1511 target_dict['configurations'] = {'Default': {}} 1564 target_dict['configurations'] = {'Default': {}}
1512 if not 'default_configuration' in target_dict: 1565 if not 'default_configuration' in target_dict:
1513 target_dict['default_configuration'] = \ 1566 target_dict['default_configuration'] = \
1514 sorted(target_dict['configurations'].keys())[0] 1567 sorted(target_dict['configurations'].keys())[0]
1515 1568
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 non_configuration_keys.extend(generator_input_info['non_configuration_keys']) 1920 non_configuration_keys.extend(generator_input_info['non_configuration_keys'])
1868 1921
1869 # TODO(mark) handle variants if the generator doesn't want them directly. 1922 # TODO(mark) handle variants if the generator doesn't want them directly.
1870 generator_handles_variants = \ 1923 generator_handles_variants = \
1871 generator_input_info['generator_handles_variants'] 1924 generator_input_info['generator_handles_variants']
1872 1925
1873 global absolute_build_file_paths 1926 global absolute_build_file_paths
1874 absolute_build_file_paths = \ 1927 absolute_build_file_paths = \
1875 generator_input_info['generator_wants_absolute_build_file_paths'] 1928 generator_input_info['generator_wants_absolute_build_file_paths']
1876 1929
1930 global multiple_toolsets
1931 multiple_toolsets = generator_input_info[
1932 'generator_supports_multiple_toolsets']
1933
1877 # A generator can have other lists (in addition to sources) be processed 1934 # A generator can have other lists (in addition to sources) be processed
1878 # for rules. 1935 # for rules.
1879 extra_sources_for_rules = generator_input_info['extra_sources_for_rules'] 1936 extra_sources_for_rules = generator_input_info['extra_sources_for_rules']
1880 1937
1881 # Load build files. This loads every target-containing build file into 1938 # Load build files. This loads every target-containing build file into
1882 # the |data| dictionary such that the keys to |data| are build file names, 1939 # the |data| dictionary such that the keys to |data| are build file names,
1883 # and the values are the entire build file contents after "early" or "pre" 1940 # and the values are the entire build file contents after "early" or "pre"
1884 # processing has been done and includes have been resolved. 1941 # processing has been done and includes have been resolved.
1885 data = {} 1942 # NOTE: data contains both "target" files (.gyp) and "includes" (.gypi), as
1943 # well as meta-data (e.g. 'included_files' key). 'target_build_files' keeps
1944 # track of the keys corresponding to "target" files.
1945 data = {'target_build_files': set()}
1886 aux_data = {} 1946 aux_data = {}
1887 for build_file in build_files: 1947 for build_file in build_files:
1888 # Normalize paths everywhere. This is important because paths will be 1948 # Normalize paths everywhere. This is important because paths will be
1889 # used as keys to the data dict and for references between input files. 1949 # used as keys to the data dict and for references between input files.
1890 build_file = os.path.normpath(build_file) 1950 build_file = os.path.normpath(build_file)
1891 try: 1951 try:
1892 LoadTargetBuildFile(build_file, data, aux_data, variables, includes, 1952 LoadTargetBuildFile(build_file, data, aux_data, variables, includes,
1893 depth, check) 1953 depth, check)
1894 except Exception, e: 1954 except Exception, e:
1895 gyp.common.ExceptionAppend(e, 'while trying to load %s' % build_file) 1955 gyp.common.ExceptionAppend(e, 'while trying to load %s' % build_file)
(...skipping 23 matching lines...) Expand all
1919 del targets[target][settings_type] 1979 del targets[target][settings_type]
1920 1980
1921 # Make sure static libraries don't declare dependencies on other static 1981 # Make sure static libraries don't declare dependencies on other static
1922 # libraries, but that linkables depend on all unlinked static libraries 1982 # libraries, but that linkables depend on all unlinked static libraries
1923 # that they need so that their link steps will be correct. 1983 # that they need so that their link steps will be correct.
1924 AdjustStaticLibraryDependencies(flat_list, targets, dependency_nodes) 1984 AdjustStaticLibraryDependencies(flat_list, targets, dependency_nodes)
1925 1985
1926 # Apply "post"/"late"/"target" variable expansions and condition evaluations. 1986 # Apply "post"/"late"/"target" variable expansions and condition evaluations.
1927 for target in flat_list: 1987 for target in flat_list:
1928 target_dict = targets[target] 1988 target_dict = targets[target]
1929 build_file = gyp.common.BuildFileAndTarget('', target)[0] 1989 build_file = gyp.common.BuildFile(target)
1930 ProcessVariablesAndConditionsInDict(target_dict, True, variables, 1990 ProcessVariablesAndConditionsInDict(target_dict, True, variables,
1931 build_file) 1991 build_file)
1932 1992
1933 # Move everything that can go into a "configurations" section into one. 1993 # Move everything that can go into a "configurations" section into one.
1934 for target in flat_list: 1994 for target in flat_list:
1935 target_dict = targets[target] 1995 target_dict = targets[target]
1936 SetUpConfigurations(target, target_dict) 1996 SetUpConfigurations(target, target_dict)
1937 1997
1938 # Apply exclude (!) and regex (/) list filters. 1998 # Apply exclude (!) and regex (/) list filters.
1939 for target in flat_list: 1999 for target in flat_list:
1940 target_dict = targets[target] 2000 target_dict = targets[target]
1941 ProcessListFiltersInDict(target, target_dict) 2001 ProcessListFiltersInDict(target, target_dict)
1942 2002
1943 # Make sure that the rules make sense, and build up rule_sources lists as 2003 # Make sure that the rules make sense, and build up rule_sources lists as
1944 # needed. Not all generators will need to use the rule_sources lists, but 2004 # needed. Not all generators will need to use the rule_sources lists, but
1945 # some may, and it seems best to build the list in a common spot. 2005 # some may, and it seems best to build the list in a common spot.
1946 # Also validate actions and run_as elements in targets. 2006 # Also validate actions and run_as elements in targets.
1947 for target in flat_list: 2007 for target in flat_list:
1948 target_dict = targets[target] 2008 target_dict = targets[target]
1949 build_file = gyp.common.BuildFileAndTarget('', target)[0] 2009 build_file = gyp.common.BuildFile(target)
1950 ValidateRulesInTarget(target, target_dict, extra_sources_for_rules) 2010 ValidateRulesInTarget(target, target_dict, extra_sources_for_rules)
1951 ValidateRunAsInTarget(target, target_dict, build_file) 2011 ValidateRunAsInTarget(target, target_dict, build_file)
1952 ValidateActionsInTarget(target, target_dict, build_file) 2012 ValidateActionsInTarget(target, target_dict, build_file)
1953 2013
1954 # Generators might not expect ints. Turn them into strs. 2014 # Generators might not expect ints. Turn them into strs.
1955 TurnIntIntoStrInDict(data) 2015 TurnIntIntoStrInDict(data)
1956 2016
1957 # TODO(mark): Return |data| for now because the generator needs a list of 2017 # TODO(mark): Return |data| for now because the generator needs a list of
1958 # build files that came in. In the future, maybe it should just accept 2018 # build files that came in. In the future, maybe it should just accept
1959 # a list, and not the whole data dict. 2019 # a list, and not the whole data dict.
1960 return [flat_list, targets, data] 2020 return [flat_list, targets, data]
OLDNEW
« no previous file with comments | « pylib/gyp/generator/xcode.py ('k') | test/toolsets/gyptest-toolsets.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698