Skip to content

Commit

Permalink
Merge branch 'release/1.41' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
czoido committed Oct 6, 2021
2 parents 1850fa0 + e2e9ff1 commit 9a5da4b
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 3 deletions.
2 changes: 1 addition & 1 deletion conan/tools/env/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def save_bat(self, filename, generate_deactivate=True, pathsep=os.pathsep):
for %%v in ({vars}) do (
set foundenvvar=
for /f "delims== tokens=1,2" %%a in ('set') do (
if "%%a" == "%%v" (
if /I "%%a" == "%%v" (
echo set %%a=%%b>> "deactivate_{filename}"
set foundenvvar=1
)
Expand Down
5 changes: 4 additions & 1 deletion conans/client/generators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self):
"MesonToolchain", "MSBuildDeps", "QbsToolchain", "msbuild",
"VirtualRunEnv", "VirtualBuildEnv", "AutotoolsDeps",
"AutotoolsToolchain", "BazelDeps", "BazelToolchain", "PkgConfigDeps",
"VCVars"]
"VCVars", "IntelCC"]

def add(self, name, generator_class, custom=False):
if name not in self._generators or custom:
Expand Down Expand Up @@ -119,6 +119,9 @@ def _new_generator(self, generator_name, output):
elif generator_name == "VCVars":
from conan.tools.microsoft import VCVars
return VCVars
elif generator_name == "IntelCC":
from conan.tools.intel import IntelCC
return IntelCC
elif generator_name == "QbsToolchain" or generator_name == "QbsProfile":
from conan.tools.qbs.qbsprofile import QbsProfile
return QbsProfile
Expand Down
Empty file.
64 changes: 64 additions & 0 deletions conans/test/integration/toolchains/intel/test_intel_cc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import platform
import textwrap

import pytest

from conans.test.utils.tools import TestClient

conanfile = textwrap.dedent("""\
[generators]
IntelCC
""")

intelprofile = textwrap.dedent("""\
[settings]
os=%s
arch=x86_64
arch_build=x86_64
compiler=intel-cc
compiler.mode=dpcpp
compiler.version=2021.3
compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]
CC=dpcpp
CXX=dpcpp
[conf]
tools.intel:installation_path=%s
""")


def get_intel_cc_generator_file(os_, installation_path, filename):
profile = intelprofile % (os_, installation_path)
client = TestClient()
client.save({
"conanfile.txt": conanfile,
"intelprofile": profile,
})
client.run("install . -pr intelprofile")
return client.load(filename)


@pytest.mark.skipif(platform.system() != "Windows", reason="Requires Windows")
def test_intel_cc_generator_windows():
os_ = "Windows"
installation_path = "C:\\Program Files (x86)\\Intel\\oneAPI"
conanintelsetvars = get_intel_cc_generator_file(os_, installation_path, "conanintelsetvars.bat")
expected = textwrap.dedent("""\
@echo off
call "C:\\Program Files (x86)\\Intel\\oneAPI\\setvars.bat" intel64
""")
assert conanintelsetvars == expected


@pytest.mark.skipif(platform.system() != "Linux", reason="Requires Linux")
def test_intel_cc_generator_linux():
os_ = "Linux"
installation_path = "/opt/intel/oneapi"
conanintelsetvars = get_intel_cc_generator_file(os_, installation_path, "conanintelsetvars.sh")
expected = '. "/opt/intel/oneapi/setvars.sh" intel64'
assert conanintelsetvars == expected
6 changes: 5 additions & 1 deletion conans/test/unittests/tools/env/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,26 +285,30 @@ def test_windows_case_insensitive():
env.define("MYVAR", "MyValueB")
env.define("MyVar1", "MyValue1A")
env.append("MYVAR1", "MyValue1B")
env.define("MyVar2", "MyNewValue2")
folder = temp_folder()

display_bat = textwrap.dedent("""\
@echo off
echo MyVar=%MyVar%!!
echo MyVar1=%MyVar1%!!
echo MyVar2=%MyVar2%!!
""")

with chdir(folder):
env.save_bat("test.bat")
save("display.bat", display_bat)
cmd = "test.bat && display.bat && deactivate_test.bat && display.bat"
out, _ = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
shell=True).communicate()
shell=True, env={"MYVAR2": "OldValue2"}).communicate()

out = out.decode()
assert "MyVar=MyValueB!!" in out
assert "MyVar=!!" in out
assert "MyVar1=MyValue1A MyValue1B!!" in out
assert "MyVar1=!!" in out
assert "MyVar2=MyNewValue2!!" in out
assert "MyVar2=OldValue2!!" in out


def test_dict_access():
Expand Down

0 comments on commit 9a5da4b

Please sign in to comment.