From da9ba2b2549e39b6707c7095a2e97db7e3d3efeb Mon Sep 17 00:00:00 2001 From: LPettey-Arm <58987326+LPettey-Arm@users.noreply.github.com> Date: Tue, 7 Apr 2020 10:58:54 -0500 Subject: Add build number to Arm compiler version identification (#15809) * Add capability for detecting build number for Arm compilers * Fixing fleck8 errors and updating test_arm_version_detection function for more detailed Arm compielr version detection * Ran flake8 locally and corrected errors * Altering Arm compielr version check to remove else clause and be more consistent with other compielr version checks. Added test case so both the 'if' and 'else' conditionals of the Arm compiler version check have a test case Co-authored-by: EC2 Default User --- lib/spack/spack/compilers/arm.py | 16 +++++++++++++++- lib/spack/spack/test/compilers.py | 8 +++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/spack/spack/compilers/arm.py b/lib/spack/spack/compilers/arm.py index ffce1e2b01..ca17ff42e8 100644 --- a/lib/spack/spack/compilers/arm.py +++ b/lib/spack/spack/compilers/arm.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) import spack.compiler +import re class Arm(spack.compiler.Compiler): @@ -35,7 +36,20 @@ class Arm(spack.compiler.Compiler): # InstalledDir: # /opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin version_argument = '--version' - version_regex = r'Arm C\/C\+\+\/Fortran Compiler version ([^ )]+)' + version_regex = r'Arm C\/C\+\+\/Fortran Compiler version ([\d\.]+) '\ + r'\(build number (\d+)\) ' + + @classmethod + def extract_version_from_output(cls, output): + """Extracts the version from compiler's output.""" + match = re.search(cls.version_regex, output) + temp = 'unknown' + if match: + if match.group(1).count('.') == 1: + temp = match.group(1) + ".0." + match.group(2) + else: + temp = match.group(1) + "." + match.group(2) + return temp @classmethod def verbose_flag(cls): diff --git a/lib/spack/spack/test/compilers.py b/lib/spack/spack/test/compilers.py index 51eedd748f..13e3d9e695 100644 --- a/lib/spack/spack/test/compilers.py +++ b/lib/spack/spack/test/compilers.py @@ -369,7 +369,13 @@ def test_clang_version_detection(version_str, expected_version): 'Thread model: posix\n' 'InstalledDir:\n' '/opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin\n', # NOQA - '19.0') + '19.0.0.73'), + ('Arm C/C++/Fortran Compiler version 19.3.1 (build number 75) (based on LLVM 7.0.2)\n' # NOQA + 'Target: aarch64--linux-gnu\n' + 'Thread model: posix\n' + 'InstalledDir:\n' + '/opt/arm/arm-hpc-compiler-19.0_Generic-AArch64_RHEL-7_aarch64-linux/bin\n', # NOQA + '19.3.1.75') ]) def test_arm_version_detection(version_str, expected_version): version = spack.compilers.arm.Arm.extract_version_from_output(version_str) -- cgit v1.2.3-70-g09d2