Skip to content

Commit

Permalink
msvc_runtime_flag should not break when expecting a string value (#10424
Browse files Browse the repository at this point in the history
)

* msvc_runtime_flag should not break

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Remove folder

Signed-off-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
uilianries committed Jan 28, 2022
1 parent 9c34ea7 commit 0073a7c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
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 .')

0 comments on commit 0073a7c

Please sign in to comment.