Skip to content

Commit

Permalink
Merge pull request #5915 from DBS06/gcc_msg_parsing
Browse files Browse the repository at this point in the history
Simplify and Improve error/warning parser for gcc_arm
  • Loading branch information
0xc0170 committed Feb 19, 2018
2 parents 3fec23e + 3ce173b commit 636ced8
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions tools/toolchains/gcc.py
Expand Up @@ -26,8 +26,7 @@ class GCC(mbedToolchain):
LIBRARY_EXT = '.a'

STD_LIB_NAME = "lib%s.a"
DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(\d+:)? (?P<severity>warning|[eE]rror|fatal error): (?P<message>.+)')
INDEX_PATTERN = re.compile('(?P<col>\s*)\^')
DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(?P<col>\d+):? (?P<severity>warning|[eE]rror|fatal error): (?P<message>.+)')

def __init__(self, target, notify=None, macros=None,
silent=False, extra_verbose=False, build_profile=None,
Expand Down Expand Up @@ -125,21 +124,12 @@ def parse_output(self, output):
'severity': match.group('severity').lower(),
'file': match.group('file'),
'line': match.group('line'),
'col': 0,
'col': match.group('col'),
'message': match.group('message'),
'text': '',
'target_name': self.target.name,
'toolchain_name': self.name
}
elif msg is not None:
# Determine the warning/error column by calculating the ^ position
match = self.INDEX_PATTERN.match(line)
if match is not None:
msg['col'] = len(match.group('col'))
self.cc_info(msg)
msg = None
else:
msg['text'] += line+"\n"

if msg is not None:
self.cc_info(msg)
Expand Down

0 comments on commit 636ced8

Please sign in to comment.