Skip to content

Commit 0e35ab8

Browse files
authored
feat: add VCToolsVersion for msvs (#209)
* Add the ability to specify the 'MSVC toolset version' <VCToolsVersion> for the VisualStudio platform. Usage example for binding.gyp ``` 'targets': [ { 'configurations': { 'Debug': { "msvs_configuration_attributes": { "VCToolsVersion": "14.36.32532", ``` * chore: update build-windows runs-on to windows-latest extract from comments by PR #209:add VCToolsVersion for msvs ``` The Node.js Windows integration / build-windows workflow runs on windows-2019 which from what I know uses VS2019. However, after this landed in Node.js, it no longer supports building on VS2019 and requires VS2022. Luckily for us, fix should be as simple as changing the line I referenced in a workflow file to windows-2022 or even simpler to windows-latest. ```
1 parent 98da389 commit 0e35ab8

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

.github/workflows/nodejs-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
build-windows:
12-
runs-on: windows-2019
12+
runs-on: windows-latest
1313
steps:
1414
- name: Clone gyp-next
1515
uses: actions/checkout@v3

pylib/gyp/easy_xml_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def test_EasyXml_complex(self):
7777
"<ConfigurationType>Application</ConfigurationType>"
7878
"<CharacterSet>Unicode</CharacterSet>"
7979
"<SpectreMitigation>SpectreLoadCF</SpectreMitigation>"
80+
"<VCToolsVersion>14.36.32532</VCToolsVersion>"
8081
"</PropertyGroup>"
8182
"</Project>"
8283
)
@@ -100,7 +101,8 @@ def test_EasyXml_complex(self):
100101
},
101102
["ConfigurationType", "Application"],
102103
["CharacterSet", "Unicode"],
103-
["SpectreMitigation", "SpectreLoadCF"]
104+
["SpectreMitigation", "SpectreLoadCF"],
105+
["VCToolsVersion", "14.36.32532"],
104106
],
105107
]
106108
)

pylib/gyp/generator/msvs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3004,6 +3004,7 @@ def _GetMSBuildConfigurationDetails(spec, build_file):
30043004
msbuild_attributes = _GetMSBuildAttributes(spec, settings, build_file)
30053005
condition = _GetConfigurationCondition(name, settings, spec)
30063006
character_set = msbuild_attributes.get("CharacterSet")
3007+
vctools_version = msbuild_attributes.get("VCToolsVersion")
30073008
config_type = msbuild_attributes.get("ConfigurationType")
30083009
_AddConditionalProperty(properties, condition, "ConfigurationType", config_type)
30093010
spectre_mitigation = msbuild_attributes.get('SpectreMitigation')
@@ -3019,6 +3020,10 @@ def _GetMSBuildConfigurationDetails(spec, build_file):
30193020
_AddConditionalProperty(
30203021
properties, condition, "CharacterSet", character_set
30213022
)
3023+
if vctools_version and "msvs_enable_winrt" not in spec:
3024+
_AddConditionalProperty(
3025+
properties, condition, "VCToolsVersion", vctools_version
3026+
)
30223027
return _GetMSBuildPropertyGroup(spec, "Configuration", properties)
30233028

30243029

@@ -3100,6 +3105,8 @@ def _ConvertMSVSBuildAttributes(spec, config, build_file):
31003105
msbuild_attributes[a] = _ConvertMSVSConfigurationType(msvs_attributes[a])
31013106
elif a == "SpectreMitigation":
31023107
msbuild_attributes[a] = msvs_attributes[a]
3108+
elif a == "VCToolsVersion":
3109+
msbuild_attributes[a] = msvs_attributes[a]
31033110
else:
31043111
print("Warning: Do not know how to convert MSVS attribute " + a)
31053112
return msbuild_attributes

0 commit comments

Comments
 (0)