Skip to content

Tools: py3 compatible version checks #7466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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