Skip to content

Commit

Permalink
Add MSVS 2022 support
Browse files Browse the repository at this point in the history
This is pretty similar to 1e42b90 (Add MSVS 2019 toolset support,
2020-01-10).
  • Loading branch information
vadz committed Apr 8, 2022
1 parent db20213 commit c18e96a
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 10 deletions.
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
v1.2.7 (2021-??-??)

New Features
------------

- Add MSVS 2022 support.

Enhancements
------------

Expand Down
7 changes: 4 additions & 3 deletions extras/vim/bkl.vim
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ syn keyword bklGlobalStat configuration
syn keyword bklGlobalStat setting
syn keyword bklGlobalProp toolsets
syn keyword bklGlobalProp configurations
syn match bklGlobalProp "\<\%(msvs\|vs\(2003\|2005\|2008\|2010\|2012\|2013\|2015\|2017\|2019\)\).generate-solution\ze *=" nextgroup=bklBoolRHS skipwhite
syn match bklGlobalProp "\<\%(msvs\|vs\)\%(2003\|2005\|2008\|2010\|2012\|2013\|2015\|2017\|2019\).solutionfile"
syn match bklGlobalProp "\<\%(msvs\|vs\(2003\|2005\|2008\|2010\|2012\|2013\|2015\|2017\|2019\|2022\)\).generate-solution\ze *=" nextgroup=bklBoolRHS skipwhite
syn match bklGlobalProp "\<\%(msvs\|vs\)\%(2003\|2005\|2008\|2010\|2012\|2013\|2015\|2017\|2019\|2022\).solutionfile"
syn keyword bklCommonProp gnu.makefile gnu-osx.makefile gnu-suncc.makefile

" Properties common to absolutely all targets.
Expand All @@ -48,9 +48,10 @@ syn keyword bklCommonProp vs2013.guid vs2013.projectfile contained
syn keyword bklCommonProp vs2015.guid vs2015.projectfile contained
syn keyword bklCommonProp vs2017.guid vs2017.projectfile contained
syn keyword bklCommonProp vs2019.guid vs2019.projectfile contained
syn keyword bklCommonProp vs2022.guid vs2022.projectfile contained
syn keyword bklCommonProp msvs.guid msvs.projectfile contained
syn keyword bklCommonProp vs.property-sheets contained
syn match bklCommonProp "\%(msvs\|vs\(2003\|2005\|2008\|2010\|2012\|2013\|2015\|2017\|2019\)\)\.option\(\.\w\+\)\{1,2}" contained
syn match bklCommonProp "\%(msvs\|vs\(2003\|2005\|2008\|2010\|2012\|2013\|2015\|2017\|2019\|2022\)\)\.option\(\.\w\+\)\{1,2}" contained

" Properties that can occur inside action targets only.
syn keyword bklActionProp commands inputs outputs contained
Expand Down
57 changes: 53 additions & 4 deletions src/bkl/plugins/vs201x.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, name, guid, projectfile, deps, configs, platforms, source_pos


class VS201xToolsetBase(VSToolsetBase):
"""Base class for VS2010, VS2012, VS2013, VS2015, VS2017 and VS2019 toolsets."""
"""Base class for VS2010, VS2012, VS2013, VS2015, VS2017, VS2019 and VS2022 toolsets."""

#: XML formatting class
XmlFormatter = VS201xXmlFormatter
Expand Down Expand Up @@ -852,13 +852,62 @@ class VS2019Toolset(VS201xToolsetBase):
Project = VS2019Project


class VS2022Solution(VS2010Solution):
format_version = "12.00"
human_version = "17"

def write_header(self, file):
super(VS2022Solution, self).write_header(file)
file.write("VisualStudioVersion = 17.0.31919.166\n")
file.write("MinimumVisualStudioVersion = 10.0.40219.1\n")


class VS2022Project(VS2010Project):
version = 17


class VS2022Toolset(VS201xToolsetBase):
"""
Visual Studio 2022.
Special properties
------------------
This toolset supports the same special properties that
:ref:`ref_toolset_vs2010`. The only difference is that they are prefixed
with ``vs2022.option.`` instead of ``vs2010.option.``, i.e. the nodes are:
- ``vs2022.option.Globals.*``
- ``vs2022.option.Configuration.*``
- ``vs2022.option.*`` (this is the unnamed ``PropertyGroup`` with
global settings such as ``TargetName``)
- ``vs2022.option.ClCompile.*``
- ``vs2022.option.ResourceCompile.*``
- ``vs2022.option.Link.*``
- ``vs2022.option.Lib.*``
- ``vs2022.option.Manifest.*``
"""

name = "vs2022"

version = 17
msvs_version = "2022"
proj_versions = [10, 11, 12, 14, 15, 16, 17]
platform_toolset = "v143"
tools_version = "17.0"
Solution = VS2022Solution
Project = VS2022Project


all_versions = {
10: VS2010Toolset,
11: VS2012Toolset,
12: VS2013Toolset,
14: VS2015Toolset,
15: VS2017Toolset,
16: VS2019Toolset,
17: VS2022Toolset,
}

class MSVSSolutionsBundle(object):
Expand All @@ -882,7 +931,7 @@ def __init__(self, toolset, module):
# version-independent solution file which will be opened by the
# latest installed version.
sln = module["%s.solutionfile" % toolset.name]
self.solutions[16] = VS2019Solution(toolset, module, sln)
self.solutions[17] = VS2022Solution(toolset, module, sln)

def add_project(self, prj):
for s in self.solutions.values():
Expand All @@ -905,7 +954,7 @@ class MSVSToolset(VS201xToolsetBase):
Any Microsoft Visual Studio version using MSBuild projects.
Files generated by this toolset can be used with any Microsoft Visual
Studio version from 2010 to 2019.
Studio version from 2010 to 2022.
Special properties
Expand Down Expand Up @@ -957,7 +1006,7 @@ class MSVSToolset(VS201xToolsetBase):
proj_versions = all_versions.keys()

# This tools version is supported by MSVS 2010 and still works just fine
# for MSVS 2019.
# for MSVS 2022.
tools_version = "4.0"

# We use a special multi-solution class, but just the same plain project
Expand Down
4 changes: 3 additions & 1 deletion tests/projects/hello_world/hello_world.bkl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
toolsets = gnu gnu-osx gnu-suncc vs2003 vs2005 vs2008 vs2010 vs2012 vs2013 vs2015 vs2017 vs2019;
toolsets = gnu gnu-osx gnu-suncc vs2003 vs2005 vs2008 vs2010 vs2012 vs2013 vs2015 vs2017 vs2019 vs2022;

vs2003.solutionfile = hello_world_vs2003.sln;
vs2005.solutionfile = hello_world_vs2005.sln;
Expand All @@ -9,6 +9,7 @@ vs2013.solutionfile = hello_world_vs2013.sln;
vs2015.solutionfile = hello_world_vs2015.sln;
vs2017.solutionfile = hello_world_vs2017.sln;
vs2019.solutionfile = hello_world_vs2019.sln;
vs2022.solutionfile = hello_world_vs2022.sln;

program hello {
archs = x86 x86_64;
Expand All @@ -24,4 +25,5 @@ program hello {
vs2015.projectfile = hello_vs2015.vcxproj;
vs2017.projectfile = hello_vs2017.vcxproj;
vs2019.projectfile = hello_vs2019.vcxproj;
vs2022.projectfile = hello_vs2022.vcxproj;
}
4 changes: 3 additions & 1 deletion tests/projects/hello_world/hello_world.model
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module {
variables {
toolsets = [gnu, gnu-osx, gnu-suncc, vs2003, vs2005, vs2008, vs2010, vs2012, vs2013, vs2015, vs2017, vs2019]
toolsets = [gnu, gnu-osx, gnu-suncc, vs2003, vs2005, vs2008, vs2010, vs2012, vs2013, vs2015, vs2017, vs2019, vs2022]
vs2003.solutionfile = @top_srcdir/hello_world_vs2003.sln
vs2005.solutionfile = @top_srcdir/hello_world_vs2005.sln
vs2008.solutionfile = @top_srcdir/hello_world_vs2008.sln
Expand All @@ -10,6 +10,7 @@ module {
vs2015.solutionfile = @top_srcdir/hello_world_vs2015.sln
vs2017.solutionfile = @top_srcdir/hello_world_vs2017.sln
vs2019.solutionfile = @top_srcdir/hello_world_vs2019.sln
vs2022.solutionfile = @top_srcdir/hello_world_vs2022.sln
}
targets {
program hello {
Expand All @@ -24,6 +25,7 @@ module {
vs2015.projectfile = @top_srcdir/hello_vs2015.vcxproj
vs2017.projectfile = @top_srcdir/hello_vs2017.vcxproj
vs2019.projectfile = @top_srcdir/hello_vs2019.vcxproj
vs2022.projectfile = @top_srcdir/hello_vs2022.vcxproj
sources {
file @top_srcdir/hello.c
}
Expand Down
1 change: 1 addition & 0 deletions tests/projects/msvs/single_project.bkl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ toolsets = msvs;

msvs2017.solutionfile = single_project_141.sln;
msvs2019.solutionfile = single_project_142.sln;
msvs2022.solutionfile = single_project_143.sln;

program single_project {
sources { single_project.cpp }
Expand Down
1 change: 1 addition & 0 deletions tests/projects/msvs/single_project.model
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module {
toolsets = [msvs]
msvs2017.solutionfile = @top_srcdir/single_project_141.sln
msvs2019.solutionfile = @top_srcdir/single_project_142.sln
msvs2022.solutionfile = @top_srcdir/single_project_143.sln
}
targets {
program single_project {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_model/properties/set_toolsets_bad.model
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ERROR:
properties/set_toolsets_bad.bkl:1:11: variable "toolsets" (list of toolsets): expression "nonexistent" is not a valid toolset value: must be one of "gnu", "gnu-osx", "gnu-suncc", "msvs", "vs2003", "vs2005", "vs2008", "vs2010", "vs2012", "vs2013", "vs2015", "vs2017", "vs2019"
properties/set_toolsets_bad.bkl:1:11: variable "toolsets" (list of toolsets): expression "nonexistent" is not a valid toolset value: must be one of "gnu", "gnu-osx", "gnu-suncc", "msvs", "vs2003", "vs2005", "vs2008", "vs2010", "vs2012", "vs2013", "vs2015", "vs2017", "vs2019", "vs2022"

0 comments on commit c18e96a

Please sign in to comment.