Skip to content

Commit 3e59bdc

Browse files
Add parameter in tools settings to show error/warning as Link
Per default mbed compile prints errors/warnings on output not in a link format, therefore it is not possible to click, i.e. in an IDE, on the errors/warnings and jump to the position in the file. The settings parameter lets you decide in witch format do you want to have it. If it is enabled then the output will look like: [Error/Warning] [absolute\path\to\file.ext]:[line]:[column]: [msg] with this format nearly every common known IDE can deal with this link and lets you jump to the file
1 parent a6e27b1 commit 3e59bdc

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

tools/default_settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@
4343

4444
# mbed.org username
4545
#MBED_ORG_USER = ""
46+
47+
# Print compiler warnings and errors as link format
48+
#PRINT_COMPILER_OUTPUT_AS_LINK = False

tools/settings.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
# mbed.org username
5555
MBED_ORG_USER = ""
5656

57+
# Print compiler warnings and errors as link format
58+
PRINT_COMPILER_OUTPUT_AS_LINK = False
59+
5760
CLI_COLOR_MAP = {
5861
"warning": "yellow",
5962
"error" : "red"
@@ -74,7 +77,7 @@
7477
# User Settings (env vars)
7578
##############################################################################
7679
_ENV_PATHS = ['ARM_PATH', 'GCC_ARM_PATH', 'GCC_CR_PATH', 'IAR_PATH',
77-
'ARMC6_PATH']
80+
'ARMC6_PATH', 'PRINT_COMPILER_OUTPUT_AS_LINK']
7881

7982
for _n in _ENV_PATHS:
8083
if getenv('MBED_'+_n):

tools/toolchains/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
from ..utils import (run_cmd, mkdir, rel_path, ToolException,
3737
NotSupportedException, split_path, compile_worker)
38-
from ..settings import MBED_ORG_USER
38+
from ..settings import MBED_ORG_USER, PRINT_COMPILER_OUTPUT_AS_LINK
3939
from .. import hooks
4040
from ..memap import MemapParser
4141

@@ -460,8 +460,13 @@ def print_notify(self, event, silent=False):
460460

461461
elif event['type'] == 'cc':
462462
event['severity'] = event['severity'].title()
463-
event['file'] = basename(event['file'])
464-
msg = '[%(severity)s] %(file)s@%(line)s,%(col)s: %(message)s' % event
463+
464+
if PRINT_COMPILER_OUTPUT_AS_LINK:
465+
event['file'] = getcwd() + event['file'].strip('.')
466+
msg = '[%(severity)s] %(file)s:%(line)s:%(col)s: %(message)s' % event
467+
else:
468+
event['file'] = basename(event['file'])
469+
msg = '[%(severity)s] %(file)s@%(line)s,%(col)s: %(message)s' % event
465470

466471
elif event['type'] == 'progress':
467472
if 'percent' in event:

0 commit comments

Comments
 (0)