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

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

Issue 10306013: MSVS: Fix to ensure that actions are re-run when the action command changes (Closed) Base URL: http://git.chromium.org/external/gyp.git@master
Patch Set: Fix test/intermediate_dir/gyptest-intermediate-dir.py (covers case where inputs list is empty) Created 8 years, 7 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 | test/actions-args-change/gyptest-all.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 copy 5 import copy
6 import ntpath 6 import ntpath
7 import os 7 import os
8 import posixpath 8 import posixpath
9 import re 9 import re
10 import subprocess 10 import subprocess
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 os.makedirs(vcproj_dir) 873 os.makedirs(vcproj_dir)
874 874
875 platforms = _GetUniquePlatforms(spec) 875 platforms = _GetUniquePlatforms(spec)
876 p = MSVSProject.Writer(project.path, version, spec['target_name'], 876 p = MSVSProject.Writer(project.path, version, spec['target_name'],
877 project.guid, platforms) 877 project.guid, platforms)
878 878
879 # Get directory project file is in. 879 # Get directory project file is in.
880 project_dir = os.path.split(project.path)[0] 880 project_dir = os.path.split(project.path)[0]
881 gyp_path = _NormalizedSource(project.build_file) 881 gyp_path = _NormalizedSource(project.build_file)
882 relative_path_of_gyp_file = gyp.common.RelativePath(gyp_path, project_dir) 882 relative_path_of_gyp_file = gyp.common.RelativePath(gyp_path, project_dir)
883 relative_path_of_vcproj_file = \
884 gyp.common.RelativePath(project.path, project_dir)
883 885
884 config_type = _GetMSVSConfigurationType(spec, project.build_file) 886 config_type = _GetMSVSConfigurationType(spec, project.build_file)
885 for config_name, config in spec['configurations'].iteritems(): 887 for config_name, config in spec['configurations'].iteritems():
886 _AddConfigurationToMSVSProject(p, spec, config_type, config_name, config) 888 _AddConfigurationToMSVSProject(p, spec, config_type, config_name, config)
887 889
888 # Prepare list of sources and excluded sources. 890 # Prepare list of sources and excluded sources.
889 gyp_file = os.path.split(project.build_file)[1] 891 gyp_file = os.path.split(project.build_file)[1]
890 sources, excluded_sources = _PrepareListOfSources(spec, gyp_file) 892 sources, excluded_sources = _PrepareListOfSources(spec, gyp_file)
891 893
892 # Add rules. 894 # Add rules.
893 actions_to_add = {} 895 actions_to_add = {}
894 _GenerateRulesForMSVS(p, project_dir, options, spec, 896 _GenerateRulesForMSVS(p, project_dir, options, spec,
895 sources, excluded_sources, 897 sources, excluded_sources,
896 actions_to_add) 898 actions_to_add)
897 list_excluded = generator_flags.get('msvs_list_excluded_files', True) 899 list_excluded = generator_flags.get('msvs_list_excluded_files', True)
898 sources, excluded_sources, excluded_idl = ( 900 sources, excluded_sources, excluded_idl = (
899 _AdjustSourcesAndConvertToFilterHierarchy( 901 _AdjustSourcesAndConvertToFilterHierarchy(
900 spec, options, project_dir, sources, excluded_sources, list_excluded)) 902 spec, options, project_dir, sources, excluded_sources, list_excluded))
901 903
902 # Add in files. 904 # Add in files.
903 missing_sources = _VerifySourcesExist(sources, project_dir) 905 missing_sources = _VerifySourcesExist(sources, project_dir)
904 p.AddFiles(sources) 906 p.AddFiles(sources)
905 907
906 _AddToolFilesToMSVS(p, spec) 908 _AddToolFilesToMSVS(p, spec)
907 _HandlePreCompiledHeaders(p, sources, spec) 909 _HandlePreCompiledHeaders(p, sources, spec)
908 _AddActions(actions_to_add, spec, relative_path_of_gyp_file) 910 _AddActions(actions_to_add, spec, relative_path_of_gyp_file,
911 relative_path_of_vcproj_file)
909 _AddCopies(actions_to_add, spec) 912 _AddCopies(actions_to_add, spec)
910 _WriteMSVSUserFile(project.path, version, spec) 913 _WriteMSVSUserFile(project.path, version, spec)
911 914
912 # NOTE: this stanza must appear after all actions have been decided. 915 # NOTE: this stanza must appear after all actions have been decided.
913 # Don't excluded sources with actions attached, or they won't run. 916 # Don't excluded sources with actions attached, or they won't run.
914 excluded_sources = _FilterActionsFromExcluded( 917 excluded_sources = _FilterActionsFromExcluded(
915 excluded_sources, actions_to_add) 918 excluded_sources, actions_to_add)
916 _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl, 919 _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl,
917 list_excluded) 920 list_excluded)
918 _AddAccumulatedActionsToMSVS(p, spec, actions_to_add) 921 _AddAccumulatedActionsToMSVS(p, spec, actions_to_add)
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 {'UsePrecompiledHeader': '0', 1437 {'UsePrecompiledHeader': '0',
1435 'ForcedIncludeFiles': '$(NOINHERIT)'}) 1438 'ForcedIncludeFiles': '$(NOINHERIT)'})
1436 p.AddFileConfig(_FixPath(source), 1439 p.AddFileConfig(_FixPath(source),
1437 _ConfigFullName(config_name, config), 1440 _ConfigFullName(config_name, config),
1438 {}, tools=[tool]) 1441 {}, tools=[tool])
1439 # Do nothing if there was no precompiled source. 1442 # Do nothing if there was no precompiled source.
1440 if extensions_excluded_from_precompile: 1443 if extensions_excluded_from_precompile:
1441 DisableForSourceTree(sources) 1444 DisableForSourceTree(sources)
1442 1445
1443 1446
1444 def _AddActions(actions_to_add, spec, relative_path_of_gyp_file): 1447 def _AddActions(actions_to_add, spec, relative_path_of_gyp_file,
1448 relative_path_of_project_file):
1445 # Add actions. 1449 # Add actions.
1446 actions = spec.get('actions', []) 1450 actions = spec.get('actions', [])
1447 for a in actions: 1451 for a in actions:
1448 cmd = _BuildCommandLineForRule(spec, a, has_input_path=False) 1452 cmd = _BuildCommandLineForRule(spec, a, has_input_path=False)
1449 # Attach actions to the gyp file if nothing else is there. 1453 # Attach actions to the gyp file if nothing else is there.
1450 inputs = a.get('inputs') or [relative_path_of_gyp_file] 1454 inputs = a.get('inputs') or [relative_path_of_gyp_file]
jeanluc1 2012/05/02 23:50:24 I'm curious... what was the problem with only usin
Mark Seaborn 2012/05/03 00:39:20 The trybot failures were caused by my change after
1455 # Additionally, we mark the project file as a dependency of the
1456 # action so that when the action's command changes, the action
1457 # will get re-run even if no other input files change. However,
1458 # this will re-run unchanged actions unnecessarily when the
1459 # project file changes.
1460 # TODO(mseaborn): Detect changes at a finer granularity.
1461 inputs = inputs + [relative_path_of_project_file]
1451 # Add the action. 1462 # Add the action.
1452 _AddActionStep(actions_to_add, 1463 _AddActionStep(actions_to_add,
1453 inputs=inputs, 1464 inputs=inputs,
1454 outputs=a.get('outputs', []), 1465 outputs=a.get('outputs', []),
1455 description=a.get('message', a['action_name']), 1466 description=a.get('message', a['action_name']),
1456 command=cmd) 1467 command=cmd)
1457 1468
1458 1469
1459 def _WriteMSVSUserFile(project_path, version, spec): 1470 def _WriteMSVSUserFile(project_path, version, spec):
1460 # Add run_as and test targets. 1471 # Add run_as and test targets.
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after
2885 2896
2886 2897
2887 def _GenerateMSBuildProject(project, options, version, generator_flags): 2898 def _GenerateMSBuildProject(project, options, version, generator_flags):
2888 spec = project.spec 2899 spec = project.spec
2889 configurations = spec['configurations'] 2900 configurations = spec['configurations']
2890 project_dir, project_file_name = os.path.split(project.path) 2901 project_dir, project_file_name = os.path.split(project.path)
2891 msbuildproj_dir = os.path.dirname(project.path) 2902 msbuildproj_dir = os.path.dirname(project.path)
2892 if msbuildproj_dir and not os.path.exists(msbuildproj_dir): 2903 if msbuildproj_dir and not os.path.exists(msbuildproj_dir):
2893 os.makedirs(msbuildproj_dir) 2904 os.makedirs(msbuildproj_dir)
2894 # Prepare list of sources and excluded sources. 2905 # Prepare list of sources and excluded sources.
2895 gyp_path = _NormalizedSource(project.build_file)
2896 relative_path_of_gyp_file = gyp.common.RelativePath(gyp_path, project_dir)
2897
2898 gyp_file = os.path.split(project.build_file)[1] 2906 gyp_file = os.path.split(project.build_file)[1]
2899 sources, excluded_sources = _PrepareListOfSources(spec, gyp_file) 2907 sources, excluded_sources = _PrepareListOfSources(spec, gyp_file)
2900 # Add rules. 2908 # Add rules.
2901 actions_to_add = {} 2909 actions_to_add = {}
2902 props_files_of_rules = set() 2910 props_files_of_rules = set()
2903 targets_files_of_rules = set() 2911 targets_files_of_rules = set()
2904 extension_to_rule_name = {} 2912 extension_to_rule_name = {}
2905 list_excluded = generator_flags.get('msvs_list_excluded_files', True) 2913 list_excluded = generator_flags.get('msvs_list_excluded_files', True)
2906 _GenerateRulesForMSBuild(project_dir, options, spec, 2914 _GenerateRulesForMSBuild(project_dir, options, spec,
2907 sources, excluded_sources, 2915 sources, excluded_sources,
2908 props_files_of_rules, targets_files_of_rules, 2916 props_files_of_rules, targets_files_of_rules,
2909 actions_to_add, extension_to_rule_name) 2917 actions_to_add, extension_to_rule_name)
2910 sources, excluded_sources, excluded_idl = ( 2918 sources, excluded_sources, excluded_idl = (
2911 _AdjustSourcesAndConvertToFilterHierarchy(spec, options, 2919 _AdjustSourcesAndConvertToFilterHierarchy(spec, options,
2912 project_dir, sources, 2920 project_dir, sources,
2913 excluded_sources, 2921 excluded_sources,
2914 list_excluded)) 2922 list_excluded))
2915 _AddActions(actions_to_add, spec, project.build_file) 2923 _AddActions(actions_to_add, spec, project.build_file, project.path)
2916 _AddCopies(actions_to_add, spec) 2924 _AddCopies(actions_to_add, spec)
2917 2925
2918 # NOTE: this stanza must appear after all actions have been decided. 2926 # NOTE: this stanza must appear after all actions have been decided.
2919 # Don't excluded sources with actions attached, or they won't run. 2927 # Don't excluded sources with actions attached, or they won't run.
2920 excluded_sources = _FilterActionsFromExcluded( 2928 excluded_sources = _FilterActionsFromExcluded(
2921 excluded_sources, actions_to_add) 2929 excluded_sources, actions_to_add)
2922 2930
2923 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) 2931 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl)
2924 actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( 2932 actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild(
2925 spec, actions_to_add) 2933 spec, actions_to_add)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
3047 action_spec.extend( 3055 action_spec.extend(
3048 # TODO(jeanluc) 'Document' for all or just if as_sources? 3056 # TODO(jeanluc) 'Document' for all or just if as_sources?
3049 [['FileType', 'Document'], 3057 [['FileType', 'Document'],
3050 ['Command', command], 3058 ['Command', command],
3051 ['Message', description], 3059 ['Message', description],
3052 ['Outputs', outputs] 3060 ['Outputs', outputs]
3053 ]) 3061 ])
3054 if additional_inputs: 3062 if additional_inputs:
3055 action_spec.append(['AdditionalInputs', additional_inputs]) 3063 action_spec.append(['AdditionalInputs', additional_inputs])
3056 actions_spec.append(action_spec) 3064 actions_spec.append(action_spec)
OLDNEW
« no previous file with comments | « no previous file | test/actions-args-change/gyptest-all.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698