18
18
from builtins import str # noqa: F401
19
19
20
20
import re
21
- import os
22
21
from copy import copy
23
- from os .path import join , dirname , splitext , basename , exists , isfile , split
22
+ from os .path import join , dirname , splitext , basename , exists , isfile
24
23
from os import makedirs , write , remove
25
24
from tempfile import mkstemp
26
25
from shutil import rmtree
27
26
from distutils .version import LooseVersion
28
27
29
28
from tools .targets import CORE_ARCH
30
29
from tools .toolchains .mbed_toolchain import mbedToolchain , TOOLCHAIN_PATHS
31
- from tools .utils import mkdir , NotSupportedException , ToolException , run_cmd
30
+ from tools .utils import mkdir , NotSupportedException , run_cmd
32
31
33
32
ARMC5_MIGRATION_WARNING = (
34
33
"Warning: We noticed that you are using Arm Compiler 5. "
38
37
"please visit https://os.mbed.com/docs/mbed-os/latest/tools/index.html"
39
38
)
40
39
40
+
41
41
class ARM (mbedToolchain ):
42
42
LINKER_EXT = '.sct'
43
43
LIBRARY_EXT = '.ar'
@@ -184,7 +184,7 @@ def parse_dependencies(self, dep_path):
184
184
def parse_output (self , output ):
185
185
msg = None
186
186
for line in output .splitlines ():
187
- match = ARM .DIAGNOSTIC_PATTERN .match (line )
187
+ match = self .DIAGNOSTIC_PATTERN .match (line )
188
188
if match is not None :
189
189
if msg is not None :
190
190
self .notify .cc_info (msg )
@@ -306,7 +306,14 @@ def correct_scatter_shebang(self, scatter_file, cur_dir_name=None):
306
306
307
307
return new_scatter
308
308
309
- def get_link_command (self , output , objects , libraries , lib_dirs , scatter_file ):
309
+ def get_link_command (
310
+ self ,
311
+ output ,
312
+ objects ,
313
+ libraries ,
314
+ lib_dirs ,
315
+ scatter_file
316
+ ):
310
317
base , _ = splitext (output )
311
318
map_file = base + ".map"
312
319
args = ["-o" , output , "--info=totals" , "--map" , "--list=%s" % map_file ]
@@ -378,6 +385,7 @@ def redirect_symbol(source, sync, build_dir):
378
385
write (handle , "RESOLVE %s AS %s\n " % (source , sync ))
379
386
return "--edit=%s" % filename
380
387
388
+
381
389
class ARM_STD (ARM ):
382
390
383
391
OFFICIALLY_SUPPORTED = True
@@ -399,9 +407,11 @@ def __init__(
399
407
build_profile = build_profile
400
408
)
401
409
if int (target .build_tools_metadata ["version" ]) > 0 :
402
- #check only for ARMC5 because ARM_STD means using ARMC5, and thus
410
+ # check only for ARMC5 because ARM_STD means using ARMC5, and thus
403
411
# supported_toolchains must include ARMC5
404
- if not set (target .supported_toolchains ).intersection (set (("ARMC5" , "ARM" ))):
412
+ if not set (target .supported_toolchains ).intersection (
413
+ set (("ARMC5" , "ARM" ))
414
+ ):
405
415
raise NotSupportedException (
406
416
"ARM compiler 5 support is required for ARM build"
407
417
)
@@ -413,6 +423,7 @@ def __init__(
413
423
"ARM/uARM compiler support is required for ARM build"
414
424
)
415
425
426
+
416
427
class ARM_MICRO (ARM ):
417
428
418
429
PATCHED_LIBRARY = False
@@ -434,7 +445,7 @@ def __init__(
434
445
# At this point we already know that we want to use ARMC5+Microlib
435
446
# so check for if they are supported For, AC6+Microlib we still
436
447
# use ARMC6 class
437
- if not set (("ARMC5" ,"uARM" )).issubset (set (
448
+ if not set (("ARMC5" , "uARM" )).issubset (set (
438
449
target .supported_toolchains
439
450
)):
440
451
raise NotSupportedException (
@@ -469,6 +480,10 @@ class ARMC6(ARM_STD):
469
480
"Cortex-A9"
470
481
]
471
482
ARMCC_RANGE = (LooseVersion ("6.10" ), LooseVersion ("7.0" ))
483
+ LD_DIAGNOSTIC_PATTERN = re .compile (
484
+ '(?P<severity>Warning|Error): (?P<message>.+)'
485
+ )
486
+ DIAGNOSTIC_PATTERN = re .compile ('((?P<file>[^:]+):(?P<line>\d+):)(?P<col>\d+):? (?P<severity>warning|[eE]rror|fatal error): (?P<message>.+)' )
472
487
473
488
@staticmethod
474
489
def check_executable ():
@@ -586,9 +601,9 @@ def __init__(self, target, *args, **kwargs):
586
601
self .ar = join (TOOLCHAIN_PATHS ["ARMC6" ], "armar" )
587
602
self .elf2bin = join (TOOLCHAIN_PATHS ["ARMC6" ], "fromelf" )
588
603
589
- # Adding this for safety since this inherits the `version_check` function
590
- # but does not call the constructor of ARM_STD, so the `product_name` variable
591
- # is not initialized.
604
+ # Adding this for safety since this inherits the `version_check`
605
+ # function but does not call the constructor of ARM_STD, so the
606
+ # `product_name` variable is not initialized.
592
607
self .product_name = None
593
608
594
609
def _get_toolchain_labels (self ):
@@ -608,7 +623,31 @@ def is_not_supported_error(self, output):
608
623
return "#error [NOT_SUPPORTED]" in output
609
624
610
625
def parse_output (self , output ):
611
- pass
626
+ for line in output .splitlines ():
627
+ match = self .LD_DIAGNOSTIC_PATTERN .match (line )
628
+ if match is not None :
629
+ self .notify .cc_info ({
630
+ 'severity' : match .group ('severity' ).lower (),
631
+ 'message' : match .group ('message' ),
632
+ 'text' : '' ,
633
+ 'target_name' : self .target .name ,
634
+ 'toolchain_name' : self .name ,
635
+ 'col' : 0 ,
636
+ 'file' : "" ,
637
+ 'line' : 0
638
+ })
639
+ match = self .DIAGNOSTIC_PATTERN .search (line )
640
+ if match is not None :
641
+ self .notify .cc_info ({
642
+ 'severity' : match .group ('severity' ).lower (),
643
+ 'file' : match .group ('file' ),
644
+ 'line' : match .group ('line' ),
645
+ 'col' : match .group ('col' ),
646
+ 'message' : match .group ('message' ),
647
+ 'text' : '' ,
648
+ 'target_name' : self .target .name ,
649
+ 'toolchain_name' : self .name
650
+ })
612
651
613
652
def get_config_option (self , config_header ):
614
653
return ["-include" , config_header ]
@@ -660,7 +699,14 @@ def compile(self, cc, source, object, includes):
660
699
cmd .extend (["-o" , object , source ])
661
700
return [cmd ]
662
701
663
- def get_link_command (self , output , objects , libraries , lib_dirs , scatter_file ):
702
+ def get_link_command (
703
+ self ,
704
+ output ,
705
+ objects ,
706
+ libraries ,
707
+ lib_dirs ,
708
+ scatter_file
709
+ ):
664
710
cmd = ARM .get_link_command (
665
711
self , output , objects , libraries , lib_dirs , scatter_file
666
712
)
0 commit comments