Skip to content

Commit

Permalink
Merge pull request #7466 from theotherjimmy/py3-version-check
Browse files Browse the repository at this point in the history
Tools: py3 compatible version checks
  • Loading branch information
Cruz Monrreal authored Jul 11, 2018
2 parents 3f742c9 + 444d021 commit 3becf77
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tools/toolchains/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ARM(mbedToolchain):
SUPPORTED_CORES = ["Cortex-M0", "Cortex-M0+", "Cortex-M3", "Cortex-M4",
"Cortex-M4F", "Cortex-M7", "Cortex-M7F", "Cortex-M7FD", "Cortex-A9"]
ARMCC_RANGE = (LooseVersion("5.06"), LooseVersion("5.07"))
ARMCC_VERSION_RE = re.compile("Component: ARM Compiler (\d+\.\d+)")
ARMCC_VERSION_RE = re.compile(b"Component: ARM Compiler (\d+\.\d+)")

@staticmethod
def check_executable():
Expand Down Expand Up @@ -99,7 +99,7 @@ def version_check(self):
msg = None
min_ver, max_ver = self.ARMCC_RANGE
match = self.ARMCC_VERSION_RE.search(stdout)
found_version = LooseVersion(match.group(1)) if match else None
found_version = LooseVersion(match.group(1).decode("utf-8")) if match else None
min_ver, max_ver = self.ARMCC_RANGE
if found_version and (found_version < min_ver or found_version >= max_ver):
msg = ("Compiler version mismatch: Have {}; "
Expand Down
4 changes: 2 additions & 2 deletions tools/toolchains/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GCC(mbedToolchain):
DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(?P<col>\d+):? (?P<severity>warning|[eE]rror|fatal error): (?P<message>.+)')

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

def __init__(self, target, notify=None, macros=None, build_profile=None,
build_dir=None):
Expand Down Expand Up @@ -116,7 +116,7 @@ def version_check(self):
stdout, _, retcode = run_cmd([self.cc[0], "--version"], redirect=True)
msg = None
match = self.GCC_VERSION_RE.search(stdout)
found_version = LooseVersion(match.group(0)) if match else None
found_version = LooseVersion(match.group(0).decode('utf-8')) if match else None
min_ver, max_ver = self.GCC_RANGE
if found_version and (found_version < min_ver or found_version >= max_ver):
msg = ("Compiler version mismatch: Have {}; "
Expand Down
4 changes: 2 additions & 2 deletions tools/toolchains/iar.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class IAR(mbedToolchain):

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

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

0 comments on commit 3becf77

Please sign in to comment.