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

Fix build scope OS detection in tools.microsoft.visual.VCVars #15568

Merged
merged 4 commits into from
Feb 6, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion conan/tools/microsoft/visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ def generate(self, scope="build"):
"""
check_duplicated_generator(self, self._conanfile)
conanfile = self._conanfile

os_ = conanfile.settings.get_safe("os")
if os_ != "Windows":
build_os_ = conanfile.settings_build.get_safe("os")

if os_ != "Windows" or build_os_ != "Windows":
return

compiler = conanfile.settings.get_safe("compiler")
Expand Down
13 changes: 13 additions & 0 deletions conans/test/integration/toolchains/microsoft/vcvars_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ def test_vcvars_generator_skip():
client.run('install . -pr=profile')
assert not os.path.exists(os.path.join(client.current_folder, "conanvcvars.bat"))

@pytest.mark.skipif(platform.system() not in ["Linux"], reason="Requires Linux")
def test_vcvars_generator_skip_on_linux():
"""
Skip creation of conanvcvars.bat on Linux build systems
"""
client = TestClient()
client.save({"conanfile.py": GenConanfile().with_generator("VCVars")
.with_settings("os", "compiler",
"arch", "build_type")})

client.run('install . -s os=Windows -s compiler=msvc -s compiler.version=193 '
'-s compiler.runtime=dynamic')
assert not os.path.exists(os.path.join(client.current_folder, "conanvcvars.bat"))

@pytest.mark.skipif(platform.system() not in ["Windows"], reason="Requires Windows")
def test_vcvars_generator_string():
Expand Down