Exemplo n.º 1
0
 def _get_toolset(self, generator):
     if generator is None or ("Visual" not in generator and "Xcode" not in generator):
         return None
     settings = self._conanfile.settings
     compiler = settings.get_safe("compiler")
     compiler_base = settings.get_safe("compiler.base")
     if compiler == "Visual Studio":
         subs_toolset = settings.get_safe("compiler.toolset")
         if subs_toolset:
             return subs_toolset
     elif compiler == "intel" and compiler_base == "Visual Studio" and "Visual" in generator:
         # TODO: This intel toolset needs to be validated too
         compiler_version = settings.get_safe("compiler.version")
         if compiler_version:
             compiler_version = compiler_version if "." in compiler_version else \
                 "%s.0" % compiler_version
             return "Intel C++ Compiler " + compiler_version
     elif compiler == "intel-cc":
         return IntelCC(self._conanfile).ms_toolset
     elif compiler == "msvc":
         compiler_version = str(settings.compiler.version)
         compiler_update = str(settings.compiler.update)
         if compiler_update != "None":  # It is full one(19.28), not generic 19.2X
             # The equivalent of compiler 19.26 is toolset 14.26
             return "version=14.{}{}".format(compiler_version[-1], compiler_update)
         else:
             return "v14{}".format(compiler_version[-1])
     elif compiler == "clang":
         if generator and "Visual" in generator:
             if "Visual Studio 16" in generator:
                 return "ClangCL"
             else:
                 raise ConanException("CMakeToolchain compiler=clang only supported VS 16")
     return None
Exemplo n.º 2
0
def test_check_ms_toolsets(mode, expected):
    conanfile = ConanFileMock()
    conanfile.settings = MockSettings({
        "compiler.version": "2021.3",
        "compiler.mode": mode,
        "os": "Windows"
    })
    assert IntelCC(conanfile).ms_toolset == expected
Exemplo n.º 3
0
def test_classic_compiler_supports_every_os(os_):
    conanfile = ConanFileMock()
    conanfile.settings = MockSettings({
        "compiler.version": "2021.3",
        "compiler.mode": "classic",
        "os": os_,
        "arch": "x86_64"
    })
    assert IntelCC(conanfile).arch == "x86_64"
Exemplo n.º 4
0
def test_error_if_detected_intel_legacy_version(os_):
    conanfile = ConanFileMock()
    conanfile.settings = MockSettings({
        "compiler.version": "19.1",
        "compiler.mode": "classic",
        "os": os_
    })
    with pytest.raises(ConanException) as excinfo:
        IntelCC(conanfile)
    assert "You have to use 'intel' compiler which is meant for legacy" in str(
        excinfo.value)
Exemplo n.º 5
0
def test_macos_not_supported_for_new_compilers(mode):
    conanfile = ConanFileMock()
    conanfile.settings = MockSettings({
        "compiler.version": "2021.3",
        "compiler.mode": mode,
        "os": "Darwin"
    })
    with pytest.raises(ConanException) as excinfo:
        IntelCC(conanfile)
    assert "macOS* is not supported for the icx/icpx or dpcpp compilers." in str(
        excinfo.value)
Exemplo n.º 6
0
 def generate(self):
     toolchain_file = self._conanfile.conf["tools.cmake.cmaketoolchain:toolchain_file"]
     if toolchain_file is None:  # The main toolchain file generated only if user dont define
         save(self.filename, self.content)
     # If we're using Intel oneAPI, we need to generate the environment file and run it
     if self._conanfile.settings.get_safe("compiler") == "intel-cc":
         IntelCC(self._conanfile).generate()
     # Generators like Ninja or NMake requires an active vcvars
     elif self.generator is not None and "Visual" not in self.generator:
         VCVars(self._conanfile).generate()
     self._writebuild(toolchain_file)
Exemplo n.º 7
0
def test_installation_path_in_conf():
    conanfile = ConanFileMock()
    conanfile.settings = MockSettings({
        "compiler.version": "2021.3",
        "compiler.mode": "classic",
        "os": "Windows"
    })
    fake_path = "mysuper/path/to/intel/oneapi"
    conanfile.conf = ConfDefinition()
    conanfile.conf.loads(
        textwrap.dedent("""\
        tools.intel:installation_path=%s
    """ % fake_path))
    assert IntelCC(conanfile).installation_path == fake_path
Exemplo n.º 8
0
 def generate(self):
     toolchain_file = self._conanfile.conf.get(
         "tools.cmake.cmaketoolchain:toolchain_file")
     if toolchain_file is None:  # The main toolchain file generated only if user dont define
         save(
             os.path.join(self._conanfile.generators_folder, self.filename),
             self.content)
     # If we're using Intel oneAPI, we need to generate the environment file and run it
     if self._conanfile.settings.get_safe("compiler") == "intel-cc":
         IntelCC(self._conanfile).generate()
     # Generators like Ninja or NMake requires an active vcvars
     elif self.generator is not None and "Visual" not in self.generator:
         VCVars(self._conanfile).generate()
     toolchain = os.path.join(self._conanfile.generators_folder,
                              toolchain_file or self.filename)
     write_cmake_presets(self._conanfile, toolchain, self.generator)
Exemplo n.º 9
0
 def _get_toolset(self, generator):
     if generator is None or ("Visual" not in generator
                              and "Xcode" not in generator):
         return None
     settings = self._conanfile.settings
     compiler = settings.get_safe("compiler")
     compiler_base = settings.get_safe("compiler.base")
     toolset = None
     if compiler == "Visual Studio":
         toolset = settings.get_safe("compiler.toolset")
     elif compiler == "intel" and compiler_base == "Visual Studio" and "Visual" in generator:
         # TODO: This intel toolset needs to be validated too
         compiler_version = settings.get_safe("compiler.version")
         if compiler_version:
             compiler_version = compiler_version if "." in compiler_version else \
                 "%s.0" % compiler_version
             toolset = "Intel C++ Compiler " + compiler_version
     elif compiler == "intel-cc":
         return IntelCC(self._conanfile).ms_toolset
     elif compiler == "msvc":
         toolset = settings.get_safe("compiler.toolset")
         if toolset is None:
             compiler_version = str(settings.compiler.version)
             compiler_update = str(settings.compiler.update)
             if compiler_update != "None":  # It is full one(19.28), not generic 19.2X
                 # The equivalent of compiler 19.26 is toolset 14.26
                 toolset = "version=14.{}{}".format(compiler_version[-1],
                                                    compiler_update)
             else:
                 toolset = msvc_version_to_toolset_version(compiler_version)
     elif compiler == "clang":
         if generator and "Visual" in generator:
             if "Visual Studio 16" in generator:
                 toolset = "ClangCL"
             else:
                 raise ConanException(
                     "CMakeToolchain compiler=clang only supported VS 16")
     toolset_arch = self._conanfile.conf.get(
         "tools.cmake.cmaketoolchain:toolset_arch")
     if toolset_arch is not None:
         toolset_arch = "host={}".format(toolset_arch)
         toolset = toolset_arch if toolset is None else "{},{}".format(
             toolset, toolset_arch)
     return toolset
Exemplo n.º 10
0
def test_setvars_command_with_custom_arguments(platform_system, os_,
                                               call_command, setvars_file):
    platform_system.return_value = os_
    conanfile = ConanFileMock()
    conanfile.settings = MockSettings({
        "compiler.version": "2021.3",
        "compiler.mode": "icx",
        "os": os_
    })
    fake_path = "mysuper/path/to/intel/oneapi"
    args = "arg1 arg2 --force"
    conanfile.conf = ConfDefinition()
    conanfile.conf.loads(
        textwrap.dedent("""\
        tools.intel:installation_path=%s
        tools.intel:setvars_args=%s
    """ % (fake_path, args)))
    expected = '%s "%s" %s' % (call_command,
                               os.path.join(fake_path, setvars_file), args)
    assert IntelCC(conanfile).command == expected