Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msvc_runtime_flag should not break when expecting a string value #10424

Merged
merged 2 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions conan/tools/microsoft/visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def msvc_runtime_flag(conanfile):
if runtime_type == "Debug":
runtime = "{}d".format(runtime)
return runtime
return ""


def vcvars_command(version, architecture=None, platform_type=None, winsdk_version=None,
Expand Down
22 changes: 20 additions & 2 deletions conans/test/functional/toolchains/microsoft/test_msbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from conans.test.conftest import tools_locations
from conans.test.functional.utils import check_vs_runtime, check_exe_run
from conans.test.utils.tools import TestClient
from conans.util.files import rmdir


sln_file = r"""
Expand Down Expand Up @@ -551,8 +552,7 @@ def test_toolchain_win_multi(self):
# Build the profile according to the settings provided
# TODO: It is a bit ugly to remove manually
build_test_folder = os.path.join(client.current_folder, "test_package", "build")
if os.path.exists(build_test_folder):
shutil.rmtree(build_test_folder)
rmdir(build_test_folder)
runtime = "MT" if build_type == "Release" else "MTd"
client.run("create . hello/0.1@ %s -s build_type=%s -s arch=%s -s compiler.runtime=%s "
" -o hello:shared=%s" % (settings, build_type, arch, runtime, shared))
Expand Down Expand Up @@ -605,3 +605,21 @@ def test_toolchain_win_multi(self):
else:
self.assertNotIn("hello.dll", client.out)
self.assertIn("KERNEL32.dll", client.out)


def test_msvc_runtime_flag_common_usage():
"""The msvc_runtime_flag must not break when expecting a string
"""
client = TestClient()
conanfile = textwrap.dedent("""
from conans import ConanFile
from conan.tools.microsoft import msvc_runtime_flag
class App(ConanFile):
settings = "os", "arch", "compiler", "build_type"

def validate(self):
if "MT" in msvc_runtime_flag(self):
pass
""")
client.save({"conanfile.py": conanfile})
client.run('info .')