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

Side by Side Diff: pylib/gyp/generator/msvs.py

Issue 107293004: win msvs: make ordering match .gyp order (Closed) Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: use OrderedSet instead Created 7 years 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 | test/win/gyptest-link-ordering.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 # Copyright (c) 2012 Google Inc. All rights reserved. 1 # Copyright (c) 2012 Google Inc. 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 import collections
5 import copy 6 import copy
6 import ntpath 7 import ntpath
7 import os 8 import os
8 import posixpath 9 import posixpath
9 import re 10 import re
10 import subprocess 11 import subprocess
11 import sys 12 import sys
12 13
13 import gyp.common 14 import gyp.common
14 import gyp.easy_xml as easy_xml 15 import gyp.easy_xml as easy_xml
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 'msvs_precompiled_source', 80 'msvs_precompiled_source',
80 ] 81 ]
81 82
82 83
83 cached_username = None 84 cached_username = None
84 85
85 86
86 cached_domain = None 87 cached_domain = None
87 88
88 89
90 # Based on http://code.activestate.com/recipes/576694/.
91 class OrderedSet(collections.MutableSet):
92 def __init__(self, iterable=None):
93 self.end = end = []
94 end += [None, end, end] # sentinel node for doubly linked list
95 self.map = {} # key --> [key, prev, next]
96 if iterable is not None:
97 self |= iterable
98
99 def __len__(self):
100 return len(self.map)
101
102 def discard(self, key):
Nico 2013/12/06 20:35:54 Is this needed?
scottmg 2013/12/06 20:43:46 Yup: http://docs.python.org/2/library/collections.
103 if key in self.map:
104 key, prev, next = self.map.pop(key)
105 prev[2] = next
106 next[1] = prev
107
108 def __contains__(self, key):
109 return key in self.map
110
111 def add(self, key):
112 if key not in self.map:
113 end = self.end
114 curr = end[1]
115 curr[2] = end[1] = self.map[key] = [key, curr, end]
116
117 def update(self, iterable):
118 for i in iterable:
119 if i not in self:
120 self.add(i)
121
122 def __iter__(self):
123 end = self.end
124 curr = end[2]
125 while curr is not end:
126 yield curr[0]
127 curr = curr[2]
128
129
89 # TODO(gspencer): Switch the os.environ calls to be 130 # TODO(gspencer): Switch the os.environ calls to be
90 # win32api.GetDomainName() and win32api.GetUserName() once the 131 # win32api.GetDomainName() and win32api.GetUserName() once the
91 # python version in depot_tools has been updated to work on Vista 132 # python version in depot_tools has been updated to work on Vista
92 # 64-bit. 133 # 64-bit.
93 def _GetDomainAndUserName(): 134 def _GetDomainAndUserName():
94 if sys.platform not in ('win32', 'cygwin'): 135 if sys.platform not in ('win32', 'cygwin'):
95 return ('DOMAIN', 'USERNAME') 136 return ('DOMAIN', 'USERNAME')
96 global cached_username 137 global cached_username
97 global cached_domain 138 global cached_domain
98 if not cached_domain or not cached_username: 139 if not cached_domain or not cached_username:
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 def _AddAccumulatedActionsToMSVS(p, spec, actions_dict): 449 def _AddAccumulatedActionsToMSVS(p, spec, actions_dict):
409 """Add actions accumulated into an actions_dict, merging as needed. 450 """Add actions accumulated into an actions_dict, merging as needed.
410 451
411 Arguments: 452 Arguments:
412 p: the target project 453 p: the target project
413 spec: the target project dict 454 spec: the target project dict
414 actions_dict: dictionary keyed on input name, which maps to a list of 455 actions_dict: dictionary keyed on input name, which maps to a list of
415 dicts describing the actions attached to that input file. 456 dicts describing the actions attached to that input file.
416 """ 457 """
417 for primary_input in actions_dict: 458 for primary_input in actions_dict:
418 inputs = set() 459 inputs = OrderedSet()
419 outputs = set() 460 outputs = OrderedSet()
420 descriptions = [] 461 descriptions = []
421 commands = [] 462 commands = []
422 for action in actions_dict[primary_input]: 463 for action in actions_dict[primary_input]:
423 inputs.update(set(action['inputs'])) 464 inputs.update(OrderedSet(action['inputs']))
424 outputs.update(set(action['outputs'])) 465 outputs.update(OrderedSet(action['outputs']))
425 descriptions.append(action['description']) 466 descriptions.append(action['description'])
426 commands.append(action['command']) 467 commands.append(action['command'])
427 # Add the custom build step for one input file. 468 # Add the custom build step for one input file.
428 description = ', and also '.join(descriptions) 469 description = ', and also '.join(descriptions)
429 command = '\r\n'.join(commands) 470 command = '\r\n'.join(commands)
430 _AddCustomBuildToolForMSVS(p, spec, 471 _AddCustomBuildToolForMSVS(p, spec,
431 primary_input=primary_input, 472 primary_input=primary_input,
432 inputs=inputs, 473 inputs=inputs,
433 outputs=outputs, 474 outputs=outputs,
434 description=description, 475 description=description,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 """Find the inputs and outputs generated by a rule. 511 """Find the inputs and outputs generated by a rule.
471 512
472 Arguments: 513 Arguments:
473 rule: the rule in question. 514 rule: the rule in question.
474 trigger_file: the main trigger for this rule. 515 trigger_file: the main trigger for this rule.
475 Returns: 516 Returns:
476 The pair of (inputs, outputs) involved in this rule. 517 The pair of (inputs, outputs) involved in this rule.
477 """ 518 """
478 raw_inputs = _FixPaths(rule.get('inputs', [])) 519 raw_inputs = _FixPaths(rule.get('inputs', []))
479 raw_outputs = _FixPaths(rule.get('outputs', [])) 520 raw_outputs = _FixPaths(rule.get('outputs', []))
480 inputs = set() 521 inputs = OrderedSet()
481 outputs = set() 522 outputs = OrderedSet()
482 inputs.add(trigger_file) 523 inputs.add(trigger_file)
483 for i in raw_inputs: 524 for i in raw_inputs:
484 inputs.add(_RuleExpandPath(i, trigger_file)) 525 inputs.add(_RuleExpandPath(i, trigger_file))
485 for o in raw_outputs: 526 for o in raw_outputs:
486 outputs.add(_RuleExpandPath(o, trigger_file)) 527 outputs.add(_RuleExpandPath(o, trigger_file))
487 return (inputs, outputs) 528 return (inputs, outputs)
488 529
489 530
490 def _GenerateNativeRulesForMSVS(p, rules, output_dir, spec, options): 531 def _GenerateNativeRulesForMSVS(p, rules, output_dir, spec, options):
491 """Generate a native rules file. 532 """Generate a native rules file.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 sources: set of sources known 583 sources: set of sources known
543 options: global generator options 584 options: global generator options
544 actions_to_add: The list of actions we will add to. 585 actions_to_add: The list of actions we will add to.
545 """ 586 """
546 filename = '%s_rules%s.mk' % (spec['target_name'], options.suffix) 587 filename = '%s_rules%s.mk' % (spec['target_name'], options.suffix)
547 mk_file = gyp.common.WriteOnDiff(os.path.join(output_dir, filename)) 588 mk_file = gyp.common.WriteOnDiff(os.path.join(output_dir, filename))
548 # Find cygwin style versions of some paths. 589 # Find cygwin style versions of some paths.
549 mk_file.write('OutDirCygwin:=$(shell cygpath -u "$(OutDir)")\n') 590 mk_file.write('OutDirCygwin:=$(shell cygpath -u "$(OutDir)")\n')
550 mk_file.write('IntDirCygwin:=$(shell cygpath -u "$(IntDir)")\n') 591 mk_file.write('IntDirCygwin:=$(shell cygpath -u "$(IntDir)")\n')
551 # Gather stuff needed to emit all: target. 592 # Gather stuff needed to emit all: target.
552 all_inputs = set() 593 all_inputs = OrderedSet()
553 all_outputs = set() 594 all_outputs = OrderedSet()
554 all_output_dirs = set() 595 all_output_dirs = OrderedSet()
555 first_outputs = [] 596 first_outputs = []
556 for rule in rules: 597 for rule in rules:
557 trigger_files = _FindRuleTriggerFiles(rule, sources) 598 trigger_files = _FindRuleTriggerFiles(rule, sources)
558 for tf in trigger_files: 599 for tf in trigger_files:
559 inputs, outputs = _RuleInputsAndOutputs(rule, tf) 600 inputs, outputs = _RuleInputsAndOutputs(rule, tf)
560 all_inputs.update(set(inputs)) 601 all_inputs.update(OrderedSet(inputs))
561 all_outputs.update(set(outputs)) 602 all_outputs.update(OrderedSet(outputs))
562 # Only use one target from each rule as the dependency for 603 # Only use one target from each rule as the dependency for
563 # 'all' so we don't try to build each rule multiple times. 604 # 'all' so we don't try to build each rule multiple times.
564 first_outputs.append(list(outputs)[0]) 605 first_outputs.append(list(outputs)[0])
565 # Get the unique output directories for this rule. 606 # Get the unique output directories for this rule.
566 output_dirs = [os.path.split(i)[0] for i in outputs] 607 output_dirs = [os.path.split(i)[0] for i in outputs]
567 for od in output_dirs: 608 for od in output_dirs:
568 all_output_dirs.add(od) 609 all_output_dirs.add(od)
569 first_outputs_cyg = [_Cygwinify(i) for i in first_outputs] 610 first_outputs_cyg = [_Cygwinify(i) for i in first_outputs]
570 # Write out all: target, including mkdir for each output directory. 611 # Write out all: target, including mkdir for each output directory.
571 mk_file.write('all: %s\n' % ' '.join(first_outputs_cyg)) 612 mk_file.write('all: %s\n' % ' '.join(first_outputs_cyg))
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 833
793 def _AdjustSourcesForRules(spec, rules, sources, excluded_sources): 834 def _AdjustSourcesForRules(spec, rules, sources, excluded_sources):
794 # Add outputs generated by each rule (if applicable). 835 # Add outputs generated by each rule (if applicable).
795 for rule in rules: 836 for rule in rules:
796 # Done if not processing outputs as sources. 837 # Done if not processing outputs as sources.
797 if int(rule.get('process_outputs_as_sources', False)): 838 if int(rule.get('process_outputs_as_sources', False)):
798 # Add in the outputs from this rule. 839 # Add in the outputs from this rule.
799 trigger_files = _FindRuleTriggerFiles(rule, sources) 840 trigger_files = _FindRuleTriggerFiles(rule, sources)
800 for trigger_file in trigger_files: 841 for trigger_file in trigger_files:
801 inputs, outputs = _RuleInputsAndOutputs(rule, trigger_file) 842 inputs, outputs = _RuleInputsAndOutputs(rule, trigger_file)
802 inputs = set(_FixPaths(inputs)) 843 inputs = OrderedSet(_FixPaths(inputs))
803 outputs = set(_FixPaths(outputs)) 844 outputs = OrderedSet(_FixPaths(outputs))
804 inputs.remove(_FixPath(trigger_file)) 845 inputs.remove(_FixPath(trigger_file))
805 sources.update(inputs) 846 sources.update(inputs)
806 if not spec.get('msvs_external_builder'): 847 if not spec.get('msvs_external_builder'):
807 excluded_sources.update(inputs) 848 excluded_sources.update(inputs)
808 sources.update(outputs) 849 sources.update(outputs)
809 850
810 851
811 def _FilterActionsFromExcluded(excluded_sources, actions_to_add): 852 def _FilterActionsFromExcluded(excluded_sources, actions_to_add):
812 """Take inputs with actions attached out of the list of exclusions. 853 """Take inputs with actions attached out of the list of exclusions.
813 854
814 Arguments: 855 Arguments:
815 excluded_sources: list of source files not to be built. 856 excluded_sources: list of source files not to be built.
816 actions_to_add: dict of actions keyed on source file they're attached to. 857 actions_to_add: dict of actions keyed on source file they're attached to.
817 Returns: 858 Returns:
818 excluded_sources with files that have actions attached removed. 859 excluded_sources with files that have actions attached removed.
819 """ 860 """
820 must_keep = set(_FixPaths(actions_to_add.keys())) 861 must_keep = OrderedSet(_FixPaths(actions_to_add.keys()))
821 return [s for s in excluded_sources if s not in must_keep] 862 return [s for s in excluded_sources if s not in must_keep]
822 863
823 864
824 def _GetDefaultConfiguration(spec): 865 def _GetDefaultConfiguration(spec):
825 return spec['configurations'][spec['default_configuration']] 866 return spec['configurations'][spec['default_configuration']]
826 867
827 868
828 def _GetGuidOfProject(proj_path, spec): 869 def _GetGuidOfProject(proj_path, spec):
829 """Get the guid for the project. 870 """Get the guid for the project.
830 871
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 999
959 def _GetUniquePlatforms(spec): 1000 def _GetUniquePlatforms(spec):
960 """Returns the list of unique platforms for this spec, e.g ['win32', ...]. 1001 """Returns the list of unique platforms for this spec, e.g ['win32', ...].
961 1002
962 Arguments: 1003 Arguments:
963 spec: The target dictionary containing the properties of the target. 1004 spec: The target dictionary containing the properties of the target.
964 Returns: 1005 Returns:
965 The MSVSUserFile object created. 1006 The MSVSUserFile object created.
966 """ 1007 """
967 # Gather list of unique platforms. 1008 # Gather list of unique platforms.
968 platforms = set() 1009 platforms = OrderedSet()
969 for configuration in spec['configurations']: 1010 for configuration in spec['configurations']:
970 platforms.add(_ConfigPlatform(spec['configurations'][configuration])) 1011 platforms.add(_ConfigPlatform(spec['configurations'][configuration]))
971 platforms = list(platforms) 1012 platforms = list(platforms)
972 return platforms 1013 return platforms
973 1014
974 1015
975 def _CreateMSVSUserFile(proj_path, version, spec): 1016 def _CreateMSVSUserFile(proj_path, version, spec):
976 """Generates a .user file for the user running this Gyp program. 1017 """Generates a .user file for the user running this Gyp program.
977 1018
978 Arguments: 1019 Arguments:
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 Arguments: 1186 Arguments:
1146 spec: The target dictionary containing the properties of the target. 1187 spec: The target dictionary containing the properties of the target.
1147 Returns: 1188 Returns:
1148 The list of directory paths. 1189 The list of directory paths.
1149 """ 1190 """
1150 libraries = spec.get('libraries', []) 1191 libraries = spec.get('libraries', [])
1151 # Strip out -l, as it is not used on windows (but is needed so we can pass 1192 # Strip out -l, as it is not used on windows (but is needed so we can pass
1152 # in libraries that are assumed to be in the default library path). 1193 # in libraries that are assumed to be in the default library path).
1153 # Also remove duplicate entries, leaving only the last duplicate, while 1194 # Also remove duplicate entries, leaving only the last duplicate, while
1154 # preserving order. 1195 # preserving order.
1155 found = set() 1196 found = OrderedSet()
1156 unique_libraries_list = [] 1197 unique_libraries_list = []
1157 for entry in reversed(libraries): 1198 for entry in reversed(libraries):
1158 library = re.sub('^\-l', '', entry) 1199 library = re.sub('^\-l', '', entry)
1159 if not os.path.splitext(library)[1]: 1200 if not os.path.splitext(library)[1]:
1160 library += '.lib' 1201 library += '.lib'
1161 if library not in found: 1202 if library not in found:
1162 found.add(library) 1203 found.add(library)
1163 unique_libraries_list.append(library) 1204 unique_libraries_list.append(library)
1164 unique_libraries_list.reverse() 1205 unique_libraries_list.reverse()
1165 return unique_libraries_list 1206 return unique_libraries_list
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 intermediate = '$(ConfigurationName)\\obj\\$(ProjectName)' 1365 intermediate = '$(ConfigurationName)\\obj\\$(ProjectName)'
1325 prepared_attrs['IntermediateDirectory'] = _FixPath(intermediate) + '\\' 1366 prepared_attrs['IntermediateDirectory'] = _FixPath(intermediate) + '\\'
1326 else: 1367 else:
1327 intermediate = _FixPath(prepared_attrs['IntermediateDirectory']) + '\\' 1368 intermediate = _FixPath(prepared_attrs['IntermediateDirectory']) + '\\'
1328 intermediate = MSVSSettings.FixVCMacroSlashes(intermediate) 1369 intermediate = MSVSSettings.FixVCMacroSlashes(intermediate)
1329 prepared_attrs['IntermediateDirectory'] = intermediate 1370 prepared_attrs['IntermediateDirectory'] = intermediate
1330 return prepared_attrs 1371 return prepared_attrs
1331 1372
1332 1373
1333 def _AddNormalizedSources(sources_set, sources_array): 1374 def _AddNormalizedSources(sources_set, sources_array):
1334 sources = [_NormalizedSource(s) for s in sources_array] 1375 sources_set.update(_NormalizedSource(s) for s in sources_array)
1335 sources_set.update(set(sources))
1336 1376
1337 1377
1338 def _PrepareListOfSources(spec, generator_flags, gyp_file): 1378 def _PrepareListOfSources(spec, generator_flags, gyp_file):
1339 """Prepare list of sources and excluded sources. 1379 """Prepare list of sources and excluded sources.
1340 1380
1341 Besides the sources specified directly in the spec, adds the gyp file so 1381 Besides the sources specified directly in the spec, adds the gyp file so
1342 that a change to it will cause a re-compile. Also adds appropriate sources 1382 that a change to it will cause a re-compile. Also adds appropriate sources
1343 for actions and copies. Assumes later stage will un-exclude files which 1383 for actions and copies. Assumes later stage will un-exclude files which
1344 have custom build steps attached. 1384 have custom build steps attached.
1345 1385
1346 Arguments: 1386 Arguments:
1347 spec: The target dictionary containing the properties of the target. 1387 spec: The target dictionary containing the properties of the target.
1348 gyp_file: The name of the gyp file. 1388 gyp_file: The name of the gyp file.
1349 Returns: 1389 Returns:
1350 A pair of (list of sources, list of excluded sources). 1390 A pair of (list of sources, list of excluded sources).
1351 The sources will be relative to the gyp file. 1391 The sources will be relative to the gyp file.
1352 """ 1392 """
1353 sources = set() 1393 sources = OrderedSet()
1354 _AddNormalizedSources(sources, spec.get('sources', [])) 1394 _AddNormalizedSources(sources, spec.get('sources', []))
1355 excluded_sources = set() 1395 excluded_sources = OrderedSet()
1356 # Add in the gyp file. 1396 # Add in the gyp file.
1357 if not generator_flags.get('standalone'): 1397 if not generator_flags.get('standalone'):
1358 sources.add(gyp_file) 1398 sources.add(gyp_file)
1359 1399
1360 # Add in 'action' inputs and outputs. 1400 # Add in 'action' inputs and outputs.
1361 for a in spec.get('actions', []): 1401 for a in spec.get('actions', []):
1362 inputs = a['inputs'] 1402 inputs = a['inputs']
1363 inputs = [_NormalizedSource(i) for i in inputs] 1403 inputs = [_NormalizedSource(i) for i in inputs]
1364 # Add all inputs to sources and excluded sources. 1404 # Add all inputs to sources and excluded sources.
1365 inputs = set(inputs) 1405 inputs = OrderedSet(inputs)
1366 sources.update(inputs) 1406 sources.update(inputs)
1367 if not spec.get('msvs_external_builder'): 1407 if not spec.get('msvs_external_builder'):
1368 excluded_sources.update(inputs) 1408 excluded_sources.update(inputs)
1369 if int(a.get('process_outputs_as_sources', False)): 1409 if int(a.get('process_outputs_as_sources', False)):
1370 _AddNormalizedSources(sources, a.get('outputs', [])) 1410 _AddNormalizedSources(sources, a.get('outputs', []))
1371 # Add in 'copies' inputs and outputs. 1411 # Add in 'copies' inputs and outputs.
1372 for cpy in spec.get('copies', []): 1412 for cpy in spec.get('copies', []):
1373 _AddNormalizedSources(sources, cpy.get('files', [])) 1413 _AddNormalizedSources(sources, cpy.get('files', []))
1374 return (sources, excluded_sources) 1414 return (sources, excluded_sources)
1375 1415
1376 1416
1377 def _AdjustSourcesAndConvertToFilterHierarchy( 1417 def _AdjustSourcesAndConvertToFilterHierarchy(
1378 spec, options, gyp_dir, sources, excluded_sources, list_excluded): 1418 spec, options, gyp_dir, sources, excluded_sources, list_excluded):
1379 """Adjusts the list of sources and excluded sources. 1419 """Adjusts the list of sources and excluded sources.
1380 1420
1381 Also converts the sets to lists. 1421 Also converts the sets to lists.
1382 1422
1383 Arguments: 1423 Arguments:
1384 spec: The target dictionary containing the properties of the target. 1424 spec: The target dictionary containing the properties of the target.
1385 options: Global generator options. 1425 options: Global generator options.
1386 gyp_dir: The path to the gyp file being processed. 1426 gyp_dir: The path to the gyp file being processed.
1387 sources: A set of sources to be included for this project. 1427 sources: A set of sources to be included for this project.
1388 excluded_sources: A set of sources to be excluded for this project. 1428 excluded_sources: A set of sources to be excluded for this project.
1389 Returns: 1429 Returns:
1390 A trio of (list of sources, list of excluded sources, 1430 A trio of (list of sources, list of excluded sources,
1391 path of excluded IDL file) 1431 path of excluded IDL file)
1392 """ 1432 """
1393 # Exclude excluded sources coming into the generator. 1433 # Exclude excluded sources coming into the generator.
1394 excluded_sources.update(set(spec.get('sources_excluded', []))) 1434 excluded_sources.update(OrderedSet(spec.get('sources_excluded', [])))
1395 # Add excluded sources into sources for good measure. 1435 # Add excluded sources into sources for good measure.
1396 sources.update(excluded_sources) 1436 sources.update(excluded_sources)
1397 # Convert to proper windows form. 1437 # Convert to proper windows form.
1398 # NOTE: sources goes from being a set to a list here. 1438 # NOTE: sources goes from being a set to a list here.
1399 # NOTE: excluded_sources goes from being a set to a list here. 1439 # NOTE: excluded_sources goes from being a set to a list here.
1400 sources = _FixPaths(sources) 1440 sources = _FixPaths(sources)
1401 # Convert to proper windows form. 1441 # Convert to proper windows form.
1402 excluded_sources = _FixPaths(excluded_sources) 1442 excluded_sources = _FixPaths(excluded_sources)
1403 1443
1404 excluded_idl = _IdlFilesHandledNonNatively(spec, sources) 1444 excluded_idl = _IdlFilesHandledNonNatively(spec, sources)
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 for f in excluded_idl: 1517 for f in excluded_idl:
1478 excluded_configs = [] 1518 excluded_configs = []
1479 for config_name, config in spec['configurations'].iteritems(): 1519 for config_name, config in spec['configurations'].iteritems():
1480 excluded_configs.append((config_name, config)) 1520 excluded_configs.append((config_name, config))
1481 exclusions[f] = excluded_configs 1521 exclusions[f] = excluded_configs
1482 return exclusions 1522 return exclusions
1483 1523
1484 1524
1485 def _AddToolFilesToMSVS(p, spec): 1525 def _AddToolFilesToMSVS(p, spec):
1486 # Add in tool files (rules). 1526 # Add in tool files (rules).
1487 tool_files = set() 1527 tool_files = OrderedSet()
1488 for _, config in spec['configurations'].iteritems(): 1528 for _, config in spec['configurations'].iteritems():
1489 for f in config.get('msvs_tool_files', []): 1529 for f in config.get('msvs_tool_files', []):
1490 tool_files.add(f) 1530 tool_files.add(f)
1491 for f in tool_files: 1531 for f in tool_files:
1492 p.AddToolFile(f) 1532 p.AddToolFile(f)
1493 1533
1494 1534
1495 def _HandlePreCompiledHeaders(p, sources, spec): 1535 def _HandlePreCompiledHeaders(p, sources, spec):
1496 # Pre-compiled header source stubs need a different compiler flag 1536 # Pre-compiled header source stubs need a different compiler flag
1497 # (generate precompiled header) and any source file not of the same 1537 # (generate precompiled header) and any source file not of the same
(...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after
3200 """Add actions accumulated into an actions_to_add, merging as needed. 3240 """Add actions accumulated into an actions_to_add, merging as needed.
3201 3241
3202 Arguments: 3242 Arguments:
3203 spec: the target project dict 3243 spec: the target project dict
3204 actions_to_add: dictionary keyed on input name, which maps to a list of 3244 actions_to_add: dictionary keyed on input name, which maps to a list of
3205 dicts describing the actions attached to that input file. 3245 dicts describing the actions attached to that input file.
3206 3246
3207 Returns: 3247 Returns:
3208 A pair of (action specification, the sources handled by this action). 3248 A pair of (action specification, the sources handled by this action).
3209 """ 3249 """
3210 sources_handled_by_action = set() 3250 sources_handled_by_action = OrderedSet()
3211 actions_spec = [] 3251 actions_spec = []
3212 for primary_input, actions in actions_to_add.iteritems(): 3252 for primary_input, actions in actions_to_add.iteritems():
3213 inputs = set() 3253 inputs = OrderedSet()
3214 outputs = set() 3254 outputs = OrderedSet()
3215 descriptions = [] 3255 descriptions = []
3216 commands = [] 3256 commands = []
3217 for action in actions: 3257 for action in actions:
3218 inputs.update(set(action['inputs'])) 3258 inputs.update(OrderedSet(action['inputs']))
3219 outputs.update(set(action['outputs'])) 3259 outputs.update(OrderedSet(action['outputs']))
3220 descriptions.append(action['description']) 3260 descriptions.append(action['description'])
3221 cmd = action['command'] 3261 cmd = action['command']
3222 # For most actions, add 'call' so that actions that invoke batch files 3262 # For most actions, add 'call' so that actions that invoke batch files
3223 # return and continue executing. msbuild_use_call provides a way to 3263 # return and continue executing. msbuild_use_call provides a way to
3224 # disable this but I have not seen any adverse effect from doing that 3264 # disable this but I have not seen any adverse effect from doing that
3225 # for everything. 3265 # for everything.
3226 if action.get('msbuild_use_call', True): 3266 if action.get('msbuild_use_call', True):
3227 cmd = 'call ' + cmd 3267 cmd = 'call ' + cmd
3228 commands.append(cmd) 3268 commands.append(cmd)
3229 # Add the custom build action for one input file. 3269 # Add the custom build action for one input file.
(...skipping 30 matching lines...) Expand all
3260 action_spec.extend( 3300 action_spec.extend(
3261 # TODO(jeanluc) 'Document' for all or just if as_sources? 3301 # TODO(jeanluc) 'Document' for all or just if as_sources?
3262 [['FileType', 'Document'], 3302 [['FileType', 'Document'],
3263 ['Command', command], 3303 ['Command', command],
3264 ['Message', description], 3304 ['Message', description],
3265 ['Outputs', outputs] 3305 ['Outputs', outputs]
3266 ]) 3306 ])
3267 if additional_inputs: 3307 if additional_inputs:
3268 action_spec.append(['AdditionalInputs', additional_inputs]) 3308 action_spec.append(['AdditionalInputs', additional_inputs])
3269 actions_spec.append(action_spec) 3309 actions_spec.append(action_spec)
OLDNEW
« no previous file with comments | « no previous file | test/win/gyptest-link-ordering.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698