OLD | NEW |
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 Loading... |
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 Loading... |
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_vcproj_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] |
| 1455 if relative_path_of_vcproj_file: |
| 1456 # Additionally, on MSVS 2008, we mark the project file as a |
| 1457 # dependency of the action so that when the action's command |
| 1458 # changes, the action will get re-run even if no other input |
| 1459 # files change. However, this will re-run unchanged actions |
| 1460 # unnecessarily when the project file changes. This is not |
| 1461 # necessary on MSVS 2010 which handles command changes for us. |
| 1462 # TODO(mseaborn): Detect changes at a finer granularity. |
| 1463 inputs = inputs + [relative_path_of_vcproj_file] |
1451 # Add the action. | 1464 # Add the action. |
1452 _AddActionStep(actions_to_add, | 1465 _AddActionStep(actions_to_add, |
1453 inputs=inputs, | 1466 inputs=inputs, |
1454 outputs=a.get('outputs', []), | 1467 outputs=a.get('outputs', []), |
1455 description=a.get('message', a['action_name']), | 1468 description=a.get('message', a['action_name']), |
1456 command=cmd) | 1469 command=cmd) |
1457 | 1470 |
1458 | 1471 |
1459 def _WriteMSVSUserFile(project_path, version, spec): | 1472 def _WriteMSVSUserFile(project_path, version, spec): |
1460 # Add run_as and test targets. | 1473 # Add run_as and test targets. |
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2885 | 2898 |
2886 | 2899 |
2887 def _GenerateMSBuildProject(project, options, version, generator_flags): | 2900 def _GenerateMSBuildProject(project, options, version, generator_flags): |
2888 spec = project.spec | 2901 spec = project.spec |
2889 configurations = spec['configurations'] | 2902 configurations = spec['configurations'] |
2890 project_dir, project_file_name = os.path.split(project.path) | 2903 project_dir, project_file_name = os.path.split(project.path) |
2891 msbuildproj_dir = os.path.dirname(project.path) | 2904 msbuildproj_dir = os.path.dirname(project.path) |
2892 if msbuildproj_dir and not os.path.exists(msbuildproj_dir): | 2905 if msbuildproj_dir and not os.path.exists(msbuildproj_dir): |
2893 os.makedirs(msbuildproj_dir) | 2906 os.makedirs(msbuildproj_dir) |
2894 # Prepare list of sources and excluded sources. | 2907 # 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] | 2908 gyp_file = os.path.split(project.build_file)[1] |
2899 sources, excluded_sources = _PrepareListOfSources(spec, gyp_file) | 2909 sources, excluded_sources = _PrepareListOfSources(spec, gyp_file) |
2900 # Add rules. | 2910 # Add rules. |
2901 actions_to_add = {} | 2911 actions_to_add = {} |
2902 props_files_of_rules = set() | 2912 props_files_of_rules = set() |
2903 targets_files_of_rules = set() | 2913 targets_files_of_rules = set() |
2904 extension_to_rule_name = {} | 2914 extension_to_rule_name = {} |
2905 list_excluded = generator_flags.get('msvs_list_excluded_files', True) | 2915 list_excluded = generator_flags.get('msvs_list_excluded_files', True) |
2906 _GenerateRulesForMSBuild(project_dir, options, spec, | 2916 _GenerateRulesForMSBuild(project_dir, options, spec, |
2907 sources, excluded_sources, | 2917 sources, excluded_sources, |
2908 props_files_of_rules, targets_files_of_rules, | 2918 props_files_of_rules, targets_files_of_rules, |
2909 actions_to_add, extension_to_rule_name) | 2919 actions_to_add, extension_to_rule_name) |
2910 sources, excluded_sources, excluded_idl = ( | 2920 sources, excluded_sources, excluded_idl = ( |
2911 _AdjustSourcesAndConvertToFilterHierarchy(spec, options, | 2921 _AdjustSourcesAndConvertToFilterHierarchy(spec, options, |
2912 project_dir, sources, | 2922 project_dir, sources, |
2913 excluded_sources, | 2923 excluded_sources, |
2914 list_excluded)) | 2924 list_excluded)) |
2915 _AddActions(actions_to_add, spec, project.build_file) | 2925 _AddActions(actions_to_add, spec, project.build_file, None) |
2916 _AddCopies(actions_to_add, spec) | 2926 _AddCopies(actions_to_add, spec) |
2917 | 2927 |
2918 # NOTE: this stanza must appear after all actions have been decided. | 2928 # NOTE: this stanza must appear after all actions have been decided. |
2919 # Don't excluded sources with actions attached, or they won't run. | 2929 # Don't excluded sources with actions attached, or they won't run. |
2920 excluded_sources = _FilterActionsFromExcluded( | 2930 excluded_sources = _FilterActionsFromExcluded( |
2921 excluded_sources, actions_to_add) | 2931 excluded_sources, actions_to_add) |
2922 | 2932 |
2923 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) | 2933 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) |
2924 actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( | 2934 actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( |
2925 spec, actions_to_add) | 2935 spec, actions_to_add) |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3047 action_spec.extend( | 3057 action_spec.extend( |
3048 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3058 # TODO(jeanluc) 'Document' for all or just if as_sources? |
3049 [['FileType', 'Document'], | 3059 [['FileType', 'Document'], |
3050 ['Command', command], | 3060 ['Command', command], |
3051 ['Message', description], | 3061 ['Message', description], |
3052 ['Outputs', outputs] | 3062 ['Outputs', outputs] |
3053 ]) | 3063 ]) |
3054 if additional_inputs: | 3064 if additional_inputs: |
3055 action_spec.append(['AdditionalInputs', additional_inputs]) | 3065 action_spec.append(['AdditionalInputs', additional_inputs]) |
3056 actions_spec.append(action_spec) | 3066 actions_spec.append(action_spec) |
OLD | NEW |