Chromium Code Reviews| Index: pylib/gyp/msvs_emulation.py |
| diff --git a/pylib/gyp/msvs_emulation.py b/pylib/gyp/msvs_emulation.py |
| index f0b814d36ec199062fb3ed53c451117c98242275..b5a377ef5a94c8687767f6d5349046c5b5d62541 100644 |
| --- a/pylib/gyp/msvs_emulation.py |
| +++ b/pylib/gyp/msvs_emulation.py |
| @@ -185,6 +185,14 @@ class MsvsSettings(object): |
| msvs_settings field). They largely correpond to the VS2008 IDE DOM. This |
| class helps map those settings to command line options.""" |
| + # A dictionary of default target extensions by type. |
|
scottmg
2014/10/03 22:19:59
this is very similar to MSVSUtil.py, could it reus
chrisha
2014/10/06 13:40:49
Indeed it is. Removed it from here, and reused the
|
| + _DEFAULT_EXTENSIONS_BY_TYPE = { |
| + 'loadable_module': 'dll', |
| + 'shared_library': 'dll', |
| + 'static_library': 'lib', |
| + 'executable': 'exe', |
| + } |
| + |
| def __init__(self, spec, generator_flags): |
| self.spec = spec |
| self.vs_version = GetVSVersion(generator_flags) |
| @@ -220,6 +228,17 @@ class MsvsSettings(object): |
| if unsupported: |
| raise Exception('\n'.join(unsupported)) |
| + def GetExtension(self): |
| + """Returns the extension for the target, with no leading dot. |
| + |
| + Uses 'product_extension' if specified, otherwise uses MSVS defaults based on |
| + the target type. |
| + """ |
| + ext = self.spec.get('product_extension', None) |
| + if ext: |
| + return ext |
| + return self._DEFAULT_EXTENSIONS_BY_TYPE.get(self.spec['type'], '') |
| + |
| def GetVSMacroEnv(self, base_to_build=None, config=None): |
| """Get a dict of variables mapping internal VS macro names to their gyp |
| equivalents.""" |
| @@ -227,16 +246,22 @@ class MsvsSettings(object): |
| target_name = self.spec.get('product_prefix', '') + \ |
| self.spec.get('product_name', self.spec['target_name']) |
| target_dir = base_to_build + '\\' if base_to_build else '' |
| + target_ext = '.' + self.GetExtension() |
| + target_file_name = target_name + target_ext |
| + |
| replacements = { |
| - '$(OutDir)\\': target_dir, |
| - '$(TargetDir)\\': target_dir, |
| - '$(IntDir)': '$!INTERMEDIATE_DIR', |
| - '$(InputPath)': '${source}', |
| '$(InputName)': '${root}', |
| - '$(ProjectName)': self.spec['target_name'], |
| - '$(TargetName)': target_name, |
| + '$(InputPath)': '${source}', |
| + '$(IntDir)': '$!INTERMEDIATE_DIR', |
| + '$(OutDir)\\': target_dir, |
| '$(PlatformName)': target_platform, |
| '$(ProjectDir)\\': '', |
| + '$(ProjectName)': self.spec['target_name'], |
| + '$(TargetDir)\\': target_dir, |
| + '$(TargetExt)': target_ext, |
| + '$(TargetFileName)': target_file_name, |
| + '$(TargetName)': target_name, |
| + '$(TargetPath)': os.path.join(target_dir, target_file_name), |
| } |
| replacements.update(GetGlobalVSMacroEnv(self.vs_version)) |
| return replacements |