From 3f889606c7debafacd3da9c9e74caa61b45a13ff Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Wed, 2 Jun 2021 19:30:55 +0200 Subject: Split compiler detection from Environment This moves all the compiler detection logic into the new compilers.detect module. This dramatically reduces the size and complexity of Environment. --- mesonbuild/mesonlib/universal.py | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'mesonbuild/mesonlib/universal.py') diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py index 160cc37..4b4eb6e 100644 --- a/mesonbuild/mesonlib/universal.py +++ b/mesonbuild/mesonlib/universal.py @@ -135,6 +135,7 @@ __all__ = [ 'version_compare', 'version_compare_condition_with_min', 'version_compare_many', + 'search_version', 'windows_proof_rm', 'windows_proof_rmtree', ] @@ -883,6 +884,49 @@ def version_compare_condition_with_min(condition: str, minimum: str) -> bool: return T.cast(bool, cmpop(Version(minimum), Version(condition))) +def search_version(text: str) -> str: + # Usually of the type 4.1.4 but compiler output may contain + # stuff like this: + # (Sourcery CodeBench Lite 2014.05-29) 4.8.3 20140320 (prerelease) + # Limiting major version number to two digits seems to work + # thus far. When we get to GCC 100, this will break, but + # if we are still relevant when that happens, it can be + # considered an achievement in itself. + # + # This regex is reaching magic levels. If it ever needs + # to be updated, do not complexify but convert to something + # saner instead. + # We'll demystify it a bit with a verbose definition. + version_regex = re.compile(r""" + (? str: if is_debianlike(): -- cgit v1.1