@@ -230,7 +230,8 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
230230 self .macros = macros or []
231231
232232 # Macros generated from toolchain and target rules/features
233- self .symbols = None
233+ self .asm_symbols = None
234+ self .cxx_symbols = None
234235
235236 # Labels generated from toolchain and target rules/features (used for selective build)
236237 self .labels = None
@@ -372,36 +373,50 @@ def notify(self, event):
372373 event ['toolchain' ] = self
373374 return self .notify_fun (event , self .silent )
374375
375- def get_symbols (self ):
376- if self .symbols is None :
377- # Target and Toolchain symbols
378- labels = self .get_labels ()
379- self .symbols = ["TARGET_%s" % t for t in labels ['TARGET' ]]
380- self .symbols .extend (["TOOLCHAIN_%s" % t for t in labels ['TOOLCHAIN' ]])
381-
382- # Cortex CPU symbols
383- if self .target .core in mbedToolchain .CORTEX_SYMBOLS :
384- self .symbols .extend (mbedToolchain .CORTEX_SYMBOLS [self .target .core ])
385-
386- # Symbols defined by the on-line build.system
387- self .symbols .extend (['MBED_BUILD_TIMESTAMP=%s' % self .timestamp , 'TARGET_LIKE_MBED' , '__MBED__=1' ])
388- if MBED_ORG_USER :
389- self .symbols .append ('MBED_USERNAME=' + MBED_ORG_USER )
390-
391- # Add target's symbols
392- self .symbols += self .target .macros
393- # Add target's hardware
394- self .symbols += ["DEVICE_" + data + "=1" for data in self .target .device_has ]
395- # Add target's features
396- self .symbols += ["FEATURE_" + data + "=1" for data in self .target .features ]
397- # Add extra symbols passed via 'macros' parameter
398- self .symbols += self .macros
399-
400- # Form factor variables
401- if hasattr (self .target , 'supported_form_factors' ):
402- self .symbols .extend (["TARGET_FF_%s" % t for t in self .target .supported_form_factors ])
403-
404- return list (set (self .symbols )) # Return only unique symbols
376+ def get_symbols (self , for_asm = False ):
377+ if for_asm :
378+ if self .asm_symbols is None :
379+ self .asm_symbols = []
380+
381+ # Cortex CPU symbols
382+ if self .target .core in mbedToolchain .CORTEX_SYMBOLS :
383+ self .asm_symbols .extend (mbedToolchain .CORTEX_SYMBOLS [self .target .core ])
384+
385+ # Add target's symbols
386+ self .asm_symbols += self .target .macros
387+ # Add extra symbols passed via 'macros' parameter
388+ self .asm_symbols += self .macros
389+ return list (set (self .asm_symbols )) # Return only unique symbols
390+ else :
391+ if self .cxx_symbols is None :
392+ # Target and Toolchain symbols
393+ labels = self .get_labels ()
394+ self .cxx_symbols = ["TARGET_%s" % t for t in labels ['TARGET' ]]
395+ self .cxx_symbols .extend (["TOOLCHAIN_%s" % t for t in labels ['TOOLCHAIN' ]])
396+
397+ # Cortex CPU symbols
398+ if self .target .core in mbedToolchain .CORTEX_SYMBOLS :
399+ self .cxx_symbols .extend (mbedToolchain .CORTEX_SYMBOLS [self .target .core ])
400+
401+ # Symbols defined by the on-line build.system
402+ self .cxx_symbols .extend (['MBED_BUILD_TIMESTAMP=%s' % self .timestamp , 'TARGET_LIKE_MBED' , '__MBED__=1' ])
403+ if MBED_ORG_USER :
404+ self .cxx_symbols .append ('MBED_USERNAME=' + MBED_ORG_USER )
405+
406+ # Add target's symbols
407+ self .cxx_symbols += self .target .macros
408+ # Add target's hardware
409+ self .cxx_symbols += ["DEVICE_" + data + "=1" for data in self .target .device_has ]
410+ # Add target's features
411+ self .cxx_symbols += ["FEATURE_" + data + "=1" for data in self .target .features ]
412+ # Add extra symbols passed via 'macros' parameter
413+ self .cxx_symbols += self .macros
414+
415+ # Form factor variables
416+ if hasattr (self .target , 'supported_form_factors' ):
417+ self .cxx_symbols .extend (["TARGET_FF_%s" % t for t in self .target .supported_form_factors ])
418+
419+ return list (set (self .cxx_symbols )) # Return only unique symbols
405420
406421 # Extend the internal list of macros
407422 def add_macros (self , new_macros ):
0 commit comments