| Index: pylib/gyp/msvs_emulation.py
|
| ===================================================================
|
| --- pylib/gyp/msvs_emulation.py (revision 1533)
|
| +++ pylib/gyp/msvs_emulation.py (working copy)
|
| @@ -152,6 +152,7 @@
|
| ('msvs_disabled_warnings', list),
|
| ('msvs_precompiled_header', str),
|
| ('msvs_precompiled_source', str),
|
| + ('msvs_configuration_platform', str),
|
| ('msvs_target_platform', str),
|
| ]
|
| configs = spec['configurations']
|
| @@ -165,8 +166,7 @@
|
| def GetVSMacroEnv(self, base_to_build=None, config=None):
|
| """Get a dict of variables mapping internal VS macro names to their gyp
|
| equivalents."""
|
| - target_platform = self.GetTargetPlatform(config)
|
| - target_platform = {'x86': 'Win32'}.get(target_platform, target_platform)
|
| + target_platform = 'Win32' if self.GetArch(config) == 'x86' else 'x64'
|
| replacements = {
|
| '$(VSInstallDir)': self.vs_version.Path(),
|
| '$(VCInstallDir)': os.path.join(self.vs_version.Path(), 'VC') + '\\',
|
| @@ -215,29 +215,40 @@
|
| return self.parent._GetAndMunge(self.field, self.base_path + [name],
|
| default=default, prefix=prefix, append=self.append, map=map)
|
|
|
| - def GetTargetPlatform(self, config):
|
| - target_platform = self.msvs_target_platform.get(config, '')
|
| - if not target_platform:
|
| - target_platform = 'Win32'
|
| - return {'Win32': 'x86'}.get(target_platform, target_platform)
|
| + def GetArch(self, config):
|
| + """Get architecture based on msvs_configuration_platform and
|
| + msvs_target_platform. Returns either 'x86' or 'x64'."""
|
| + configuration_platform = self.msvs_configuration_platform.get(config, '')
|
| + platform = self.msvs_target_platform.get(config, '')
|
| + if not platform: # If no specific override, use the configuration's.
|
| + platform = configuration_platform
|
| + # Map from platform to architecture.
|
| + return {'Win32': 'x86', 'x64': 'x64'}.get(platform, 'x86')
|
|
|
| - def _RealConfig(self, config):
|
| - target_platform = self.GetTargetPlatform(config)
|
| - if target_platform == 'x64' and not config.endswith('_x64'):
|
| + def _TargetConfig(self, config):
|
| + """Returns the target-specific configuration."""
|
| + # There's two levels of architecture/platform specification in VS. The
|
| + # first level is globally for the configuration (this is what we consider
|
| + # "the" config at the gyp level, which will be something like 'Debug' or
|
| + # 'Release_x64'), and a second target-specific configuration, which is an
|
| + # override for the global one. |config| is remapped here to take into
|
| + # account the local target-specific overrides to the global configuration.
|
| + arch = self.GetArch(config)
|
| + if arch == 'x64' and not config.endswith('_x64'):
|
| config += '_x64'
|
| + if arch == 'x86' and config.endswith('_x64'):
|
| + config = config.rsplit('_', 1)[0]
|
| return config
|
|
|
| def _Setting(self, path, config,
|
| default=None, prefix='', append=None, map=None):
|
| """_GetAndMunge for msvs_settings."""
|
| - config = self._RealConfig(config)
|
| return self._GetAndMunge(
|
| self.msvs_settings[config], path, default, prefix, append, map)
|
|
|
| def _ConfigAttrib(self, path, config,
|
| default=None, prefix='', append=None, map=None):
|
| """_GetAndMunge for msvs_configuration_attributes."""
|
| - config = self._RealConfig(config)
|
| return self._GetAndMunge(
|
| self.msvs_configuration_attributes[config],
|
| path, default, prefix, append, map)
|
| @@ -245,7 +256,7 @@
|
| def AdjustIncludeDirs(self, include_dirs, config):
|
| """Updates include_dirs to expand VS specific paths, and adds the system
|
| include dirs used for platform SDK and similar."""
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| includes = include_dirs + self.msvs_system_include_dirs[config]
|
| includes.extend(self._Setting(
|
| ('VCCLCompilerTool', 'AdditionalIncludeDirectories'), config, default=[]))
|
| @@ -254,7 +265,7 @@
|
| def GetComputedDefines(self, config):
|
| """Returns the set of defines that are injected to the defines list based
|
| on other VS settings."""
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| defines = []
|
| if self._ConfigAttrib(['CharacterSet'], config) == '1':
|
| defines.extend(('_UNICODE', 'UNICODE'))
|
| @@ -267,7 +278,7 @@
|
| def GetOutputName(self, config, expand_special):
|
| """Gets the explicitly overridden output name for a target or returns None
|
| if it's not overridden."""
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| type = self.spec['type']
|
| root = 'VCLibrarianTool' if type == 'static_library' else 'VCLinkerTool'
|
| # TODO(scottmg): Handle OutputDirectory without OutputFile.
|
| @@ -280,7 +291,7 @@
|
| def GetPDBName(self, config, expand_special):
|
| """Gets the explicitly overridden pdb name for a target or returns None
|
| if it's not overridden."""
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| output_file = self._Setting(('VCLinkerTool', 'ProgramDatabaseFile'), config)
|
| if output_file:
|
| output_file = expand_special(self.ConvertVSMacros(
|
| @@ -289,7 +300,7 @@
|
|
|
| def GetCflags(self, config):
|
| """Returns the flags that need to be added to .c and .cc compilations."""
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| cflags = []
|
| cflags.extend(['/wd' + w for w in self.msvs_disabled_warnings[config]])
|
| cl = self._GetWrapper(self, self.msvs_settings[config],
|
| @@ -321,13 +332,13 @@
|
| def GetPrecompiledHeader(self, config, gyp_to_build_path):
|
| """Returns an object that handles the generation of precompiled header
|
| build steps."""
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| return _PchHelper(self, config, gyp_to_build_path)
|
|
|
| def _GetPchFlags(self, config, extension):
|
| """Get the flags to be added to the cflags for precompiled header support.
|
| """
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| # The PCH is only built once by a particular source file. Usage of PCH must
|
| # only be for the same language (i.e. C vs. C++), so only include the pch
|
| # flags when the language matches.
|
| @@ -340,18 +351,18 @@
|
|
|
| def GetCflagsC(self, config):
|
| """Returns the flags that need to be added to .c compilations."""
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| return self._GetPchFlags(config, '.c')
|
|
|
| def GetCflagsCC(self, config):
|
| """Returns the flags that need to be added to .cc compilations."""
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| return ['/TP'] + self._GetPchFlags(config, '.cc')
|
|
|
| def _GetAdditionalLibraryDirectories(self, root, config, gyp_to_build_path):
|
| """Get and normalize the list of paths in AdditionalLibraryDirectories
|
| setting."""
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| libpaths = self._Setting((root, 'AdditionalLibraryDirectories'),
|
| config, default=[])
|
| libpaths = [os.path.normpath(
|
| @@ -361,7 +372,7 @@
|
|
|
| def GetLibFlags(self, config, gyp_to_build_path):
|
| """Returns the flags that need to be added to lib commands."""
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| libflags = []
|
| lib = self._GetWrapper(self, self.msvs_settings[config],
|
| 'VCLibrarianTool', append=libflags)
|
| @@ -385,7 +396,7 @@
|
| manifest_base_name, is_executable):
|
| """Returns the flags that need to be added to link commands, and the
|
| manifest files."""
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| ldflags = []
|
| ld = self._GetWrapper(self, self.msvs_settings[config],
|
| 'VCLinkerTool', append=ldflags)
|
| @@ -481,14 +492,14 @@
|
| def IsUseLibraryDependencyInputs(self, config):
|
| """Returns whether the target should be linked via Use Library Dependency
|
| Inputs (using component .objs of a given .lib)."""
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| uldi = self._Setting(('VCLinkerTool', 'UseLibraryDependencyInputs'), config)
|
| return uldi == 'true'
|
|
|
| def GetRcflags(self, config, gyp_to_ninja_path):
|
| """Returns the flags that need to be added to invocations of the resource
|
| compiler."""
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| rcflags = []
|
| rc = self._GetWrapper(self, self.msvs_settings[config],
|
| 'VCResourceCompilerTool', append=rcflags)
|
| @@ -525,18 +536,27 @@
|
| return int(rule.get('msvs_cygwin_shell',
|
| self.spec.get('msvs_cygwin_shell', 1))) != 0
|
|
|
| - def HasExplicitIdlRules(self, spec):
|
| - """Determine if there's an explicit rule for idl files. When there isn't we
|
| - need to generate implicit rules to build MIDL .idl files."""
|
| + def _HasExplicitRuleForExtension(self, spec, extension):
|
| + """Determine if there's an explicit rule for a particular extension."""
|
| for rule in spec.get('rules', []):
|
| - if rule['extension'] == 'idl' and int(rule.get('msvs_external_rule', 0)):
|
| + if rule['extension'] == extension:
|
| return True
|
| return False
|
|
|
| + def HasExplicitIdlRules(self, spec):
|
| + """Determine if there's an explicit rule for idl files. When there isn't we
|
| + need to generate implicit rules to build MIDL .idl files."""
|
| + return self._HasExplicitRuleForExtension(spec, 'idl')
|
| +
|
| + def HasExplicitAsmRules(self, spec):
|
| + """Determine if there's an explicit rule for asm files. When there isn't we
|
| + need to generate implicit rules to assemble .asm files."""
|
| + return self._HasExplicitRuleForExtension(spec, 'asm')
|
| +
|
| def GetIdlBuildData(self, source, config):
|
| """Determine the implicit outputs for an idl file. Returns output
|
| directory, outputs, and variables and flags that are required."""
|
| - config = self._RealConfig(config)
|
| + config = self._TargetConfig(config)
|
| midl_get = self._GetWrapper(self, self.msvs_settings[config], 'VCMIDLTool')
|
| def midl(name, default=None):
|
| return self.ConvertVSMacros(midl_get(name, default=default),
|
|
|