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 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 if product_extension: | 1196 if product_extension: |
1197 suffix = '.' + product_extension | 1197 suffix = '.' + product_extension |
1198 elif msbuild: | 1198 elif msbuild: |
1199 suffix = '$(TargetExt)' | 1199 suffix = '$(TargetExt)' |
1200 prefix = spec.get('product_prefix', '') | 1200 prefix = spec.get('product_prefix', '') |
1201 product_name = spec.get('product_name', '$(ProjectName)') | 1201 product_name = spec.get('product_name', '$(ProjectName)') |
1202 out_file = ntpath.join(out_dir, prefix + product_name + suffix) | 1202 out_file = ntpath.join(out_dir, prefix + product_name + suffix) |
1203 return out_file, vc_tool, msbuild_tool | 1203 return out_file, vc_tool, msbuild_tool |
1204 | 1204 |
1205 | 1205 |
| 1206 def _GetOutputTargetExt(spec): |
| 1207 """Returns the extension for this target, including the dot |
| 1208 |
| 1209 If product_extension is specified, set target_extension to this to avoid |
| 1210 MSB8012, returns None otherwise. Ignores any target_extension settings in |
| 1211 the input files. |
| 1212 |
| 1213 Arguments: |
| 1214 spec: The target dictionary containing the properties of the target. |
| 1215 Returns: |
| 1216 A string with the extension, or None |
| 1217 """ |
| 1218 target_extension = spec.get('product_extension') |
| 1219 if target_extension: |
| 1220 return '.' + target_extension |
| 1221 return None |
| 1222 |
| 1223 |
1206 def _GetDefines(config): | 1224 def _GetDefines(config): |
1207 """Returns the list of preprocessor definitions for this configuation. | 1225 """Returns the list of preprocessor definitions for this configuation. |
1208 | 1226 |
1209 Arguments: | 1227 Arguments: |
1210 config: The dictionary that defines the special processing to be done | 1228 config: The dictionary that defines the special processing to be done |
1211 for this configuration. | 1229 for this configuration. |
1212 Returns: | 1230 Returns: |
1213 The list of preprocessor definitions. | 1231 The list of preprocessor definitions. |
1214 """ | 1232 """ |
1215 defines = [] | 1233 defines = [] |
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2645 'shared_library': 'Link', | 2663 'shared_library': 'Link', |
2646 'loadable_module': 'Link', | 2664 'loadable_module': 'Link', |
2647 'static_library': 'Lib', | 2665 'static_library': 'Lib', |
2648 } | 2666 } |
2649 msbuild_tool = msbuild_tool_map.get(spec['type']) | 2667 msbuild_tool = msbuild_tool_map.get(spec['type']) |
2650 if msbuild_tool: | 2668 if msbuild_tool: |
2651 msbuild_settings = config['finalized_msbuild_settings'] | 2669 msbuild_settings = config['finalized_msbuild_settings'] |
2652 out_file = msbuild_settings[msbuild_tool].get('OutputFile') | 2670 out_file = msbuild_settings[msbuild_tool].get('OutputFile') |
2653 if out_file: | 2671 if out_file: |
2654 msbuild_attributes['TargetPath'] = _FixPath(out_file) | 2672 msbuild_attributes['TargetPath'] = _FixPath(out_file) |
| 2673 target_ext = msbuild_settings[msbuild_tool].get('TargetExt') |
| 2674 if target_ext: |
| 2675 msbuild_attributes['TargetExt'] = target_ext |
2655 | 2676 |
2656 return msbuild_attributes | 2677 return msbuild_attributes |
2657 | 2678 |
2658 | 2679 |
2659 def _GetMSBuildConfigurationGlobalProperties(spec, configurations, build_file): | 2680 def _GetMSBuildConfigurationGlobalProperties(spec, configurations, build_file): |
2660 # TODO(jeanluc) We could optimize out the following and do it only if | 2681 # TODO(jeanluc) We could optimize out the following and do it only if |
2661 # there are actions. | 2682 # there are actions. |
2662 # TODO(jeanluc) Handle the equivalent of setting 'CYGWIN=nontsec'. | 2683 # TODO(jeanluc) Handle the equivalent of setting 'CYGWIN=nontsec'. |
2663 new_paths = [] | 2684 new_paths = [] |
2664 cygwin_dirs = spec.get('msvs_cygwin_dirs', ['.'])[0] | 2685 cygwin_dirs = spec.get('msvs_cygwin_dirs', ['.'])[0] |
(...skipping 15 matching lines...) Expand all Loading... |
2680 _AddConditionalProperty(properties, condition, 'IntDir', | 2701 _AddConditionalProperty(properties, condition, 'IntDir', |
2681 attributes['IntermediateDirectory']) | 2702 attributes['IntermediateDirectory']) |
2682 _AddConditionalProperty(properties, condition, 'OutDir', | 2703 _AddConditionalProperty(properties, condition, 'OutDir', |
2683 attributes['OutputDirectory']) | 2704 attributes['OutputDirectory']) |
2684 _AddConditionalProperty(properties, condition, 'TargetName', | 2705 _AddConditionalProperty(properties, condition, 'TargetName', |
2685 attributes['TargetName']) | 2706 attributes['TargetName']) |
2686 | 2707 |
2687 if attributes.get('TargetPath'): | 2708 if attributes.get('TargetPath'): |
2688 _AddConditionalProperty(properties, condition, 'TargetPath', | 2709 _AddConditionalProperty(properties, condition, 'TargetPath', |
2689 attributes['TargetPath']) | 2710 attributes['TargetPath']) |
| 2711 if attributes.get('TargetExt'): |
| 2712 _AddConditionalProperty(properties, condition, 'TargetExt', |
| 2713 attributes['TargetExt']) |
2690 | 2714 |
2691 if new_paths: | 2715 if new_paths: |
2692 _AddConditionalProperty(properties, condition, 'ExecutablePath', | 2716 _AddConditionalProperty(properties, condition, 'ExecutablePath', |
2693 new_paths) | 2717 new_paths) |
2694 tool_settings = msbuild_settings.get('', {}) | 2718 tool_settings = msbuild_settings.get('', {}) |
2695 for name, value in sorted(tool_settings.iteritems()): | 2719 for name, value in sorted(tool_settings.iteritems()): |
2696 formatted_value = _GetValueFormattedForMSBuild('', name, value) | 2720 formatted_value = _GetValueFormattedForMSBuild('', name, value) |
2697 _AddConditionalProperty(properties, condition, name, formatted_value) | 2721 _AddConditionalProperty(properties, condition, name, formatted_value) |
2698 return _GetMSBuildPropertyGroup(spec, None, properties) | 2722 return _GetMSBuildPropertyGroup(spec, None, properties) |
2699 | 2723 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2800 msbuild_settings = configuration['msbuild_settings'] | 2824 msbuild_settings = configuration['msbuild_settings'] |
2801 MSVSSettings.ValidateMSBuildSettings(msbuild_settings) | 2825 MSVSSettings.ValidateMSBuildSettings(msbuild_settings) |
2802 else: | 2826 else: |
2803 converted = True | 2827 converted = True |
2804 msvs_settings = configuration.get('msvs_settings', {}) | 2828 msvs_settings = configuration.get('msvs_settings', {}) |
2805 msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings) | 2829 msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings) |
2806 include_dirs, resource_include_dirs = _GetIncludeDirs(configuration) | 2830 include_dirs, resource_include_dirs = _GetIncludeDirs(configuration) |
2807 libraries = _GetLibraries(spec) | 2831 libraries = _GetLibraries(spec) |
2808 library_dirs = _GetLibraryDirs(configuration) | 2832 library_dirs = _GetLibraryDirs(configuration) |
2809 out_file, _, msbuild_tool = _GetOutputFilePathAndTool(spec, msbuild=True) | 2833 out_file, _, msbuild_tool = _GetOutputFilePathAndTool(spec, msbuild=True) |
| 2834 target_ext = _GetOutputTargetExt(spec) |
2810 defines = _GetDefines(configuration) | 2835 defines = _GetDefines(configuration) |
2811 if converted: | 2836 if converted: |
2812 # Visual Studio 2010 has TR1 | 2837 # Visual Studio 2010 has TR1 |
2813 defines = [d for d in defines if d != '_HAS_TR1=0'] | 2838 defines = [d for d in defines if d != '_HAS_TR1=0'] |
2814 # Warn of ignored settings | 2839 # Warn of ignored settings |
2815 ignored_settings = ['msvs_prebuild', 'msvs_postbuild', 'msvs_tool_files'] | 2840 ignored_settings = ['msvs_prebuild', 'msvs_postbuild', 'msvs_tool_files'] |
2816 for ignored_setting in ignored_settings: | 2841 for ignored_setting in ignored_settings: |
2817 value = configuration.get(ignored_setting) | 2842 value = configuration.get(ignored_setting) |
2818 if value: | 2843 if value: |
2819 print ('Warning: The automatic conversion to MSBuild does not handle ' | 2844 print ('Warning: The automatic conversion to MSBuild does not handle ' |
(...skipping 17 matching lines...) Expand all Loading... |
2837 'AdditionalIncludeDirectories', resource_include_dirs) | 2862 'AdditionalIncludeDirectories', resource_include_dirs) |
2838 # Add in libraries, note that even for empty libraries, we want this | 2863 # Add in libraries, note that even for empty libraries, we want this |
2839 # set, to prevent inheriting default libraries from the enviroment. | 2864 # set, to prevent inheriting default libraries from the enviroment. |
2840 _ToolSetOrAppend(msbuild_settings, 'Link', 'AdditionalDependencies', | 2865 _ToolSetOrAppend(msbuild_settings, 'Link', 'AdditionalDependencies', |
2841 libraries) | 2866 libraries) |
2842 _ToolAppend(msbuild_settings, 'Link', 'AdditionalLibraryDirectories', | 2867 _ToolAppend(msbuild_settings, 'Link', 'AdditionalLibraryDirectories', |
2843 library_dirs) | 2868 library_dirs) |
2844 if out_file: | 2869 if out_file: |
2845 _ToolAppend(msbuild_settings, msbuild_tool, 'OutputFile', out_file, | 2870 _ToolAppend(msbuild_settings, msbuild_tool, 'OutputFile', out_file, |
2846 only_if_unset=True) | 2871 only_if_unset=True) |
| 2872 if target_ext: |
| 2873 _ToolAppend(msbuild_settings, msbuild_tool, 'TargetExt', target_ext, |
| 2874 only_if_unset=True) |
2847 # Add defines. | 2875 # Add defines. |
2848 _ToolAppend(msbuild_settings, 'ClCompile', | 2876 _ToolAppend(msbuild_settings, 'ClCompile', |
2849 'PreprocessorDefinitions', defines) | 2877 'PreprocessorDefinitions', defines) |
2850 _ToolAppend(msbuild_settings, 'ResourceCompile', | 2878 _ToolAppend(msbuild_settings, 'ResourceCompile', |
2851 'PreprocessorDefinitions', defines) | 2879 'PreprocessorDefinitions', defines) |
2852 # Add disabled warnings. | 2880 # Add disabled warnings. |
2853 _ToolAppend(msbuild_settings, 'ClCompile', | 2881 _ToolAppend(msbuild_settings, 'ClCompile', |
2854 'DisableSpecificWarnings', disabled_warnings) | 2882 'DisableSpecificWarnings', disabled_warnings) |
2855 # Turn on precompiled headers if appropriate. | 2883 # Turn on precompiled headers if appropriate. |
2856 if precompiled_header: | 2884 if precompiled_header: |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3227 action_spec.extend( | 3255 action_spec.extend( |
3228 # TODO(jeanluc) 'Document' for all or just if as_sources? | 3256 # TODO(jeanluc) 'Document' for all or just if as_sources? |
3229 [['FileType', 'Document'], | 3257 [['FileType', 'Document'], |
3230 ['Command', command], | 3258 ['Command', command], |
3231 ['Message', description], | 3259 ['Message', description], |
3232 ['Outputs', outputs] | 3260 ['Outputs', outputs] |
3233 ]) | 3261 ]) |
3234 if additional_inputs: | 3262 if additional_inputs: |
3235 action_spec.append(['AdditionalInputs', additional_inputs]) | 3263 action_spec.append(['AdditionalInputs', additional_inputs]) |
3236 actions_spec.append(action_spec) | 3264 actions_spec.append(action_spec) |
OLD | NEW |