Skip to content

Commit

Permalink
feat: add VCToolsVersion for msvs (#209)
Browse files Browse the repository at this point in the history
* 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.
```
  • Loading branch information
tr-takatsuka committed Oct 18, 2023
1 parent 98da389 commit 0e35ab8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
build-windows:
runs-on: windows-2019
runs-on: windows-latest
steps:
- name: Clone gyp-next
uses: actions/checkout@v3
Expand Down
4 changes: 3 additions & 1 deletion pylib/gyp/easy_xml_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def test_EasyXml_complex(self):
"<ConfigurationType>Application</ConfigurationType>"
"<CharacterSet>Unicode</CharacterSet>"
"<SpectreMitigation>SpectreLoadCF</SpectreMitigation>"
"<VCToolsVersion>14.36.32532</VCToolsVersion>"
"</PropertyGroup>"
"</Project>"
)
Expand All @@ -100,7 +101,8 @@ def test_EasyXml_complex(self):
},
["ConfigurationType", "Application"],
["CharacterSet", "Unicode"],
["SpectreMitigation", "SpectreLoadCF"]
["SpectreMitigation", "SpectreLoadCF"],
["VCToolsVersion", "14.36.32532"],
],
]
)
Expand Down
7 changes: 7 additions & 0 deletions pylib/gyp/generator/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3004,6 +3004,7 @@ def _GetMSBuildConfigurationDetails(spec, build_file):
msbuild_attributes = _GetMSBuildAttributes(spec, settings, build_file)
condition = _GetConfigurationCondition(name, settings, spec)
character_set = msbuild_attributes.get("CharacterSet")
vctools_version = msbuild_attributes.get("VCToolsVersion")
config_type = msbuild_attributes.get("ConfigurationType")
_AddConditionalProperty(properties, condition, "ConfigurationType", config_type)
spectre_mitigation = msbuild_attributes.get('SpectreMitigation')
Expand All @@ -3019,6 +3020,10 @@ def _GetMSBuildConfigurationDetails(spec, build_file):
_AddConditionalProperty(
properties, condition, "CharacterSet", character_set
)
if vctools_version and "msvs_enable_winrt" not in spec:
_AddConditionalProperty(
properties, condition, "VCToolsVersion", vctools_version
)
return _GetMSBuildPropertyGroup(spec, "Configuration", properties)


Expand Down Expand Up @@ -3100,6 +3105,8 @@ def _ConvertMSVSBuildAttributes(spec, config, build_file):
msbuild_attributes[a] = _ConvertMSVSConfigurationType(msvs_attributes[a])
elif a == "SpectreMitigation":
msbuild_attributes[a] = msvs_attributes[a]
elif a == "VCToolsVersion":
msbuild_attributes[a] = msvs_attributes[a]
else:
print("Warning: Do not know how to convert MSVS attribute " + a)
return msbuild_attributes
Expand Down

0 comments on commit 0e35ab8

Please sign in to comment.