summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiza Chevalier <lizalc@pm.me>2025-10-27 17:25:51 -0500
committerDylan Baker <dylan@pnwbakers.com>2025-10-29 12:35:55 -0700
commite9d255de1580235fff96e110001ce4293006caaa (patch)
tree25df3ae836ceccbd657c7364403f501fc3fc57ba
parent5b50a6b4084edbb5802460c83ec8a6085e9df331 (diff)
downloadmeson-e9d255de1580235fff96e110001ce4293006caaa.tar.gz
compilers/gnu: use version attributes for feature checks
Replace the hardcoded version strings with class attributes to allow subclasses to override them.
-rw-r--r--mesonbuild/compilers/mixins/gnu.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py
index bedee621a..239d7ef3a 100644
--- a/mesonbuild/compilers/mixins/gnu.py
+++ b/mesonbuild/compilers/mixins/gnu.py
@@ -547,13 +547,18 @@ class GnuCompiler(GnuLikeCompiler):
"""
id = 'gcc'
+ _COLOR_VERSION = '>=4.9.0'
+ _WPEDANTIC_VERSION = '>=4.8.0'
+ _LTO_AUTO_VERSION = '>=10.0'
+ _USE_MOLD_VERSION = '>=12.0.1'
+
def __init__(self, defines: T.Optional[T.Dict[str, str]]):
super().__init__()
self.defines = defines or {}
self.base_options.update({OptionKey('b_colorout'), OptionKey('b_lto_threads')})
- self._has_color_support = mesonlib.version_compare(self.version, '>=4.9.0')
- self._has_wpedantic_support = mesonlib.version_compare(self.version, '>=4.8.0')
- self._has_lto_auto_support = mesonlib.version_compare(self.version, '>=10.0')
+ self._has_color_support = mesonlib.version_compare(self.version, self._COLOR_VERSION)
+ self._has_wpedantic_support = mesonlib.version_compare(self.version, self._WPEDANTIC_VERSION)
+ self._has_lto_auto_support = mesonlib.version_compare(self.version, self._LTO_AUTO_VERSION)
def get_colorout_args(self, colortype: str) -> T.List[str]:
if self._has_color_support:
@@ -627,7 +632,7 @@ class GnuCompiler(GnuLikeCompiler):
@classmethod
def use_linker_args(cls, linker: str, version: str) -> T.List[str]:
- if linker == 'mold' and mesonlib.version_compare(version, '>=12.0.1'):
+ if linker == 'mold' and mesonlib.version_compare(version, cls._USE_MOLD_VERSION):
return ['-fuse-ld=mold']
return super().use_linker_args(linker, version)