diff options
author | Stepan Nassyr <s.nassyr@fz-juelich.de> | 2022-06-09 21:51:06 +0200 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2022-06-10 08:24:52 -0700 |
commit | b0158955b721b224b1d3e864fba2eb397ba2073d (patch) | |
tree | bf268ed844f63cf8e0ce2467a0d4f1e202f0cb91 | |
parent | d045c9f79df629d8111ed46c2afeb37670bb8309 (diff) | |
download | meson-b0158955b721b224b1d3e864fba2eb397ba2073d.zip meson-b0158955b721b224b1d3e864fba2eb397ba2073d.tar.gz meson-b0158955b721b224b1d3e864fba2eb397ba2073d.tar.bz2 |
ACfL version detection with regex
-rw-r--r-- | mesonbuild/compilers/detect.py | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py index 79bc2b5..5e147a8 100644 --- a/mesonbuild/compilers/detect.py +++ b/mesonbuild/compilers/detect.py @@ -477,20 +477,9 @@ def _detect_c_or_cpp_compiler(env: 'Environment', lang: str, for_machine: Machin exe_wrap, linker=linker, full_version=full_version) if 'Arm C/C++/Fortran Compiler' in out: - version = '' - arm_ver_match = re.search(r'version (\d+)\.(\d+) \(build number (\d+)\)', out) - if arm_ver_match: - arm_ver_major = arm_ver_match.group(1) - arm_ver_minor = arm_ver_match.group(2) - arm_ver_build = arm_ver_match.group(3) - version = '.'.join([arm_ver_major, arm_ver_minor, arm_ver_build]) - else: - arm_ver_match = re.search(r'version (\d+)\.(\d+)\.(\d+) \(build number (\d+)\)', out) - arm_ver_major = arm_ver_match.group(1) - arm_ver_minor = arm_ver_match.group(2) - arm_ver_patch = arm_ver_match.group(3) - arm_ver_build = arm_ver_match.group(4) - version = '.'.join([arm_ver_major, arm_ver_minor, arm_ver_patch, arm_ver_build]) + arm_ver_match = re.search(r'version (\d+)\.(\d+)\.?(\d+)? \(build number (\d+)\)', out) + assert arm_ver_match is not None, 'for mypy' # because mypy *should* be complaning that this could be None + version = '.'.join([x for x in arm_ver_match.groups() if x is not None]) if lang == 'c': cls = ArmLtdClangCCompiler elif lang == 'cpp': @@ -756,20 +745,9 @@ def detect_fortran_compiler(env: 'Environment', for_machine: MachineChoice) -> C if 'Arm C/C++/Fortran Compiler' in out: cls = ArmLtdFlangFortranCompiler - version = '' - arm_ver_match = re.search(r'version (\d+)\.(\d+) \(build number (\d+)\)', out) - if arm_ver_match: - arm_ver_major = arm_ver_match.group(1) - arm_ver_minor = arm_ver_match.group(2) - arm_ver_build = arm_ver_match.group(3) - version = '.'.join([arm_ver_major, arm_ver_minor, arm_ver_build]) - else: - arm_ver_match = re.search(r'version (\d+)\.(\d+)\.(\d+) \(build number (\d+)\)', out) - arm_ver_major = arm_ver_match.group(1) - arm_ver_minor = arm_ver_match.group(2) - arm_ver_patch = arm_ver_match.group(3) - arm_ver_build = arm_ver_match.group(4) - version = '.'.join([arm_ver_major, arm_ver_minor, arm_ver_patch, arm_ver_build]) + arm_ver_match = re.search(r'version (\d+)\.(\d+)\.?(\d+)? \(build number (\d+)\)', out) + assert arm_ver_match is not None, 'for mypy' # because mypy *should* be complaning that this could be None + version = '.'.join([x for x in arm_ver_match.groups() if x is not None]) linker = guess_nix_linker(env, compiler, cls, version, for_machine) return cls( ccache + compiler, version, for_machine, is_cross, info, |