Skip to content

Commit 3becf77

Browse files
author
Cruz Monrreal
authored
Merge pull request #7466 from theotherjimmy/py3-version-check
Tools: py3 compatible version checks
2 parents 3f742c9 + 444d021 commit 3becf77

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

tools/toolchains/arm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ARM(mbedToolchain):
4141
SUPPORTED_CORES = ["Cortex-M0", "Cortex-M0+", "Cortex-M3", "Cortex-M4",
4242
"Cortex-M4F", "Cortex-M7", "Cortex-M7F", "Cortex-M7FD", "Cortex-A9"]
4343
ARMCC_RANGE = (LooseVersion("5.06"), LooseVersion("5.07"))
44-
ARMCC_VERSION_RE = re.compile("Component: ARM Compiler (\d+\.\d+)")
44+
ARMCC_VERSION_RE = re.compile(b"Component: ARM Compiler (\d+\.\d+)")
4545

4646
@staticmethod
4747
def check_executable():
@@ -99,7 +99,7 @@ def version_check(self):
9999
msg = None
100100
min_ver, max_ver = self.ARMCC_RANGE
101101
match = self.ARMCC_VERSION_RE.search(stdout)
102-
found_version = LooseVersion(match.group(1)) if match else None
102+
found_version = LooseVersion(match.group(1).decode("utf-8")) if match else None
103103
min_ver, max_ver = self.ARMCC_RANGE
104104
if found_version and (found_version < min_ver or found_version >= max_ver):
105105
msg = ("Compiler version mismatch: Have {}; "

tools/toolchains/gcc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class GCC(mbedToolchain):
3131
DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(?P<col>\d+):? (?P<severity>warning|[eE]rror|fatal error): (?P<message>.+)')
3232

3333
GCC_RANGE = (LooseVersion("6.0.0"), LooseVersion("7.0.0"))
34-
GCC_VERSION_RE = re.compile("\d+\.\d+\.\d+")
34+
GCC_VERSION_RE = re.compile(b"\d+\.\d+\.\d+")
3535

3636
def __init__(self, target, notify=None, macros=None, build_profile=None,
3737
build_dir=None):
@@ -116,7 +116,7 @@ def version_check(self):
116116
stdout, _, retcode = run_cmd([self.cc[0], "--version"], redirect=True)
117117
msg = None
118118
match = self.GCC_VERSION_RE.search(stdout)
119-
found_version = LooseVersion(match.group(0)) if match else None
119+
found_version = LooseVersion(match.group(0).decode('utf-8')) if match else None
120120
min_ver, max_ver = self.GCC_RANGE
121121
if found_version and (found_version < min_ver or found_version >= max_ver):
122122
msg = ("Compiler version mismatch: Have {}; "

tools/toolchains/iar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class IAR(mbedToolchain):
3030

3131
DIAGNOSTIC_PATTERN = re.compile('"(?P<file>[^"]+)",(?P<line>[\d]+)\s+(?P<severity>Warning|Error|Fatal error)(?P<message>.+)')
3232
INDEX_PATTERN = re.compile('(?P<col>\s*)\^')
33-
IAR_VERSION_RE = re.compile("IAR ANSI C/C\+\+ Compiler V(\d+\.\d+)")
33+
IAR_VERSION_RE = re.compile(b"IAR ANSI C/C\+\+ Compiler V(\d+\.\d+)")
3434
IAR_VERSION = LooseVersion("7.80")
3535

3636
@staticmethod
@@ -99,7 +99,7 @@ def version_check(self):
9999
stdout, _, retcode = run_cmd([self.cc[0], "--version"], redirect=True)
100100
msg = None
101101
match = self.IAR_VERSION_RE.search(stdout)
102-
found_version = match.group(1) if match else None
102+
found_version = match.group(1).decode("utf-8") if match else None
103103
if found_version and LooseVersion(found_version) != self.IAR_VERSION:
104104
msg = "Compiler version mismatch: Have {}; expected {}".format(
105105
found_version, self.IAR_VERSION)

0 commit comments

Comments
 (0)