Skip to content

Commit e9d255d

Browse files
lizalcdcbaker
authored andcommitted
compilers/gnu: use version attributes for feature checks
Replace the hardcoded version strings with class attributes to allow subclasses to override them.
1 parent 5b50a6b commit e9d255d

File tree

1 file changed

+9
-4
lines changed
  • mesonbuild/compilers/mixins

1 file changed

+9
-4
lines changed

mesonbuild/compilers/mixins/gnu.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,18 @@ class GnuCompiler(GnuLikeCompiler):
547547
"""
548548
id = 'gcc'
549549

550+
_COLOR_VERSION = '>=4.9.0'
551+
_WPEDANTIC_VERSION = '>=4.8.0'
552+
_LTO_AUTO_VERSION = '>=10.0'
553+
_USE_MOLD_VERSION = '>=12.0.1'
554+
550555
def __init__(self, defines: T.Optional[T.Dict[str, str]]):
551556
super().__init__()
552557
self.defines = defines or {}
553558
self.base_options.update({OptionKey('b_colorout'), OptionKey('b_lto_threads')})
554-
self._has_color_support = mesonlib.version_compare(self.version, '>=4.9.0')
555-
self._has_wpedantic_support = mesonlib.version_compare(self.version, '>=4.8.0')
556-
self._has_lto_auto_support = mesonlib.version_compare(self.version, '>=10.0')
559+
self._has_color_support = mesonlib.version_compare(self.version, self._COLOR_VERSION)
560+
self._has_wpedantic_support = mesonlib.version_compare(self.version, self._WPEDANTIC_VERSION)
561+
self._has_lto_auto_support = mesonlib.version_compare(self.version, self._LTO_AUTO_VERSION)
557562

558563
def get_colorout_args(self, colortype: str) -> T.List[str]:
559564
if self._has_color_support:
@@ -627,7 +632,7 @@ def get_lto_compile_args(self, *, threads: int = 0, mode: str = 'default') -> T.
627632

628633
@classmethod
629634
def use_linker_args(cls, linker: str, version: str) -> T.List[str]:
630-
if linker == 'mold' and mesonlib.version_compare(version, '>=12.0.1'):
635+
if linker == 'mold' and mesonlib.version_compare(version, cls._USE_MOLD_VERSION):
631636
return ['-fuse-ld=mold']
632637
return super().use_linker_args(linker, version)
633638

0 commit comments

Comments
 (0)