Skip to content

Commit

Permalink
Merge branch 'release/1.43' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
czoido committed Dec 3, 2021
2 parents d936610 + ab4b12a commit 2e54d45
Show file tree
Hide file tree
Showing 22 changed files with 84 additions and 115 deletions.
6 changes: 3 additions & 3 deletions conan/tools/_compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ def _cppstd_msvc(visual_version, cppstd):
v20 = None
v23 = None

if Version(visual_version) >= "19.0":
if Version(visual_version) >= "190":
v14 = "c++14"
v17 = "c++latest"
if Version(visual_version) >= "19.1":
if Version(visual_version) >= "191":
v17 = "c++17"
v20 = "c++latest"
if Version(visual_version) >= "19.3":
if Version(visual_version) >= "193":
v20 = "c++20"
v23 = "c++latest"

Expand Down
14 changes: 6 additions & 8 deletions conan/tools/cmake/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,14 +542,12 @@ def _get_toolset(self, generator):
return IntelCC(self._conanfile).ms_toolset
elif compiler == "msvc":
compiler_version = str(settings.compiler.version)
version_components = compiler_version.split(".")
if len(version_components) >= 2: # there is a 19.XX
minor = version_components[1]
if len(minor) >= 2 and "X" not in minor: # It is full one(19.28), not generic 19.2X
# The equivalent of compiler 19.26 is toolset 14.26
return "version=14.{}".format(minor)
else:
return "v14{}".format(minor[0])
compiler_update = str(settings.compiler.update)
if compiler_update != "None": # It is full one(19.28), not generic 19.2X
# The equivalent of compiler 19.26 is toolset 14.26
return "version=14.{}{}".format(compiler_version[-1], compiler_update)
else:
return "v14{}".format(compiler_version[-1])
elif compiler == "clang":
if generator and "Visual" in generator:
if "Visual Studio 16" in generator:
Expand Down
31 changes: 5 additions & 26 deletions conan/tools/microsoft/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,6 @@
from conans.util.files import save, load


def vs_ide_version(conanfile):
compiler = conanfile.settings.get_safe("compiler")
compiler_version = (conanfile.settings.get_safe("compiler.base.version") or
conanfile.settings.get_safe("compiler.version"))
if compiler == "msvc":
toolset_override = conanfile.conf["tools.microsoft.msbuild:vs_version"]
if toolset_override:
visual_version = toolset_override
else:
version = compiler_version[:4] # Remove the latest version number 19.1X if existing
_visuals = {'19.0': '14', # TODO: This is common to CMake, refactor
'19.1': '15',
'19.2': '16',
'19.3': '17'}
visual_version = _visuals[version]
else:
visual_version = compiler_version
return visual_version


class MSBuildToolchain(object):

filename = "conantoolchain.props"
Expand Down Expand Up @@ -70,12 +50,11 @@ def _msvs_toolset(conanfile):
compiler = settings.get_safe("compiler")
compiler_version = settings.get_safe("compiler.version")
if compiler == "msvc":
version = compiler_version[:4] # Remove the latest version number 19.1X if existing
toolsets = {'19.0': 'v140', # TODO: This is common to CMake, refactor
'19.1': 'v141',
'19.2': 'v142',
"19.3": 'v143'}
return toolsets[version]
toolsets = {'190': 'v140', # TODO: This is common to CMake, refactor
'191': 'v141',
'192': 'v142',
"193": 'v143'}
return toolsets[compiler_version]
if compiler == "intel":
compiler_version = compiler_version if "." in compiler_version else \
"%s.0" % compiler_version
Expand Down
22 changes: 11 additions & 11 deletions conan/tools/microsoft/visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
CONAN_VCVARS_FILE = "conanvcvars.bat"


def msvc_version_to_vs_ide_version(version):
_visuals = {'190': '14',
'191': '15',
'192': '16',
'193': '17'}
return _visuals[str(version)]


class VCVars:
def __init__(self, conanfile):
self._conanfile = conanfile
Expand Down Expand Up @@ -54,12 +62,7 @@ def vs_ide_version(conanfile):
if toolset_override:
visual_version = toolset_override
else:
version = compiler_version[:4] # Remove the latest version number 19.1X if existing
_visuals = {'19.0': '14', # TODO: This is common to CMake, refactor
'19.1': '15',
'19.2': '16',
'19.3': '17'}
visual_version = _visuals[version]
visual_version = msvc_version_to_vs_ide_version(compiler_version)
else:
visual_version = compiler_version
return visual_version
Expand Down Expand Up @@ -166,9 +169,6 @@ def _vcvars_vers(conanfile, compiler, vs_version):
assert compiler == "msvc"
# Code similar to CMakeToolchain toolset one
compiler_version = str(conanfile.settings.compiler.version)
version_components = compiler_version.split(".")
assert len(version_components) >= 2 # there is a 19.XX
minor = version_components[1]
# The equivalent of compiler 19.26 is toolset 14.26
vcvars_ver = "14.{}".format(minor[0])
# The equivalent of compiler 192 is toolset 14.2
vcvars_ver = "14.{}".format(compiler_version[-1])
return vcvars_ver
6 changes: 3 additions & 3 deletions conans/client/build/cppstd_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ def _cppstd_msvc(visual_version, cppstd):
v20 = None
v23 = None

if Version(visual_version) >= "19.0":
if Version(visual_version) >= "190":
v14 = "c++14"
v17 = "c++latest"
if Version(visual_version) >= "19.1":
if Version(visual_version) >= "191":
v17 = "c++17"
v20 = "c++latest"
if Version(visual_version) >= "19.3":
if Version(visual_version) >= "193":
v20 = "c++20"
v23 = "c++latest"

Expand Down
6 changes: 2 additions & 4 deletions conans/client/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@
llvm, ClangCL, v143]
cppstd: [None, 14, 17, 20, 23]
msvc:
version: ["19.0",
"19.1X", "19.10", "19.11", "19.12", "19.13", "19.14", "19.15", "19.16",
"19.2X", "19.20", "19.21", "19.22", "19.23", "19.24", "19.25", "19.26", "19.27", "19.28", "19.29",
"19.3X", "19.30"]
version: [190, 191, 192, 193]
update: [None, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
runtime: [static, dynamic]
runtime_type: [Debug, Release]
cppstd: [14, 17, 20, 23]
Expand Down
6 changes: 2 additions & 4 deletions conans/client/conf/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,7 @@ def _get_profile_compiler_version(compiler, version, output):
elif compiler == "intel" and (int(major) < 19 or (int(major) == 19 and int(minor) == 0)):
return major
elif compiler == "msvc":
# by default, drop the last digit of the minor (19.30 -> 19.3)
if len(minor) == 2:
version = version[:-1]
return major
return version


Expand Down Expand Up @@ -233,7 +231,7 @@ def _detect_compiler_version(result, output, profile_path):
version = Version(version)
if version == "17":
compiler = "msvc"
version = "19.3"
version = "193"

result.append(("compiler", compiler))
result.append(("compiler.version", _get_profile_compiler_version(compiler, version, output)))
Expand Down
6 changes: 2 additions & 4 deletions conans/client/migrations_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2908,10 +2908,8 @@
llvm, ClangCL, v143]
cppstd: [None, 14, 17, 20, 23]
msvc:
version: ["19.0",
"19.1X", "19.10", "19.11", "19.12", "19.13", "19.14", "19.15", "19.16",
"19.2X", "19.20", "19.21", "19.22", "19.23", "19.24", "19.25", "19.26", "19.27", "19.28", "19.29",
"19.3X", "19.30"]
version: [190, 191, 192, 193]
update: [None, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
runtime: [static, dynamic]
runtime_type: [Debug, Release]
cppstd: [14, 17, 20, 23]
Expand Down
9 changes: 3 additions & 6 deletions conans/model/info.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os

from conan.tools.microsoft.visual import msvc_version_to_vs_ide_version
from conans.client.build.cppstd_flags import cppstd_default
from conans.client.tools.win import MSVS_DEFAULT_TOOLSETS_INVERSE
from conans.errors import ConanException
Expand Down Expand Up @@ -587,12 +588,8 @@ def msvc_compatible(self):
runtime_type = compatible.settings.compiler.runtime_type

compatible.settings.compiler = "Visual Studio"
version = str(version)[:4]
_visuals = {'19.0': '14',
'19.1': '15',
'19.2': '16',
'19.3': '17'}
compatible.settings.compiler.version = _visuals[version]
visual_version = msvc_version_to_vs_ide_version(version)
compatible.settings.compiler.version = visual_version
runtime = "MT" if runtime == "static" else "MD"
if runtime_type == "Debug":
runtime = "{}d".format(runtime)
Expand Down
10 changes: 5 additions & 5 deletions conans/test/functional/toolchains/cmake/test_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ def _run_app(self, build_type, bin_folder=False, msg="App", dyld_path=None):
class WinTest(Base):
@parameterized.expand([("Visual Studio", "Debug", "MTd", "15", "14", "x86", "v140", True),
("Visual Studio", "Release", "MD", "15", "17", "x86_64", "", False),
("msvc", "Debug", "static", "19.1X", "14", "x86", None, True),
("msvc", "Release", "dynamic", "19.1X", "17", "x86_64", None, False)]
("msvc", "Debug", "static", "191", "14", "x86", None, True),
("msvc", "Release", "dynamic", "191", "17", "x86_64", None, False)]
)
def test_toolchain_win(self, compiler, build_type, runtime, version, cppstd, arch, toolset,
shared):
Expand Down Expand Up @@ -243,7 +243,7 @@ def _verify_out(marker=">>"):
if compiler == "msvc":
visual_version = version
else:
visual_version = "19.0" if toolset == "v140" else "19.1"
visual_version = "190" if toolset == "v140" else "191"
check_exe_run(self.client.out, "main", "msvc", visual_version, "Release", arch, cppstd,
{"MYVAR": "MYVAR_VALUE",
"MYVAR_CONFIG": "MYVAR_RELEASE",
Expand Down Expand Up @@ -447,8 +447,8 @@ def _verify_out(marker=">>"):

@pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows")
@pytest.mark.parametrize("version, vs_version",
[("19.0", "15"),
("19.1X", "15")])
[("190", "15"),
("191", "15")])
def test_msvc_vs_versiontoolset(version, vs_version):
settings = {"compiler": "msvc",
"compiler.version": version,
Expand Down
18 changes: 9 additions & 9 deletions conans/test/functional/toolchains/cmake/test_cmake_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@


@pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows")
@pytest.mark.parametrize("compiler, version, runtime",
[("msvc", "19.2X", "dynamic"),
("msvc", "19.26", "static"),
("msvc", "19.28", "static")])
def test_cmake_toolchain_win_toolset(compiler, version, runtime):
@pytest.mark.parametrize("compiler, version, update, runtime",
[("msvc", "192", None, "dynamic"),
("msvc", "192", "6", "static"),
("msvc", "192", "8", "static")])
def test_cmake_toolchain_win_toolset(compiler, version, update, runtime):
client = TestClient(path_with_spaces=False)
settings = {"compiler": compiler,
"compiler.version": version,
"compiler.update": update,
"compiler.cppstd": "17",
"compiler.runtime": runtime,
"build_type": "Release",
Expand All @@ -34,11 +35,10 @@ def test_cmake_toolchain_win_toolset(compiler, version, runtime):
client.save({"conanfile.py": conanfile})
client.run("install . {}".format(settings))
toolchain = client.load("conan_toolchain.cmake")
if "X" not in version: # Fullversion
minor = version.split(".")[1]
value = "version=14.{}".format(minor)
if update is not None: # Fullversion
value = "version=14.{}{}".format(version[-1], update)
else:
value = "v142"
value = "v14{}".format(version[-1])
assert 'set(CMAKE_GENERATOR_TOOLSET "{}" CACHE STRING "" FORCE)'.format(value) in toolchain


Expand Down
6 changes: 3 additions & 3 deletions conans/test/functional/toolchains/cmake/test_ninja.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_locally_build_msvc_toolset(client):
[settings]
os=Windows
compiler=msvc
compiler.version=19.0
compiler.version=190
compiler.runtime=dynamic
compiler.cppstd=14
build_type=Release
Expand All @@ -144,7 +144,7 @@ def test_locally_build_msvc_toolset(client):
client.run_command("myapp.exe")

# Checking that compiler is indeed version 19.0, not 19.1-default of VS15
check_exe_run(client.out, ["main", "hello"], "msvc", "19.0", "Release", "x86_64", cppstd="14")
check_exe_run(client.out, ["main", "hello"], "msvc", "190", "Release", "x86_64", cppstd="14")
check_vs_runtime("myapp.exe", client, msvc_version, "Release", architecture="amd64")
check_vs_runtime("mylibrary.lib", client, msvc_version, "Release", architecture="amd64")

Expand Down Expand Up @@ -203,7 +203,7 @@ def test_ninja_conf():
[settings]
os=Windows
compiler=msvc
compiler.version=19.1X
compiler.version=191
compiler.runtime=dynamic
compiler.cppstd=14
build_type=Release
Expand Down
16 changes: 8 additions & 8 deletions conans/test/functional/toolchains/microsoft/test_msbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,13 @@
@pytest.mark.tool_visual_studio(version='15')
@pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows")
def test_msvc_runtime_flag_vs2017():
check_msvc_runtime_flag("15", "19.1X")
check_msvc_runtime_flag("15", "191")


@pytest.mark.tool_visual_studio(version='17')
@pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows")
def test_msvc_runtime_flag_vs2022():
check_msvc_runtime_flag("17", "19.3X")
check_msvc_runtime_flag("17", "193")


def check_msvc_runtime_flag(vs_version, msvc_version):
Expand Down Expand Up @@ -342,10 +342,10 @@ def generate(self):
assert "MSVC FLAG=MD!!" in client.out


vs_versions = [{"vs_version": "15", "msvc_version": "19.1X", "ide_year": "2017", "toolset": "v141"}]
vs_versions = [{"vs_version": "15", "msvc_version": "191", "ide_year": "2017", "toolset": "v141"}]

if "17" in tools_locations['visual_studio'] and not tools_locations['visual_studio']['17'].get('disabled', False):
vs_versions.append({"vs_version": "17", "msvc_version": "19.3X", "ide_year": "2022", "toolset": "v143"})
vs_versions.append({"vs_version": "17", "msvc_version": "193", "ide_year": "2022", "toolset": "v143"})


@parameterized_class(vs_versions)
Expand Down Expand Up @@ -422,8 +422,8 @@ def _run_app(client, arch, build_type, shared=None):
client.run_command(command_str)

@parameterized.expand([("Visual Studio", "15", "MT", "17"),
("msvc", "19.1X", "static", "17"),
("msvc", "19.0", "static", "14")]
("msvc", "191", "static", "17"),
("msvc", "190", "static", "14")]
)
@pytest.mark.tool_cmake
def test_toolchain_win_vs2017(self, compiler, version, runtime, cppstd):
Expand All @@ -433,7 +433,7 @@ def test_toolchain_win_vs2017(self, compiler, version, runtime, cppstd):
self.check_toolchain_win(compiler, version, runtime, cppstd)

@parameterized.expand([("Visual Studio", "17", "MT", "17"),
("msvc", "19.3", "static", "17")]
("msvc", "193", "static", "17")]
)
def test_toolchain_win_vs2022(self, compiler, version, runtime, cppstd):
if self.vs_version != "17":
Expand Down Expand Up @@ -526,7 +526,7 @@ def test_toolchain_win_debug(self):
self.assertIn("[vcvarsall.bat] Environment initialized for: 'x64'", client.out)
self._run_app(client, "x64", "Debug")
self.assertIn("Hello World Debug", client.out)
check_exe_run(client.out, "main", "msvc", "19.0", "Debug", "x86_64", "14",
check_exe_run(client.out, "main", "msvc", "190", "Debug", "x86_64", "14",
{"DEFINITIONS_BOTH": 'True',
"DEFINITIONS_BOTH2": "True",
"DEFINITIONS_BOTH_INT": "123",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
"""


vs_versions = [{"vs_version": "15", "msvc_version": "19.1", "ide_year": "2017", "toolset": "v141"}]
vs_versions = [{"vs_version": "15", "msvc_version": "191", "ide_year": "2017", "toolset": "v141"}]

if "17" in tools_locations['visual_studio'] and not tools_locations['visual_studio']['17'].get('disabled', False):
vs_versions.append({"vs_version": "17", "msvc_version": "19.3", "ide_year": "2022", "toolset": "v143"})
Expand Down
6 changes: 3 additions & 3 deletions conans/test/functional/toolchains/test_msbuild_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from conans.test.utils.tools import TestClient


@parameterized.expand([("msvc", "19.0", "dynamic"),
("msvc", "19.1X", "static")]
@parameterized.expand([("msvc", "190", "dynamic"),
("msvc", "191", "static")]
)
@pytest.mark.tool_visual_studio
@pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows")
Expand Down Expand Up @@ -37,7 +37,7 @@ def generate(self):
client.run("install . {}".format(settings))
props = client.load("conantoolchain_release_x64.props")
assert "<LanguageStandard>stdcpp17</LanguageStandard>" in props
if version == "19.0":
if version == "190":
assert "<PlatformToolset>v140</PlatformToolset>" in props
else:
assert "<PlatformToolset>v141</PlatformToolset>" in props
Expand Down
2 changes: 1 addition & 1 deletion conans/test/functional/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def check_exe_run(output, names, compiler, version, build_type, arch, cppstd, de
assert arch is None, "checked don't know how to validate this architecture"

if version:
assert "{} _MSC_VER{}".format(name, version.replace(".", "").replace("X", "")) in output
assert "{} _MSC_VER{}".format(name, version) in output
if cppstd:
assert "{} _MSVC_LANG20{}".format(name, cppstd) in output

Expand Down

0 comments on commit 2e54d45

Please sign in to comment.