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 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 guid = default_config.get('msvs_guid') | 826 guid = default_config.get('msvs_guid') |
827 if guid: | 827 if guid: |
828 if VALID_MSVS_GUID_CHARS.match(guid) is None: | 828 if VALID_MSVS_GUID_CHARS.match(guid) is None: |
829 raise ValueError('Invalid MSVS guid: "%s". Must match regex: "%s".' % | 829 raise ValueError('Invalid MSVS guid: "%s". Must match regex: "%s".' % |
830 (guid, VALID_MSVS_GUID_CHARS.pattern)) | 830 (guid, VALID_MSVS_GUID_CHARS.pattern)) |
831 guid = '{%s}' % guid | 831 guid = '{%s}' % guid |
832 guid = guid or MSVSNew.MakeGuid(proj_path) | 832 guid = guid or MSVSNew.MakeGuid(proj_path) |
833 return guid | 833 return guid |
834 | 834 |
835 | 835 |
| 836 def _GetMsbuildToolsetOfProject(proj_path, spec): |
| 837 """Get the platform toolset for the project. |
| 838 |
| 839 Arguments: |
| 840 proj_path: Path of the vcproj or vcxproj file to generate. |
| 841 spec: The target dictionary containing the properties of the target. |
| 842 Returns: |
| 843 the platform toolset string or None. |
| 844 """ |
| 845 # Pluck out the default configuration. |
| 846 default_config = _GetDefaultConfiguration(spec) |
| 847 return default_config.get('msbuild_toolset') |
| 848 |
| 849 |
836 def _GenerateProject(project, options, version, generator_flags): | 850 def _GenerateProject(project, options, version, generator_flags): |
837 """Generates a vcproj file. | 851 """Generates a vcproj file. |
838 | 852 |
839 Arguments: | 853 Arguments: |
840 project: the MSVSProject object. | 854 project: the MSVSProject object. |
841 options: global generator options. | 855 options: global generator options. |
842 version: the MSVSVersion object. | 856 version: the MSVSVersion object. |
843 generator_flags: dict of generator-specific flags. | 857 generator_flags: dict of generator-specific flags. |
844 """ | 858 """ |
845 default_config = _GetDefaultConfiguration(project.spec) | 859 default_config = _GetDefaultConfiguration(project.spec) |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 build_file = gyp.common.BuildFile(qualified_target) | 1645 build_file = gyp.common.BuildFile(qualified_target) |
1632 # Create object for this project. | 1646 # Create object for this project. |
1633 obj = MSVSNew.MSVSProject( | 1647 obj = MSVSNew.MSVSProject( |
1634 _FixPath(proj_path), | 1648 _FixPath(proj_path), |
1635 name=spec['target_name'], | 1649 name=spec['target_name'], |
1636 guid=guid, | 1650 guid=guid, |
1637 spec=spec, | 1651 spec=spec, |
1638 build_file=build_file, | 1652 build_file=build_file, |
1639 config_platform_overrides=overrides, | 1653 config_platform_overrides=overrides, |
1640 fixpath_prefix=fixpath_prefix) | 1654 fixpath_prefix=fixpath_prefix) |
| 1655 # Set project toolset if any (MS build only) |
| 1656 if msvs_version.UsesVcxproj(): |
| 1657 obj.set_msbuild_toolset(_GetMsbuildToolsetOfProject(proj_path, spec)) |
1641 projects[qualified_target] = obj | 1658 projects[qualified_target] = obj |
1642 # Set all the dependencies | 1659 # Set all the dependencies |
1643 for project in projects.values(): | 1660 for project in projects.values(): |
1644 deps = project.spec.get('dependencies', []) | 1661 deps = project.spec.get('dependencies', []) |
1645 deps = [projects[d] for d in deps] | 1662 deps = [projects[d] for d in deps] |
1646 project.set_dependencies(deps) | 1663 project.set_dependencies(deps) |
1647 return projects | 1664 return projects |
1648 | 1665 |
1649 | 1666 |
1650 def CalculateVariables(default_variables, params): | 1667 def CalculateVariables(default_variables, params): |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2394 condition = _GetConfigurationCondition(name, settings) | 2411 condition = _GetConfigurationCondition(name, settings) |
2395 character_set = msbuild_attributes.get('CharacterSet') | 2412 character_set = msbuild_attributes.get('CharacterSet') |
2396 _AddConditionalProperty(properties, condition, 'ConfigurationType', | 2413 _AddConditionalProperty(properties, condition, 'ConfigurationType', |
2397 msbuild_attributes['ConfigurationType']) | 2414 msbuild_attributes['ConfigurationType']) |
2398 if character_set: | 2415 if character_set: |
2399 _AddConditionalProperty(properties, condition, 'CharacterSet', | 2416 _AddConditionalProperty(properties, condition, 'CharacterSet', |
2400 character_set) | 2417 character_set) |
2401 return _GetMSBuildPropertyGroup(spec, 'Configuration', properties) | 2418 return _GetMSBuildPropertyGroup(spec, 'Configuration', properties) |
2402 | 2419 |
2403 | 2420 |
| 2421 def _GetMSBuildLocalProperties(msbuild_toolset): |
| 2422 # Currently the only local property we support is PlatformToolset |
| 2423 properties = {} |
| 2424 if msbuild_toolset: |
| 2425 properties = [ |
| 2426 ['PropertyGroup', {'Label': 'Locals'}, |
| 2427 ['PlatformToolset', msbuild_toolset], |
| 2428 ] |
| 2429 ] |
| 2430 return properties |
| 2431 |
| 2432 |
2404 def _GetMSBuildPropertySheets(configurations): | 2433 def _GetMSBuildPropertySheets(configurations): |
2405 user_props = r'$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props' | 2434 user_props = r'$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props' |
2406 return [ | 2435 return [ |
2407 ['ImportGroup', | 2436 ['ImportGroup', |
2408 {'Label': 'PropertySheets'}, | 2437 {'Label': 'PropertySheets'}, |
2409 ['Import', | 2438 ['Import', |
2410 {'Project': user_props, | 2439 {'Project': user_props, |
2411 'Condition': "exists('%s')" % user_props, | 2440 'Condition': "exists('%s')" % user_props, |
2412 'Label': 'LocalAppDataPlatform' | 2441 'Label': 'LocalAppDataPlatform' |
2413 } | 2442 } |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2827 'Project', | 2856 'Project', |
2828 {'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003', | 2857 {'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003', |
2829 'ToolsVersion': version.ProjectVersion(), | 2858 'ToolsVersion': version.ProjectVersion(), |
2830 'DefaultTargets': 'Build' | 2859 'DefaultTargets': 'Build' |
2831 }] | 2860 }] |
2832 | 2861 |
2833 content += _GetMSBuildProjectConfigurations(configurations) | 2862 content += _GetMSBuildProjectConfigurations(configurations) |
2834 content += _GetMSBuildGlobalProperties(spec, project.guid, project_file_name) | 2863 content += _GetMSBuildGlobalProperties(spec, project.guid, project_file_name) |
2835 content += import_default_section | 2864 content += import_default_section |
2836 content += _GetMSBuildConfigurationDetails(spec, project.build_file) | 2865 content += _GetMSBuildConfigurationDetails(spec, project.build_file) |
| 2866 content += _GetMSBuildLocalProperties(project.msbuild_toolset) |
2837 content += import_cpp_props_section | 2867 content += import_cpp_props_section |
2838 content += _GetMSBuildExtensions(props_files_of_rules) | 2868 content += _GetMSBuildExtensions(props_files_of_rules) |
2839 content += _GetMSBuildPropertySheets(configurations) | 2869 content += _GetMSBuildPropertySheets(configurations) |
2840 content += macro_section | 2870 content += macro_section |
2841 content += _GetMSBuildConfigurationGlobalProperties(spec, configurations, | 2871 content += _GetMSBuildConfigurationGlobalProperties(spec, configurations, |
2842 project.build_file) | 2872 project.build_file) |
2843 content += _GetMSBuildToolSettingsSections(spec, configurations) | 2873 content += _GetMSBuildToolSettingsSections(spec, configurations) |
2844 content += _GetMSBuildSources( | 2874 content += _GetMSBuildSources( |
2845 spec, sources, exclusions, extension_to_rule_name, actions_spec, | 2875 spec, sources, exclusions, extension_to_rule_name, actions_spec, |
2846 sources_handled_by_action, list_excluded) | 2876 sources_handled_by_action, list_excluded) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2926 action_spec.extend( | 2956 action_spec.extend( |
2927 # TODO(jeanluc) 'Document' for all or just if as_sources? | 2957 # TODO(jeanluc) 'Document' for all or just if as_sources? |
2928 [['FileType', 'Document'], | 2958 [['FileType', 'Document'], |
2929 ['Command', command], | 2959 ['Command', command], |
2930 ['Message', description], | 2960 ['Message', description], |
2931 ['Outputs', outputs] | 2961 ['Outputs', outputs] |
2932 ]) | 2962 ]) |
2933 if additional_inputs: | 2963 if additional_inputs: |
2934 action_spec.append(['AdditionalInputs', additional_inputs]) | 2964 action_spec.append(['AdditionalInputs', additional_inputs]) |
2935 actions_spec.append(action_spec) | 2965 actions_spec.append(action_spec) |
OLD | NEW |