cengal.build_tools.current_compiler.versions.v_0.current_compiler

 1#!/usr/bin/env python
 2# coding=utf-8
 3
 4# Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>
 5# 
 6# Licensed under the Apache License, Version 2.0 (the "License");
 7# you may not use this file except in compliance with the License.
 8# You may obtain a copy of the License at
 9# 
10#     http://www.apache.org/licenses/LICENSE-2.0
11# 
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17
18
19__all__ = ['compiler_type', 'compiler_name', 'compiler_string', 'compiler_string_escaped']
20
21
22"""
23Module Docstring
24Docstrings: http://www.python.org/dev/peps/pep-0257/
25"""
26
27__author__ = "ButenkoMS <gtalk@butenkoms.space>"
28__copyright__ = "Copyright © 2012-2024 ButenkoMS. All rights reserved. Contacts: <gtalk@butenkoms.space>"
29__credits__ = ["ButenkoMS <gtalk@butenkoms.space>", ]
30__license__ = "Apache License, Version 2.0"
31__version__ = "4.4.1"
32__maintainer__ = "ButenkoMS <gtalk@butenkoms.space>"
33__email__ = "gtalk@butenkoms.space"
34# __status__ = "Prototype"
35__status__ = "Development"
36# __status__ = "Production"
37
38
39from distutils import sysconfig
40from cengal.os.execute import escape_text
41
42
43compiler_name_raw: str = sysconfig.get_config_var("CC")
44if compiler_name_raw is None:
45    if sysconfig.get_config_var("VSINSTALLDIR") is None:
46        compiler_name_raw = str()
47    else:
48        compiler_name_raw = 'msvc'
49
50compiler_name: str = compiler_name_raw.split()[0] if compiler_name_raw else str()
51compiler_string: str = compiler_name_raw
52compiler_string_escaped: str = escape_text(compiler_name_raw)
53
54if "gcc" in compiler_name_raw.lower():
55    compiler_type: str = 'gcc'
56elif "msvc" in compiler_name_raw.lower():
57    compiler_type = 'msvc'
58elif "clang" in compiler_name_raw.lower():
59    compiler_type = 'clang'
60elif "icc" in compiler_name_raw.lower():
61    compiler_type = 'icc'
62elif "llvm" in compiler_name_raw.lower():
63    compiler_type = 'llvm'
64elif "intel" in compiler_name_raw.lower():
65    compiler_type = 'intel'
66elif "arm" in compiler_name_raw.lower():
67    compiler_type = 'arm'
68elif "mingw" in compiler_name_raw.lower():
69    compiler_type = 'mingw'
70else:
71    compiler_type = 'unknown'
compiler_type: str = 'gcc'
compiler_name: str = 'x86_64-linux-gnu-gcc'
compiler_string: str = 'x86_64-linux-gnu-gcc -pthread'
compiler_string_escaped: str = 'x86_64-linux-gnu-gcc -pthread'