Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- tests for toolchains and intel compiler
Signed-off-by: SSE4 <tomskside@gmail.com>
- Loading branch information
Showing
6 changed files
with
267 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
import platform | ||
import textwrap | ||
import unittest | ||
|
||
from conans.client.tools.intel import intel_installation_path | ||
from conans.errors import ConanException | ||
from conans.test.utils.tools import TestClient | ||
|
||
|
||
class BaseIntelTestCase(unittest.TestCase): | ||
def setUp(self): | ||
try: | ||
installation_path = intel_installation_path(self.version, self.arch) | ||
if not os.path.isdir(installation_path): | ||
raise unittest.SkipTest("Intel C++ compiler is required") | ||
except ConanException: | ||
raise unittest.SkipTest("Intel C++ compiler is required") | ||
|
||
self.t = TestClient() | ||
|
||
@property | ||
def version(self): | ||
return '19.1' | ||
|
||
@property | ||
def arch(self): | ||
return "x86_64" | ||
|
||
@property | ||
def settings(self): | ||
the_os = {'Darwin': 'Macos'}.get(platform.system(), platform.system()) | ||
vars = [('compiler', 'intel'), | ||
('compiler.version', self.version), | ||
('build_type', 'Release'), | ||
('arch', self.arch), | ||
('os', the_os)] | ||
if platform.system() == "Windows": | ||
vars.append(('compiler.base', 'Visual Studio')) | ||
vars.append(('compiler.base.version', '15')) | ||
vars.append(('compiler.base.runtime', 'MD')) | ||
else: | ||
vars.append(('compiler.base', 'gcc')) | ||
vars.append(('compiler.base.version', '10')) | ||
vars.append(('compiler.base.libcxx', 'libstdc++')) | ||
return vars | ||
|
||
@property | ||
def profile(self): | ||
template = textwrap.dedent(""" | ||
include(default) | ||
[settings] | ||
{settings} | ||
""") | ||
settings = '\n'.join(["%s = %s" % (s[0], s[1]) for s in self.settings]) | ||
return template.format(settings=settings) |
106 changes: 106 additions & 0 deletions
106
conans/test/integration/toolchains/intel/test_using_cmake.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import os | ||
import pytest | ||
import textwrap | ||
|
||
from ._base import BaseIntelTestCase | ||
|
||
from conans.client.toolchain.cmake.base import CMakeToolchainBase | ||
from conans.client.toolchain.visual import vcvars_command | ||
from conans.test.assets.sources import gen_function_cpp | ||
|
||
|
||
cmakelists_txt = textwrap.dedent(""" | ||
cmake_minimum_required(VERSION 2.8.12) | ||
project(MyApp CXX) | ||
find_package(hello REQUIRED) | ||
set(CMAKE_VERBOSE_MAKEFILE ON) | ||
add_executable(${CMAKE_PROJECT_NAME} main.cpp) | ||
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "d") | ||
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE hello::hello) | ||
install(TARGETS ${CMAKE_PROJECT_NAME} | ||
RUNTIME DESTINATION bin | ||
LIBRARY DESTINATION lib | ||
ARCHIVE DESTINATION lib | ||
PUBLIC_HEADER DESTINATION include | ||
) | ||
""") | ||
|
||
conanfile_py = textwrap.dedent(""" | ||
from conans import ConanFile, CMake, CMakeToolchain | ||
class App(ConanFile): | ||
settings = 'os', 'arch', 'compiler', 'build_type' | ||
exports_sources = "CMakeLists.txt", "main.cpp" | ||
generators = "cmake_find_package_multi" | ||
requires = "hello/0.1" | ||
_cmake = None | ||
def _configure_cmake(self): | ||
if not self._cmake: | ||
self._cmake = CMake(self) | ||
self._cmake.configure() | ||
return self._cmake | ||
def toolchain(self): | ||
tc = CMakeToolchain(self) | ||
tc.write_toolchain_files() | ||
def build(self): | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
def package(self): | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
""") | ||
|
||
@pytest.mark.toolchain | ||
@pytest.mark.tool_cmake | ||
@pytest.mark.tool_icc | ||
class CMakeIntelTestCase(BaseIntelTestCase): | ||
|
||
def test_use_cmake_toolchain(self): | ||
self.t.save({'profile': self.profile}) | ||
self.t.run("new hello/0.1 -s") | ||
self.t.run("create . hello/0.1@ -pr:h=profile") | ||
|
||
app = gen_function_cpp(name="main", includes=["hello"], calls=["hello"]) | ||
|
||
# Prepare the actual consumer package | ||
self.t.save({"conanfile.py": conanfile_py, | ||
"main.cpp": app, | ||
"CMakeLists.txt": cmakelists_txt, | ||
'profile': self.profile}, | ||
clean_first=True) | ||
|
||
# Build in the cache | ||
self.t.run("install . -pr:h=profile") | ||
self.assertIn("conanfile.py: Generator cmake_find_package_multi created helloTargets.cmake", | ||
self.t.out) | ||
self.t.run("build .") | ||
self.assertIn("The CXX compiler identification is Intel 19.1", self.t.out) | ||
|
||
exe = os.path.join("Release", "MyApp.exe") | ||
self.t.run_command(exe) | ||
self.assertIn("main __INTEL_COMPILER1910", self.t.out) | ||
|
||
vcvars = vcvars_command(version="15", architecture="x64") | ||
dumpbind_cmd = '%s && dumpbin /dependents "%s"' % (vcvars, exe) | ||
self.t.run_command(dumpbind_cmd) | ||
self.assertIn("KERNEL32.dll", self.t.out) | ||
|
||
# Build locally | ||
os.unlink(os.path.join(self.t.current_folder, exe)) | ||
|
||
self.t.run_command('cmake . -G "Visual Studio 15 2017" ' | ||
'-DCMAKE_TOOLCHAIN_FILE={}'.format(CMakeToolchainBase.filename)) | ||
self.t.run_command('cmake --build . --config Release') | ||
|
||
self.t.run_command(exe) | ||
self.assertIn("main __INTEL_COMPILER1910", self.t.out) | ||
|
||
self.t.run_command(dumpbind_cmd) | ||
self.assertIn("KERNEL32.dll", self.t.out) |
87 changes: 87 additions & 0 deletions
87
conans/test/integration/toolchains/intel/test_using_msbuild.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import os | ||
import platform | ||
import pytest | ||
import textwrap | ||
import unittest | ||
|
||
from ._base import BaseIntelTestCase | ||
from ..test_msbuild import myapp_vcxproj, sln_file | ||
|
||
from conans.client.toolchain.visual import vcvars_command | ||
from conans.test.assets.sources import gen_function_cpp | ||
|
||
|
||
conanfile_py = textwrap.dedent(""" | ||
from conans import ConanFile, MSBuild, MSBuildToolchain | ||
class App(ConanFile): | ||
settings = 'os', 'arch', 'compiler', 'build_type' | ||
exports_sources = "MyProject.sln", "MyApp/MyApp.vcxproj", "MyApp/MyApp.cpp" | ||
generators = "msbuild" | ||
requires = "hello/0.1" | ||
def toolchain(self): | ||
tc = MSBuildToolchain(self) | ||
tc.write_toolchain_files() | ||
def build(self): | ||
msbuild = MSBuild(self) | ||
msbuild.build("MyProject.sln") | ||
""") | ||
|
||
|
||
@pytest.mark.toolchain | ||
@pytest.mark.tool_cmake | ||
@pytest.mark.tool_msbuild | ||
@pytest.mark.tool_icc | ||
@unittest.skipUnless(platform.system() == "Windows", "msbuild requires Windows") | ||
class MSBuildIntelTestCase(BaseIntelTestCase): | ||
def test_use_msbuild_toolchain(self): | ||
self.t.save({'profile': self.profile}) | ||
self.t.run("new hello/0.1 -s") | ||
self.t.run("create . hello/0.1@ -pr:h=profile") | ||
|
||
app = gen_function_cpp(name="main", includes=["hello"], calls=["hello"]) | ||
|
||
# Prepare the actual consumer package | ||
self.t.save({"conanfile.py": conanfile_py, | ||
"MyProject.sln": sln_file, | ||
"MyApp/MyApp.vcxproj": myapp_vcxproj, | ||
"MyApp/MyApp.cpp": app, | ||
'profile': self.profile}, | ||
clean_first=True) | ||
|
||
# Build in the cache | ||
self.t.run("install . -pr:h=profile -if=conan") | ||
|
||
self.assertIn("conanfile.py: MSBuildToolchain created conan_toolchain_release_x64.props", | ||
self.t.out) | ||
|
||
self.t.run("build . -if=conan") | ||
self.assertIn("Visual Studio 2017", self.t.out) | ||
self.assertIn("[vcvarsall.bat] Environment initialized for: 'x64'", self.t.out) | ||
|
||
exe = "x64\\Release\\MyApp.exe" | ||
self.t.run_command(exe) | ||
self.assertIn("main __INTEL_COMPILER1910", self.t.out) | ||
|
||
vcvars = vcvars_command(version="15", architecture="x64") | ||
dumpbind_cmd = '%s && dumpbin /dependents "%s"' % (vcvars, exe) | ||
self.t.run_command(dumpbind_cmd) | ||
self.assertIn("KERNEL32.dll", self.t.out) | ||
|
||
# Build locally | ||
os.unlink(os.path.join(self.t.current_folder, exe)) | ||
|
||
cmd = vcvars + ' && msbuild "MyProject.sln" /p:Configuration=Release ' \ | ||
'/p:Platform=x64 /p:PlatformToolset="Intel C++ Compiler 19.1"' | ||
|
||
self.t.run_command(cmd) | ||
self.assertIn("Visual Studio 2017", self.t.out) | ||
self.assertIn("[vcvarsall.bat] Environment initialized for: 'x64'", self.t.out) | ||
|
||
self.t.run_command(exe) | ||
self.assertIn("main __INTEL_COMPILER1910", self.t.out) | ||
|
||
self.t.run_command(dumpbind_cmd) | ||
self.assertIn("KERNEL32.dll", self.t.out) |