Use Non-blocking Error and LooseVersion

pull/7247/head
Jimmy Brisson 2018-06-19 10:41:08 -05:00
parent 6f54a8fdd7
commit a87575fec5
3 changed files with 59 additions and 25 deletions

View File

@ -23,6 +23,7 @@ from os.path import join, dirname, splitext, basename, exists, relpath, isfile
from os import makedirs, write, curdir, remove from os import makedirs, write, curdir, remove
from tempfile import mkstemp from tempfile import mkstemp
from shutil import rmtree from shutil import rmtree
from distutils.version import LooseVersion
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
from tools.hooks import hook_tool from tools.hooks import hook_tool
@ -39,8 +40,8 @@ class ARM(mbedToolchain):
SHEBANG = "#! armcc -E" SHEBANG = "#! armcc -E"
SUPPORTED_CORES = ["Cortex-M0", "Cortex-M0+", "Cortex-M3", "Cortex-M4", SUPPORTED_CORES = ["Cortex-M0", "Cortex-M0+", "Cortex-M3", "Cortex-M4",
"Cortex-M4F", "Cortex-M7", "Cortex-M7F", "Cortex-M7FD", "Cortex-A9"] "Cortex-M4F", "Cortex-M7", "Cortex-M7F", "Cortex-M7FD", "Cortex-A9"]
ARMCC_VERSION = "5.06" ARMCC_RANGE = (LooseVersion("5.06"), LooseVersion("5.07"))
ARMCC_VERSION_RE = re.compile("^Product: ARM Compiler (.*)$") ARMCC_VERSION_RE = re.compile("^Product: ARM Compiler ([.0-9]*)")
@staticmethod @staticmethod
def check_executable(): def check_executable():
@ -95,14 +96,29 @@ class ARM(mbedToolchain):
def version_check(self): def version_check(self):
stdout, _, retcode = run_cmd([self.cc[0], "--vsn"], redirect=True) stdout, _, retcode = run_cmd([self.cc[0], "--vsn"], redirect=True)
msg = None
min_ver, max_ver = self.ARMCC_RANGE
first_line = stdout.splitlines()[0] first_line = stdout.splitlines()[0]
match = self.ARMCC_VERSION_RE.match(first_line) match = self.ARMCC_VERSION_RE.match(first_line)
if match: if match:
found_version = match.group(1) found_version = LooseVersion(match.group(1))
if not found_version.startswith(self.ARMCC_VERSION): if found_version < min_ver or found_version > max_ver:
raise NotSupportedException( msg = ("Compiler version mismatch: Have {}; "
"ARM compiler version mismatch: Have {}; expected {}" "expected >= {} < {}"
.format(found_version, self.ARMCC_VERSION)) .format(found_version, min_ver, max_ver))
else:
msg = ("Compiler version mismatch: Could not detect version; "
"expected >= {} < {}"
.format(min_ver, max_ver))
if msg:
self.notify.cc_info({
"message": msg,
"file": "",
"line": "",
"col": "",
"severity": "ERROR",
})
def _get_toolchain_labels(self): def _get_toolchain_labels(self):
if getattr(self.target, "default_lib", "std") == "small": if getattr(self.target, "default_lib", "std") == "small":
@ -337,7 +353,7 @@ class ARMC6(ARM_STD):
"Cortex-M4F", "Cortex-M7", "Cortex-M7F", "Cortex-M7FD", "Cortex-M4F", "Cortex-M7", "Cortex-M7F", "Cortex-M7FD",
"Cortex-M23", "Cortex-M23-NS", "Cortex-M33", "Cortex-M23", "Cortex-M23-NS", "Cortex-M33",
"CortexM33-NS", "Cortex-A9"] "CortexM33-NS", "Cortex-A9"]
ARMCC_VERSION = "6.10" ARMCC_RANGE = (LooseVersion("6.10"), LooseVersion("7.0"))
@staticmethod @staticmethod
def check_executable(): def check_executable():

View File

@ -17,6 +17,7 @@ limitations under the License.
import re import re
from os.path import join, basename, splitext, dirname, exists from os.path import join, basename, splitext, dirname, exists
from distutils.spawn import find_executable from distutils.spawn import find_executable
from distutils.version import LooseVersion
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
from tools.hooks import hook_tool from tools.hooks import hook_tool
@ -29,7 +30,7 @@ class GCC(mbedToolchain):
STD_LIB_NAME = "lib%s.a" STD_LIB_NAME = "lib%s.a"
DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(?P<col>\d+):? (?P<severity>warning|[eE]rror|fatal error): (?P<message>.+)') DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(?P<col>\d+):? (?P<severity>warning|[eE]rror|fatal error): (?P<message>.+)')
GCC_MAJOR = "6" GCC_RANGE = (LooseVersion("6.0.0"), LooseVersion("7.0.0"))
GCC_VERSION_RE = re.compile("[0-9]*\.[0-9]*\.[0-9]*") GCC_VERSION_RE = re.compile("[0-9]*\.[0-9]*\.[0-9]*")
def __init__(self, target, notify=None, macros=None, build_profile=None, def __init__(self, target, notify=None, macros=None, build_profile=None,
@ -118,15 +119,24 @@ class GCC(mbedToolchain):
for word in line.split(): for word in line.split():
match = self.GCC_VERSION_RE.match(word) match = self.GCC_VERSION_RE.match(word)
if match: if match:
found_version = match.group(0) found_version = LooseVersion(match.group(0))
if found_version and not found_version.startswith(self.GCC_MAJOR + "."): min_ver, max_ver = self.GCC_RANGE
raise NotSupportedException( if found_version and (found_version < min_ver or found_version >= max_ver):
"GCC_ARM compiler version mismatch: Have {}; expected major version {}" msg = ("Compiler version mismatch: Have {}; "
.format(found_version, self.GCC_MAJOR)) "expected version >= {} and < {}"
.format(found_version, min_ver, max_ver))
elif not found_version: elif not found_version:
raise NotSupportedException( msg = ("Compiler version mismatch: Could not detect version; "
"GCC_ARM compiler version mismatch: Could Not detect compiler " "expected version >= {} and < {}"
"version; expected {}".format(self.GCC_MAJOR)) .format(min_ver, max_ver))
if msg:
self.notify.cc_info({
"message": msg,
"file": "",
"line": "",
"col": "",
"severity": "ERROR",
})
def is_not_supported_error(self, output): def is_not_supported_error(self, output):
return "error: #error [NOT_SUPPORTED]" in output return "error: #error [NOT_SUPPORTED]" in output

View File

@ -17,6 +17,7 @@ limitations under the License.
import re import re
from os import remove from os import remove
from os.path import join, splitext, exists from os.path import join, splitext, exists
from distutils.version import LooseVersion
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
from tools.hooks import hook_tool from tools.hooks import hook_tool
@ -30,7 +31,7 @@ class IAR(mbedToolchain):
DIAGNOSTIC_PATTERN = re.compile('"(?P<file>[^"]+)",(?P<line>[\d]+)\s+(?P<severity>Warning|Error|Fatal error)(?P<message>.+)') 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*)\^') INDEX_PATTERN = re.compile('(?P<col>\s*)\^')
IAR_VERSION_RE = re.compile("IAR ANSI C/C\+\+ Compiler V([0-9]+.[0-9]+)") IAR_VERSION_RE = re.compile("IAR ANSI C/C\+\+ Compiler V([0-9]+.[0-9]+)")
IAR_VERSION = "7.80" IAR_VERSION = LooseVersion("7.80")
@staticmethod @staticmethod
def check_executable(): def check_executable():
@ -101,14 +102,21 @@ class IAR(mbedToolchain):
match = self.IAR_VERSION_RE.match(line) match = self.IAR_VERSION_RE.match(line)
if match: if match:
found_version = match.group(1) found_version = match.group(1)
if found_version and not found_version.startswith(self.IAR_VERSION): msg = None
raise NotSupportedException( if found_version and LooseVersion(found_version) != self.IAR_VERSION:
"IAR compiler version mismatch: Have {}; expected {}" msg = "Compiler version mismatch: Have {}; expected {}".format(
.format(found_version, self.IAR_VERSION)) found_version, self.IAR_VERSION)
elif not found_version: elif not found_version:
raise NotSupportedException( msg = ("Compiler version mismatch: Could Not detect compiler "
"IAR compiler version mismatch: Could Not detect compiler "
"version; expected {}".format(self.IAR_VERSION)) "version; expected {}".format(self.IAR_VERSION))
if msg:
self.notify.cc_info({
"message": msg,
"file": "",
"line": "",
"col": "",
"severity": "ERROR",
})
def parse_dependencies(self, dep_path): def parse_dependencies(self, dep_path):