@@ -188,8 +188,14 @@ def __str__(self):
188
188
189
189
190
190
class mbedToolchain :
191
+ # Verbose logging
191
192
VERBOSE = True
193
+
194
+ # Compile C files as CPP
192
195
COMPILE_C_AS_CPP = False
196
+
197
+ # Response files for compiling, includes, linking and archiving.
198
+ # Not needed on posix systems where the typical arg limit is 2 megabytes
193
199
RESPONSE_FILES = True
194
200
195
201
CORTEX_SYMBOLS = {
@@ -242,8 +248,6 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
242
248
# Number of concurrent build jobs. 0 means auto (based on host system cores)
243
249
self .jobs = 0
244
250
245
- self .CHROOT = None
246
-
247
251
# Ignore patterns from .mbedignore files
248
252
self .ignore_patterns = []
249
253
@@ -285,12 +289,20 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
285
289
# uVisor spepcific rules
286
290
if 'UVISOR' in self .target .features and 'UVISOR_SUPPORTED' in self .target .extra_labels :
287
291
self .target .core = re .sub (r"F$" , '' , self .target .core )
288
-
292
+
293
+ # Stats cache is used to reduce the amount of IO requests to stat
294
+ # header files during dependency change. See need_update()
289
295
self .stat_cache = {}
290
296
297
+ # Used by the mbed Online Build System to build in chrooted environment
298
+ self .CHROOT = None
299
+
300
+ # Call post __init__() hooks before the ARM/GCC_ARM/IAR toolchain __init__() takes over
291
301
self .init ()
292
302
293
- # This allows post __init__() hooks. Do not use
303
+ # Used for post __init__() hooks
304
+ # THIS METHOD IS BEING OVERRIDDEN BY THE MBED ONLINE BUILD SYSTEM
305
+ # ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY
294
306
def init (self ):
295
307
return True
296
308
@@ -340,6 +352,8 @@ def print_notify_verbose(self, event, silent=False):
340
352
elif event ['type' ] == 'progress' :
341
353
self .print_notify (event ) # standard handle
342
354
355
+ # THIS METHOD IS BEING OVERRIDDEN BY THE MBED ONLINE BUILD SYSTEM
356
+ # ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY
343
357
def notify (self , event ):
344
358
""" Little closure for notify functions
345
359
"""
@@ -392,6 +406,8 @@ def get_labels(self):
392
406
}
393
407
return self .labels
394
408
409
+
410
+ # Determine whether a source file needs updating/compiling
395
411
def need_update (self , target , dependencies ):
396
412
if self .build_all :
397
413
return True
@@ -601,6 +617,8 @@ def copy_files(self, files_paths, trg_path, resources=None, rel_path=None):
601
617
mkdir (dirname (target ))
602
618
copyfile (source , target )
603
619
620
+ # THIS METHOD IS BEING OVERRIDDEN BY THE MBED ONLINE BUILD SYSTEM
621
+ # ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY
604
622
def relative_object_path (self , build_path , base_dir , source ):
605
623
source_dir , name , _ = split_path (source )
606
624
@@ -610,6 +628,8 @@ def relative_object_path(self, build_path, base_dir, source):
610
628
mkdir (obj_dir )
611
629
return join (obj_dir , name + '.o' )
612
630
631
+ # Generate response file for all includes.
632
+ # ARM, GCC, IAR cross compatible
613
633
def get_inc_file (self , includes ):
614
634
include_file = join (self .build_dir , ".includes_%s.txt" % self .inc_md5 )
615
635
if not exists (include_file ):
@@ -625,6 +645,8 @@ def get_inc_file(self, includes):
625
645
f .write (string )
626
646
return include_file
627
647
648
+ # Generate response file for all objects when linking.
649
+ # ARM, GCC, IAR cross compatible
628
650
def get_link_file (self , cmd ):
629
651
link_file = join (self .build_dir , ".link_files.txt" )
630
652
with open (link_file , "wb" ) as f :
@@ -639,6 +661,8 @@ def get_link_file(self, cmd):
639
661
f .write (string )
640
662
return link_file
641
663
664
+ # Generate response file for all objects when archiving.
665
+ # ARM, GCC, IAR cross compatible
642
666
def get_arch_file (self , objects ):
643
667
archive_file = join (self .build_dir , ".archive_files.txt" )
644
668
with open (archive_file , "wb" ) as f :
@@ -649,6 +673,8 @@ def get_arch_file(self, objects):
649
673
f .write (string )
650
674
return archive_file
651
675
676
+ # THIS METHOD IS BEING CALLED BY THE MBED ONLINE BUILD SYSTEM
677
+ # ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY
652
678
def compile_sources (self , resources , build_path , inc_dirs = None ):
653
679
# Web IDE progress bar for project build
654
680
files_to_compile = resources .s_sources + resources .c_sources + resources .cpp_sources
@@ -699,6 +725,7 @@ def compile_sources(self, resources, build_path, inc_dirs=None):
699
725
else :
700
726
return self .compile_seq (queue , objects )
701
727
728
+ # Compile source files queue in sequential order
702
729
def compile_seq (self , queue , objects ):
703
730
for item in queue :
704
731
result = compile_worker (item )
@@ -715,6 +742,7 @@ def compile_seq(self, queue, objects):
715
742
objects .append (result ['object' ])
716
743
return objects
717
744
745
+ # Compile source files queue in parallel by creating pool of worker threads
718
746
def compile_queue (self , queue , objects ):
719
747
jobs_count = int (self .jobs if self .jobs else cpu_count () * CPU_COEF )
720
748
p = Pool (processes = jobs_count )
@@ -764,6 +792,7 @@ def compile_queue(self, queue, objects):
764
792
765
793
return objects
766
794
795
+ # Determine the compile command based on type of source file
767
796
def compile_command (self , source , object , includes ):
768
797
# Check dependencies
769
798
_ , ext = splitext (source )
@@ -858,6 +887,8 @@ def link_program(self, r, tmp_path, name):
858
887
859
888
return bin , needed_update
860
889
890
+ # THIS METHOD IS BEING OVERRIDDEN BY THE MBED ONLINE BUILD SYSTEM
891
+ # ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY
861
892
def default_cmd (self , command ):
862
893
_stdout , _stderr , _rc = run_cmd (command , work_dir = getcwd (), chroot = self .CHROOT )
863
894
self .debug ("Return: %s" % _rc )
@@ -876,18 +907,24 @@ def default_cmd(self, command):
876
907
def info (self , message ):
877
908
self .notify ({'type' : 'info' , 'message' : message })
878
909
910
+ # THIS METHOD IS BEING OVERRIDDEN BY THE MBED ONLINE BUILD SYSTEM
911
+ # ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY
879
912
def debug (self , message ):
880
913
if self .VERBOSE :
881
914
if type (message ) is ListType :
882
915
message = ' ' .join (message )
883
916
message = "[DEBUG] " + message
884
917
self .notify ({'type' : 'debug' , 'message' : message })
885
918
919
+ # THIS METHOD IS BEING OVERRIDDEN BY THE MBED ONLINE BUILD SYSTEM
920
+ # ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY
886
921
def cc_info (self , info = None ):
887
922
if info is not None :
888
923
info ['type' ] = 'cc'
889
924
self .notify (info )
890
925
926
+ # THIS METHOD IS BEING OVERRIDDEN BY THE MBED ONLINE BUILD SYSTEM
927
+ # ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY
891
928
def cc_verbose (self , message , file = "" ):
892
929
self .debug (message )
893
930
@@ -903,6 +940,8 @@ def tool_error(self, message):
903
940
def var (self , key , value ):
904
941
self .notify ({'type' : 'var' , 'key' : key , 'val' : value })
905
942
943
+ # THIS METHOD IS BEING OVERRIDDEN BY THE MBED ONLINE BUILD SYSTEM
944
+ # ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY
906
945
def mem_stats (self , map ):
907
946
"""! Creates parser object
908
947
@param map Path to linker map file to parse and decode
@@ -957,7 +996,6 @@ def get_config_header(self):
957
996
def get_config_macros (self ):
958
997
return Config .config_to_macros (self .config_data ) if self .config_data else []
959
998
960
-
961
999
from tools .settings import ARM_PATH
962
1000
from tools .settings import GCC_ARM_PATH , GCC_CR_PATH
963
1001
from tools .settings import IAR_PATH
0 commit comments