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

MSBuild. parameter to skip toolset adjustement #5052

Merged
merged 2 commits into from Apr 29, 2019
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
3 changes: 2 additions & 1 deletion conans/client/build/msbuild.py
Expand Up @@ -104,7 +104,8 @@ def get_command(self, project_file, props_file_path=None, targets=None, upgrade_

build_type = build_type or self._settings.get_safe("build_type")
arch = arch or self._settings.get_safe("arch")
toolset = toolset or tools.msvs_toolset(self._settings)
if toolset is None: # False value to skip adjusting
toolset = tools.msvs_toolset(self._settings)
verbosity = os.getenv("CONAN_MSBUILD_VERBOSITY") or verbosity or "minimal"
if not build_type:
raise ConanException("Cannot build_sln_command, build_type not defined")
Expand Down
31 changes: 31 additions & 0 deletions conans/test/unittests/client/build/msbuild_test.py
Expand Up @@ -8,6 +8,7 @@
from parameterized import parameterized

from conans.client import tools
from conans.client.tools.files import chdir
from conans.client.build.msbuild import MSBuild
from conans.errors import ConanException
from conans.model.version import Version
Expand Down Expand Up @@ -152,6 +153,36 @@ def default_toolset_test(self, compiler_version, expected_toolset):
command = msbuild.get_command("project_should_flags_test_file.sln")
self.assertIn('/p:PlatformToolset="%s"' % expected_toolset, command)

@unittest.skipUnless(platform.system() == "Windows", "Requires MSBuild")
def skip_toolset_test(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test failing in Linux because not VS

settings = MockSettings({"build_type": "Debug",
"compiler": "Visual Studio",
"compiler.version": "15",
"arch": "x86_64"})

class Runner(object):

def __init__(self):
self.commands = []

def __call__(self, *args, **kwargs):
self.commands.append(args[0])

with chdir(tools.mkdir_tmp()):
runner = Runner()
conanfile = MockConanfile(settings, runner=runner)
msbuild = MSBuild(conanfile)
msbuild.build("myproject", toolset=False)
self.assertEqual(len(runner.commands), 1)
self.assertNotIn("PlatformToolset", runner.commands[0])

runner = Runner()
conanfile = MockConanfile(settings, runner=runner)
msbuild = MSBuild(conanfile)
msbuild.build("myproject", toolset="mytoolset")
self.assertEqual(len(runner.commands), 1)
self.assertIn('/p:PlatformToolset="mytoolset"', runner.commands[0])

@parameterized.expand([("v142",),
("v141",),
("v140",),
Expand Down