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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
871 vcproj_dir = os.path.dirname(project.path) | 871 vcproj_dir = os.path.dirname(project.path) |
872 if vcproj_dir and not os.path.exists(vcproj_dir): | 872 if vcproj_dir and not os.path.exists(vcproj_dir): |
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 relative_path_of_vcproj_file = \ |
882 relative_path_of_gyp_file = gyp.common.RelativePath(gyp_path, project_dir) | 882 gyp.common.RelativePath(project.path, project_dir) |
883 | 883 |
884 config_type = _GetMSVSConfigurationType(spec, project.build_file) | 884 config_type = _GetMSVSConfigurationType(spec, project.build_file) |
885 for config_name, config in spec['configurations'].iteritems(): | 885 for config_name, config in spec['configurations'].iteritems(): |
886 _AddConfigurationToMSVSProject(p, spec, config_type, config_name, config) | 886 _AddConfigurationToMSVSProject(p, spec, config_type, config_name, config) |
887 | 887 |
888 # Prepare list of sources and excluded sources. | 888 # Prepare list of sources and excluded sources. |
889 gyp_file = os.path.split(project.build_file)[1] | 889 gyp_file = os.path.split(project.build_file)[1] |
890 sources, excluded_sources = _PrepareListOfSources(spec, gyp_file) | 890 sources, excluded_sources = _PrepareListOfSources(spec, gyp_file) |
891 | 891 |
892 # Add rules. | 892 # Add rules. |
893 actions_to_add = {} | 893 actions_to_add = {} |
894 _GenerateRulesForMSVS(p, project_dir, options, spec, | 894 _GenerateRulesForMSVS(p, project_dir, options, spec, |
895 sources, excluded_sources, | 895 sources, excluded_sources, |
896 actions_to_add) | 896 actions_to_add) |
897 list_excluded = generator_flags.get('msvs_list_excluded_files', True) | 897 list_excluded = generator_flags.get('msvs_list_excluded_files', True) |
898 sources, excluded_sources, excluded_idl = ( | 898 sources, excluded_sources, excluded_idl = ( |
899 _AdjustSourcesAndConvertToFilterHierarchy( | 899 _AdjustSourcesAndConvertToFilterHierarchy( |
900 spec, options, project_dir, sources, excluded_sources, list_excluded)) | 900 spec, options, project_dir, sources, excluded_sources, list_excluded)) |
901 | 901 |
902 # Add in files. | 902 # Add in files. |
903 missing_sources = _VerifySourcesExist(sources, project_dir) | 903 missing_sources = _VerifySourcesExist(sources, project_dir) |
904 p.AddFiles(sources) | 904 p.AddFiles(sources) |
905 | 905 |
906 _AddToolFilesToMSVS(p, spec) | 906 _AddToolFilesToMSVS(p, spec) |
907 _HandlePreCompiledHeaders(p, sources, spec) | 907 _HandlePreCompiledHeaders(p, sources, spec) |
908 _AddActions(actions_to_add, spec, relative_path_of_gyp_file) | 908 _AddActions(actions_to_add, spec, relative_path_of_vcproj_file) |
909 _AddCopies(actions_to_add, spec) | 909 _AddCopies(actions_to_add, spec) |
910 _WriteMSVSUserFile(project.path, version, spec) | 910 _WriteMSVSUserFile(project.path, version, spec) |
911 | 911 |
912 # NOTE: this stanza must appear after all actions have been decided. | 912 # NOTE: this stanza must appear after all actions have been decided. |
913 # Don't excluded sources with actions attached, or they won't run. | 913 # Don't excluded sources with actions attached, or they won't run. |
914 excluded_sources = _FilterActionsFromExcluded( | 914 excluded_sources = _FilterActionsFromExcluded( |
915 excluded_sources, actions_to_add) | 915 excluded_sources, actions_to_add) |
916 _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl, | 916 _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl, |
917 list_excluded) | 917 list_excluded) |
918 _AddAccumulatedActionsToMSVS(p, spec, actions_to_add) | 918 _AddAccumulatedActionsToMSVS(p, spec, actions_to_add) |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1434 {'UsePrecompiledHeader': '0', | 1434 {'UsePrecompiledHeader': '0', |
1435 'ForcedIncludeFiles': '$(NOINHERIT)'}) | 1435 'ForcedIncludeFiles': '$(NOINHERIT)'}) |
1436 p.AddFileConfig(_FixPath(source), | 1436 p.AddFileConfig(_FixPath(source), |
1437 _ConfigFullName(config_name, config), | 1437 _ConfigFullName(config_name, config), |
1438 {}, tools=[tool]) | 1438 {}, tools=[tool]) |
1439 # Do nothing if there was no precompiled source. | 1439 # Do nothing if there was no precompiled source. |
1440 if extensions_excluded_from_precompile: | 1440 if extensions_excluded_from_precompile: |
1441 DisableForSourceTree(sources) | 1441 DisableForSourceTree(sources) |
1442 | 1442 |
1443 | 1443 |
1444 def _AddActions(actions_to_add, spec, relative_path_of_gyp_file): | 1444 def _AddActions(actions_to_add, spec, relative_path_of_project_file): |
1445 # Add actions. | 1445 # Add actions. |
1446 actions = spec.get('actions', []) | 1446 actions = spec.get('actions', []) |
1447 for a in actions: | 1447 for a in actions: |
1448 cmd = _BuildCommandLineForRule(spec, a, has_input_path=False) | 1448 cmd = _BuildCommandLineForRule(spec, a, has_input_path=False) |
1449 # Attach actions to the gyp file if nothing else is there. | 1449 # We mark the project file as a dependency of the action so that |
1450 inputs = a.get('inputs') or [relative_path_of_gyp_file] | 1450 # when the action's command changes, the action will get re-run |
1451 # even if no other input files change. However, this will re-run | |
1452 # unchanged actions unnecessarily when the project file changes. | |
1453 # TODO(mseaborn): Detect changes at a finer granularity. | |
1454 inputs = a.get('inputs') + [relative_path_of_project_file] | |
1451 # Add the action. | 1455 # Add the action. |
1452 _AddActionStep(actions_to_add, | 1456 _AddActionStep(actions_to_add, |
1453 inputs=inputs, | 1457 inputs=inputs, |
1454 outputs=a.get('outputs', []), | 1458 outputs=a.get('outputs', []), |
1455 description=a.get('message', a['action_name']), | 1459 description=a.get('message', a['action_name']), |
1456 command=cmd) | 1460 command=cmd) |
1457 | 1461 |
1458 | 1462 |
1459 def _WriteMSVSUserFile(project_path, version, spec): | 1463 def _WriteMSVSUserFile(project_path, version, spec): |
1460 # Add run_as and test targets. | 1464 # Add run_as and test targets. |
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2885 | 2889 |
2886 | 2890 |
2887 def _GenerateMSBuildProject(project, options, version, generator_flags): | 2891 def _GenerateMSBuildProject(project, options, version, generator_flags): |
2888 spec = project.spec | 2892 spec = project.spec |
2889 configurations = spec['configurations'] | 2893 configurations = spec['configurations'] |
2890 project_dir, project_file_name = os.path.split(project.path) | 2894 project_dir, project_file_name = os.path.split(project.path) |
2891 msbuildproj_dir = os.path.dirname(project.path) | 2895 msbuildproj_dir = os.path.dirname(project.path) |
2892 if msbuildproj_dir and not os.path.exists(msbuildproj_dir): | 2896 if msbuildproj_dir and not os.path.exists(msbuildproj_dir): |
2893 os.makedirs(msbuildproj_dir) | 2897 os.makedirs(msbuildproj_dir) |
2894 # Prepare list of sources and excluded sources. | 2898 # 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] | 2899 gyp_file = os.path.split(project.build_file)[1] |
2899 sources, excluded_sources = _PrepareListOfSources(spec, gyp_file) | 2900 sources, excluded_sources = _PrepareListOfSources(spec, gyp_file) |
2900 # Add rules. | 2901 # Add rules. |
2901 actions_to_add = {} | 2902 actions_to_add = {} |
2902 props_files_of_rules = set() | 2903 props_files_of_rules = set() |
2903 targets_files_of_rules = set() | 2904 targets_files_of_rules = set() |
2904 extension_to_rule_name = {} | 2905 extension_to_rule_name = {} |
2905 list_excluded = generator_flags.get('msvs_list_excluded_files', True) | 2906 list_excluded = generator_flags.get('msvs_list_excluded_files', True) |
2906 _GenerateRulesForMSBuild(project_dir, options, spec, | 2907 _GenerateRulesForMSBuild(project_dir, options, spec, |
2907 sources, excluded_sources, | 2908 sources, excluded_sources, |
2908 props_files_of_rules, targets_files_of_rules, | 2909 props_files_of_rules, targets_files_of_rules, |
2909 actions_to_add, extension_to_rule_name) | 2910 actions_to_add, extension_to_rule_name) |
2910 sources, excluded_sources, excluded_idl = ( | 2911 sources, excluded_sources, excluded_idl = ( |
2911 _AdjustSourcesAndConvertToFilterHierarchy(spec, options, | 2912 _AdjustSourcesAndConvertToFilterHierarchy(spec, options, |
2912 project_dir, sources, | 2913 project_dir, sources, |
2913 excluded_sources, | 2914 excluded_sources, |
2914 list_excluded)) | 2915 list_excluded)) |
2915 _AddActions(actions_to_add, spec, project.build_file) | 2916 _AddActions(actions_to_add, spec, project.path) |
jeanluc1
2012/05/02 23:13:52
I'm not sure if there's a reason why MSVS uses rel
Mark Seaborn
2012/05/02 23:38:32
I have no idea. I don't have MSVS 2010 installed
jeanluc1
2012/05/02 23:50:24
If the 2010 trybot is happy, that's sufficient for
| |
2916 _AddCopies(actions_to_add, spec) | 2917 _AddCopies(actions_to_add, spec) |
2917 | 2918 |
2918 # NOTE: this stanza must appear after all actions have been decided. | 2919 # NOTE: this stanza must appear after all actions have been decided. |
2919 # Don't excluded sources with actions attached, or they won't run. | 2920 # Don't excluded sources with actions attached, or they won't run. |
2920 excluded_sources = _FilterActionsFromExcluded( | 2921 excluded_sources = _FilterActionsFromExcluded( |
2921 excluded_sources, actions_to_add) | 2922 excluded_sources, actions_to_add) |
2922 | 2923 |
2923 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) | 2924 exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) |
2924 actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( | 2925 actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( |
2925 spec, actions_to_add) | 2926 spec, actions_to_add) |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3047 action_spec.extend( | 3048 action_spec.extend( |
3048 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3049 # TODO(jeanluc) 'Document' for all or just if as_sources? |
3049 [['FileType', 'Document'], | 3050 [['FileType', 'Document'], |
3050 ['Command', command], | 3051 ['Command', command], |
3051 ['Message', description], | 3052 ['Message', description], |
3052 ['Outputs', outputs] | 3053 ['Outputs', outputs] |
3053 ]) | 3054 ]) |
3054 if additional_inputs: | 3055 if additional_inputs: |
3055 action_spec.append(['AdditionalInputs', additional_inputs]) | 3056 action_spec.append(['AdditionalInputs', additional_inputs]) |
3056 actions_spec.append(action_spec) | 3057 actions_spec.append(action_spec) |
OLD | NEW |