Skip to content

Commit

Permalink
Add support for VS 2022 (#338)
Browse files Browse the repository at this point in the history
* Add support for VS 2022.

* build: Temporarily modify CI workflows.

* Make Tundra check for 64-bit install path.

* Oops, this isn't GMod Lua...

* Revert tundra push workflow change.
  • Loading branch information
RyanJGray authored Dec 20, 2022
1 parent 39588fd commit cf4f794
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
32 changes: 16 additions & 16 deletions scripts/tundra/ide/msvc-common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,10 @@ function msvc_generator:generate_project(project, all_projects)
p:write(' DefaultTargets="Build"')

-- This doesn't seem to change any behaviour, but this is the default
-- value when creating a makefile project from VS2013, VS2015, VS2017,
-- and VS2019 wizards.
if VERSION_YEAR == '2019' then
p:write(' ToolsVersion="16.0"')
elseif VERSION_YEAR == '2017' then
-- value when creating a makefile project from VS2013, VS2015, VS2017
-- wizards.
-- MS state that ToolsVersion is obsolete from VS2019 onwards.
if VERSION_YEAR == '2017' then
p:write(' ToolsVersion="15.0"')
elseif VERSION_YEAR == '2015' then
p:write(' ToolsVersion="14.0"')
Expand All @@ -430,13 +429,12 @@ function msvc_generator:generate_project(project, all_projects)
p:write('\t</ItemGroup>', LF)

p:write('\t<PropertyGroup Label="Globals">', LF)
if VERSION_YEAR == '2019' then
p:write('\t\t<VCProjectVersion>16.0</VCProjectVersion>', LF)
elseif VERSION_YEAR == '2017' then
-- Undocumented, appears to only exist in VS2017 projects.
if VERSION_YEAR == '2017' then
p:write('\t\t<VCProjectVersion>15.0</VCProjectVersion>', LF)
end
p:write('\t\t<ProjectGuid>{', project.Guid, '}</ProjectGuid>', LF)
if VERSION_YEAR == '2019' or VERSION_YEAR == '2017' then
if VERSION_YEAR == '2022' or VERSION_YEAR == '2019' or VERSION_YEAR == '2017' then
p:write('\t\t<Keyword>Win32Proj</Keyword>', LF)
else
p:write('\t\t<Keyword>MakefileProj</Keyword>', LF)
Expand All @@ -462,24 +460,26 @@ function msvc_generator:generate_project(project, all_projects)
for _, tuple in ipairs(self.config_tuples) do
p:write('\t<PropertyGroup Condition="\'$(Configuration)|$(Platform)\'==\'', tuple.MsvcName, '\'" Label="Configuration">', LF)
p:write('\t\t<ConfigurationType>Makefile</ConfigurationType>', LF)
p:write('\t\t<UseDebugLibraries>true</UseDebugLibraries>', LF) -- I have no idea what this setting affects
p:write('\t\t<UseDebugLibraries>true</UseDebugLibraries>', LF) -- This seems to be a master switch for multiple debug features
if VERSION_YEAR == '2012' then
p:write('\t\t<PlatformToolset>v110</PlatformToolset>', LF) -- I have no idea what this setting affects
p:write('\t\t<PlatformToolset>v110</PlatformToolset>', LF) -- Use MSVC compiler toolset version 11.0 (VS2012)
elseif VERSION_YEAR == '2013' then
p:write('\t\t<PlatformToolset>v120</PlatformToolset>', LF) -- I have no idea what this setting affects
p:write('\t\t<PlatformToolset>v120</PlatformToolset>', LF) -- Use MSVC compiler toolset version 12.0 (VS2013)
elseif VERSION_YEAR == '2015' then
p:write('\t\t<PlatformToolset>v140</PlatformToolset>', LF) -- I have no idea what this setting affects
p:write('\t\t<PlatformToolset>v140</PlatformToolset>', LF) -- Use MSVC compiler toolset version 14.0 (VS2015)
elseif VERSION_YEAR == '2017' then
p:write('\t\t<PlatformToolset>v141</PlatformToolset>', LF) -- I have no idea what this setting affects
p:write('\t\t<PlatformToolset>v141</PlatformToolset>', LF) -- Use MSVC compiler toolset version 14.1 (VS2017)
elseif VERSION_YEAR == '2019' then
p:write('\t\t<PlatformToolset>v142</PlatformToolset>', LF) -- I have no idea what this setting affects
p:write('\t\t<PlatformToolset>v142</PlatformToolset>', LF) -- Use MSVC compiler toolset version 14.2 (VS2019)
elseif VERSION_YEAR == '2022' then
p:write('\t\t<PlatformToolset>v143</PlatformToolset>', LF) -- Use MSVC compiler toolset version 14.3 (VS2022)
end
p:write('\t</PropertyGroup>', LF)
end

p:write('\t<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />', LF)

if VERSION_YEAR == '2019' or VERSION_YEAR == '2017' then
if VERSION_YEAR == '2022' or VERSION_YEAR == '2019' or VERSION_YEAR == '2017' then
for _, tuple in ipairs(self.config_tuples) do
p:write('\t<ImportGroup Label="PropertySheets" Condition="\'$(Configuration)|$(Platform)\'==\'', tuple.MsvcName, '\'">', LF)
p:write('\t\t<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists(\'$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props\')" Label="LocalAppDataPlatform" />', LF)
Expand Down
7 changes: 7 additions & 0 deletions scripts/tundra/ide/msvc143.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Microsoft Visual Studio 2022 Solution/Project file generation

module(..., package.seeall)

local msvc_common = require "tundra.ide.msvc-common"

msvc_common.setup("12.00", "2022")
8 changes: 8 additions & 0 deletions scripts/tundra/tools/msvc-vs2022.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

module(..., package.seeall)

local vscommon = require "tundra.tools.msvc-vscommon-next"

function apply(env, options)
vscommon.apply_msvc_visual_studio("2022", env, options)
end
5 changes: 5 additions & 0 deletions scripts/tundra/tools/msvc-vscommon-next.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ function apply_msvc_visual_studio(version, env, options)
local platform_type = options.PlatformType --default empty ({empty} | store | uwp)
local sdk_version = options.SdkVersion --default from vcvarsall.bat (otherwise request a specific version through this option)
local installation_path = options.InstallationPath or "C:\\Program Files (x86)\\Microsoft Visual Studio"
-- VS2022 is 64-bit and gets installed into Program Files.
if not options.InstallationPath and (version == "2022") then
installation_path = "C:\\Program Files\\Microsoft Visual Studio"
end

local vs_product = options.Product
local vcvarsall_bat = options.VCVarsPath --override the search strategy and use a specific 'vcvars' bat file
local search_set = {}
Expand Down

0 comments on commit cf4f794

Please sign in to comment.