Skip to content

Commit

Permalink
Fix conanvcvars in powershell (#16322)
Browse files Browse the repository at this point in the history
fix conanvcvars ps1 and improve test
  • Loading branch information
juansblanco authored May 23, 2024
1 parent 95da083 commit 19fbb60
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions conan/tools/microsoft/visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def generate(self, scope="build"):

is_ps1 = conanfile.conf.get("tools.env.virtualenv:powershell", check_type=bool, default=False)
if is_ps1:
content_ps1 = textwrap.dedent(rf"""\
content_ps1 = textwrap.dedent(rf"""
if (-not $env:VSCMD_ARG_VCVARS_VER){{
Push-Location "$PSScriptRoot"
cmd /c "conanvcvars.bat&set" |
Expand All @@ -180,7 +180,7 @@ def generate(self, scope="build"):
}}
Pop-Location
write-host conanvcvars.ps1: Activated environment}}
""")
""").strip()
conan_vcvars_ps1 = f"{CONAN_VCVARS}.ps1"
create_env_script(conanfile, content_ps1, conan_vcvars_ps1, scope)
_create_deactivate_vcvars_file(conanfile, conan_vcvars_ps1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ def build(self):
assert "conanvcvars.ps1: Activated environment" in client.out
#check that the new env variables are set
assert "VSCMD_ARG_VCVARS_VER" in client.out

client.run_command(r'powershell.exe ".\build\Release\generators\conanvcvars.ps1"')
assert client.out.strip() == "conanvcvars.ps1: Activated environment"

conanbuild = client.load(r".\build\Release\generators\conanbuild.ps1")
vcvars_ps1 = client.load(r".\build\Release\generators\conanvcvars.ps1")
#check that the conanvcvars.ps1 is being added to the conanbuild.ps1
Expand Down

0 comments on commit 19fbb60

Please sign in to comment.