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