Index: pylib/gyp/generator/msvs.py |
=================================================================== |
--- pylib/gyp/generator/msvs.py (revision 1747) |
+++ pylib/gyp/generator/msvs.py (working copy) |
@@ -1203,6 +1203,24 @@ |
return out_file, vc_tool, msbuild_tool |
+def _GetOutputTargetExt(spec): |
+ """Returns the extension for this target, including the dot |
+ |
+ If product_extension is specified, set target_extension to this to avoid |
+ MSB8012, returns None otherwise. Ignores any target_extension settings in |
+ the input files. |
+ |
+ Arguments: |
+ spec: The target dictionary containing the properties of the target. |
+ Returns: |
+ A string with the extension, or None |
+ """ |
+ target_extension = spec.get('product_extension') |
+ if target_extension: |
+ return '.' + target_extension |
+ return None |
+ |
+ |
def _GetDefines(config): |
"""Returns the list of preprocessor definitions for this configuation. |
@@ -2652,6 +2670,9 @@ |
out_file = msbuild_settings[msbuild_tool].get('OutputFile') |
if out_file: |
msbuild_attributes['TargetPath'] = _FixPath(out_file) |
+ target_ext = msbuild_settings[msbuild_tool].get('TargetExt') |
+ if target_ext: |
+ msbuild_attributes['TargetExt'] = target_ext |
return msbuild_attributes |
@@ -2687,6 +2708,9 @@ |
if attributes.get('TargetPath'): |
_AddConditionalProperty(properties, condition, 'TargetPath', |
attributes['TargetPath']) |
+ if attributes.get('TargetExt'): |
+ _AddConditionalProperty(properties, condition, 'TargetExt', |
+ attributes['TargetExt']) |
if new_paths: |
_AddConditionalProperty(properties, condition, 'ExecutablePath', |
@@ -2807,6 +2831,7 @@ |
libraries = _GetLibraries(spec) |
library_dirs = _GetLibraryDirs(configuration) |
out_file, _, msbuild_tool = _GetOutputFilePathAndTool(spec, msbuild=True) |
+ target_ext = _GetOutputTargetExt(spec) |
defines = _GetDefines(configuration) |
if converted: |
# Visual Studio 2010 has TR1 |
@@ -2844,6 +2869,9 @@ |
if out_file: |
_ToolAppend(msbuild_settings, msbuild_tool, 'OutputFile', out_file, |
only_if_unset=True) |
+ if target_ext: |
+ _ToolAppend(msbuild_settings, msbuild_tool, 'TargetExt', target_ext, |
+ only_if_unset=True) |
# Add defines. |
_ToolAppend(msbuild_settings, 'ClCompile', |
'PreprocessorDefinitions', defines) |