|
3 | 3 |
|
4 | 4 | from __future__ import annotations |
5 | 5 |
|
6 | | -"""Representations specific to the Microchip XC16 C compiler family.""" |
| 6 | +"""Representations specific to the Microchip XC C/C++ compiler family.""" |
7 | 7 |
|
8 | 8 | import os |
9 | 9 | import typing as T |
10 | 10 |
|
11 | | -from ...mesonlib import EnvironmentException |
| 11 | +from .gnu import GnuCStds, GnuCPPStds |
| 12 | +from ..compilers import Compiler |
| 13 | +from ...mesonlib import EnvironmentException, version_compare |
12 | 14 |
|
13 | 15 | if T.TYPE_CHECKING: |
14 | 16 | from ...envconfig import MachineInfo |
15 | 17 | from ...environment import Environment |
16 | | - from ...compilers.compilers import Compiler |
| 18 | + |
| 19 | + CompilerBase = Compiler |
17 | 20 | else: |
18 | 21 | # This is a bit clever, for mypy we pretend that these mixins descend from |
19 | 22 | # Compiler, so we get all of the methods and attributes defined for us, but |
20 | 23 | # for runtime we make them descend from object (which all classes normally |
21 | 24 | # do). This gives up DRYer type checking, with no runtime impact |
22 | | - Compiler = object |
| 25 | + CompilerBase = object |
23 | 26 |
|
24 | 27 | xc16_optimization_args: T.Dict[str, T.List[str]] = { |
25 | 28 | 'plain': [], |
@@ -109,3 +112,84 @@ def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str], bu |
109 | 112 | parameter_list[idx] = i[:9] + os.path.normpath(os.path.join(build_dir, i[9:])) |
110 | 113 |
|
111 | 114 | return parameter_list |
| 115 | + |
| 116 | + |
| 117 | +class Xc32Compiler(CompilerBase): |
| 118 | + |
| 119 | + """Microchip XC32 compiler mixin. GCC based with some options disabled.""" |
| 120 | + |
| 121 | + id = 'xc32-gcc' |
| 122 | + |
| 123 | + gcc_version = '4.5.1' # Defaults to GCC version used by first XC32 release (v1.00). |
| 124 | + |
| 125 | + _COLOR_VERSION = ">=3.0" # XC32 version based on GCC 8.3.1+ |
| 126 | + _WPEDANTIC_VERSION = ">=1.40" # XC32 version based on GCC 4.8.3+ |
| 127 | + _LTO_AUTO_VERSION = "==-1" |
| 128 | + _USE_MOLD_VERSION = "==-1" |
| 129 | + |
| 130 | + def __init__(self) -> None: |
| 131 | + if not self.is_cross: |
| 132 | + raise EnvironmentException("XC32 supports only cross-compilation.") |
| 133 | + |
| 134 | + def get_instruction_set_args(self, instruction_set: str) -> T.Optional[T.List[str]]: |
| 135 | + return None |
| 136 | + |
| 137 | + def thread_flags(self, env: Environment) -> T.List[str]: |
| 138 | + return [] |
| 139 | + |
| 140 | + def openmp_flags(self, env: Environment) -> T.List[str]: |
| 141 | + return Compiler.openmp_flags(self, env) |
| 142 | + |
| 143 | + def get_pic_args(self) -> T.List[str]: |
| 144 | + return Compiler.get_pic_args(self) |
| 145 | + |
| 146 | + def get_pie_args(self) -> T.List[str]: |
| 147 | + return Compiler.get_pie_args(self) |
| 148 | + |
| 149 | + def get_profile_generate_args(self) -> T.List[str]: |
| 150 | + return Compiler.get_profile_generate_args(self) |
| 151 | + |
| 152 | + def get_profile_use_args(self) -> T.List[str]: |
| 153 | + return Compiler.get_profile_use_args(self) |
| 154 | + |
| 155 | + def sanitizer_compile_args(self, value: T.List[str]) -> T.List[str]: |
| 156 | + return [] |
| 157 | + |
| 158 | + @classmethod |
| 159 | + def use_linker_args(cls, linker: str, version: str) -> T.List[str]: |
| 160 | + return [] |
| 161 | + |
| 162 | + def get_coverage_args(self) -> T.List[str]: |
| 163 | + return [] |
| 164 | + |
| 165 | + def get_largefile_args(self) -> T.List[str]: |
| 166 | + return [] |
| 167 | + |
| 168 | + def get_prelink_args(self, prelink_name: str, obj_list: T.List[str]) -> T.Tuple[T.List[str], T.List[str]]: |
| 169 | + return Compiler.get_prelink_args(self, prelink_name, obj_list) |
| 170 | + |
| 171 | + def get_prelink_append_compile_args(self) -> bool: |
| 172 | + return False |
| 173 | + |
| 174 | + def supported_warn_args(self, warn_args_by_version: T.Dict[str, T.List[str]]) -> T.List[str]: |
| 175 | + result: T.List[str] = [] |
| 176 | + for version, warn_args in warn_args_by_version.items(): |
| 177 | + if version_compare(self.gcc_version, '>=' + version): |
| 178 | + result += warn_args |
| 179 | + return result |
| 180 | + |
| 181 | +class Xc32CStds(GnuCStds): |
| 182 | + |
| 183 | + """Mixin for setting C standards based on XC32 version.""" |
| 184 | + |
| 185 | + _C18_VERSION = ">=3.0" |
| 186 | + _C2X_VERSION = "==-1" |
| 187 | + _C23_VERSION = "==-1" |
| 188 | + _C2Y_VERSION = "==-1" |
| 189 | + |
| 190 | +class Xc32CPPStds(GnuCPPStds): |
| 191 | + |
| 192 | + """Mixin for setting C++ standards based on XC32 version.""" |
| 193 | + |
| 194 | + _CPP23_VERSION = "==-1" |
| 195 | + _CPP26_VERSION = "==-1" |
0 commit comments