Skip to content

Commit d23d43f

Browse files
committed
src,lib: MSVS better handling of build configution & platform
1 parent 7961cf5 commit d23d43f

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

gyp/MSVS/MSVSVersion.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import os
88
import glob
9-
from typing import Dict
109
from gyp.MSVS.MSVSUtil import TryQueryRegistryValue
1110

1211
msvs_version_map = {
@@ -130,7 +129,7 @@ def SetupScript(self, target_arch):
130129
return script_data
131130

132131

133-
MSVS_VERSIONS = { # type: Dict[str, VisualStudioVersion]
132+
MSVS_VERSIONS = {
134133
'2019':
135134
VisualStudioVersion(
136135
short_name='2019',

gyp/generator/msvs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2565,7 +2565,7 @@ def _GenerateMSBuildRuleXmlFile(xml_path, msbuild_rules):
25652565

25662566
def _GetConfigurationAndPlatform(name, settings):
25672567
configuration = name.rsplit('_', 1)[0]
2568-
platform = settings.get('msvs_configuration_platform', 'Win32')
2568+
platform = settings.get('msvs_configuration_platform', 'x64')
25692569
return configuration, platform
25702570

25712571

testlib/TestGyp.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,12 @@ def configuration_dirname(self):
429429
else:
430430
return 'Default'
431431

432+
def configuration_platform(self):
433+
if self.configuration and '|' in self.configuration:
434+
return self.configuration.split('|')[1]
435+
else:
436+
return ''
437+
432438
def configuration_buildname(self):
433439
if self.configuration:
434440
return self.configuration
@@ -802,7 +808,10 @@ def FindVisualStudioInstallation():
802808
'-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
803809
]
804810
vswhere_json = subprocess.check_output(args1)
805-
top_vs_info = json.loads(vswhere_json)[0]
811+
vswhere_infos = json.loads(vswhere_json)
812+
if len(vswhere_infos) == 0:
813+
raise IOError("vswhere did not find any MSVS instances.")
814+
top_vs_info = vswhere_infos[0]
806815
if top_vs_info:
807816
inst_path = top_vs_info['installationPath']
808817
args2 = ['cmd.exe', '/d', '/c',
@@ -972,8 +981,6 @@ def build(self, gyp_file, target=None, rebuild=False, clean=False, **kw):
972981
from the specified gyp_file.
973982
"""
974983
if '15.0' in self.build_tool or 'Current' in self.build_tool:
975-
configuration = '/p:Configuration=' + (
976-
self.configuration or self.configuration_buildname())
977984
build = '/t'
978985
if target not in (None, self.ALL, self.DEFAULT):
979986
build += ':' + target
@@ -984,19 +991,21 @@ def build(self, gyp_file, target=None, rebuild=False, clean=False, **kw):
984991
elif ':' not in build:
985992
build += ':Build'
986993
arguments = kw.get('arguments', [])[:]
987-
arguments.extend([gyp_file.replace('.gyp', '.sln'),
988-
build, configuration])
994+
configuration_arg = '/p:Configuration=%s' % self.configuration_dirname()
995+
arguments.extend([gyp_file.replace('.gyp', '.sln'), build, configuration_arg])
996+
platform = self.configuration_platform()
997+
if platform:
998+
arguments.append('/p:Platform=%s' % platform)
989999
else:
990-
configuration = self.configuration_buildname()
1000+
configuration_arg = self.configuration_buildname()
9911001
if clean:
9921002
build = '/Clean'
9931003
elif rebuild:
9941004
build = '/Rebuild'
9951005
else:
9961006
build = '/Build'
9971007
arguments = kw.get('arguments', [])[:]
998-
arguments.extend([gyp_file.replace('.gyp', '.sln'),
999-
build, configuration])
1008+
arguments.extend([gyp_file.replace('.gyp', '.sln'), build, configuration_arg])
10001009
# Note: the Visual Studio generator doesn't add an explicit 'all'
10011010
# target, so we just treat it the same as the default.
10021011
if target not in (None, self.ALL, self.DEFAULT):

0 commit comments

Comments
 (0)