mirror of https://github.com/ARMmbed/mbed-os.git
Differentiate ASM and CXX symbols as they are not treated the same in ARMCC and IAR compilers
parent
68d48ea541
commit
88564a9ac3
|
@ -230,7 +230,8 @@ class mbedToolchain:
|
||||||
self.macros = macros or []
|
self.macros = macros or []
|
||||||
|
|
||||||
# Macros generated from toolchain and target rules/features
|
# Macros generated from toolchain and target rules/features
|
||||||
self.symbols = None
|
self.asm_symbols = None
|
||||||
|
self.cxx_symbols = None
|
||||||
|
|
||||||
# Labels generated from toolchain and target rules/features (used for selective build)
|
# Labels generated from toolchain and target rules/features (used for selective build)
|
||||||
self.labels = None
|
self.labels = None
|
||||||
|
@ -372,36 +373,50 @@ class mbedToolchain:
|
||||||
event['toolchain'] = self
|
event['toolchain'] = self
|
||||||
return self.notify_fun(event, self.silent)
|
return self.notify_fun(event, self.silent)
|
||||||
|
|
||||||
def get_symbols(self):
|
def get_symbols(self, for_asm=False):
|
||||||
if self.symbols is None:
|
if for_asm:
|
||||||
# Target and Toolchain symbols
|
if self.asm_symbols is None:
|
||||||
labels = self.get_labels()
|
self.asm_symbols = []
|
||||||
self.symbols = ["TARGET_%s" % t for t in labels['TARGET']]
|
|
||||||
self.symbols.extend(["TOOLCHAIN_%s" % t for t in labels['TOOLCHAIN']])
|
|
||||||
|
|
||||||
# Cortex CPU symbols
|
# Cortex CPU symbols
|
||||||
if self.target.core in mbedToolchain.CORTEX_SYMBOLS:
|
if self.target.core in mbedToolchain.CORTEX_SYMBOLS:
|
||||||
self.symbols.extend(mbedToolchain.CORTEX_SYMBOLS[self.target.core])
|
self.asm_symbols.extend(mbedToolchain.CORTEX_SYMBOLS[self.target.core])
|
||||||
|
|
||||||
# Symbols defined by the on-line build.system
|
# Add target's symbols
|
||||||
self.symbols.extend(['MBED_BUILD_TIMESTAMP=%s' % self.timestamp, 'TARGET_LIKE_MBED', '__MBED__=1'])
|
self.asm_symbols += self.target.macros
|
||||||
if MBED_ORG_USER:
|
# Add extra symbols passed via 'macros' parameter
|
||||||
self.symbols.append('MBED_USERNAME=' + MBED_ORG_USER)
|
self.asm_symbols += self.macros
|
||||||
|
return list(set(self.asm_symbols)) # Return only unique symbols
|
||||||
|
else:
|
||||||
|
if self.cxx_symbols is None:
|
||||||
|
# Target and Toolchain symbols
|
||||||
|
labels = self.get_labels()
|
||||||
|
self.cxx_symbols = ["TARGET_%s" % t for t in labels['TARGET']]
|
||||||
|
self.cxx_symbols.extend(["TOOLCHAIN_%s" % t for t in labels['TOOLCHAIN']])
|
||||||
|
|
||||||
# Add target's symbols
|
# Cortex CPU symbols
|
||||||
self.symbols += self.target.macros
|
if self.target.core in mbedToolchain.CORTEX_SYMBOLS:
|
||||||
# Add target's hardware
|
self.cxx_symbols.extend(mbedToolchain.CORTEX_SYMBOLS[self.target.core])
|
||||||
self.symbols += ["DEVICE_" + data + "=1" for data in self.target.device_has]
|
|
||||||
# Add target's features
|
|
||||||
self.symbols += ["FEATURE_" + data + "=1" for data in self.target.features]
|
|
||||||
# Add extra symbols passed via 'macros' parameter
|
|
||||||
self.symbols += self.macros
|
|
||||||
|
|
||||||
# Form factor variables
|
# Symbols defined by the on-line build.system
|
||||||
if hasattr(self.target, 'supported_form_factors'):
|
self.cxx_symbols.extend(['MBED_BUILD_TIMESTAMP=%s' % self.timestamp, 'TARGET_LIKE_MBED', '__MBED__=1'])
|
||||||
self.symbols.extend(["TARGET_FF_%s" % t for t in self.target.supported_form_factors])
|
if MBED_ORG_USER:
|
||||||
|
self.cxx_symbols.append('MBED_USERNAME=' + MBED_ORG_USER)
|
||||||
|
|
||||||
return list(set(self.symbols)) # Return only unique symbols
|
# Add target's symbols
|
||||||
|
self.cxx_symbols += self.target.macros
|
||||||
|
# Add target's hardware
|
||||||
|
self.cxx_symbols += ["DEVICE_" + data + "=1" for data in self.target.device_has]
|
||||||
|
# Add target's features
|
||||||
|
self.cxx_symbols += ["FEATURE_" + data + "=1" for data in self.target.features]
|
||||||
|
# Add extra symbols passed via 'macros' parameter
|
||||||
|
self.cxx_symbols += self.macros
|
||||||
|
|
||||||
|
# Form factor variables
|
||||||
|
if hasattr(self.target, 'supported_form_factors'):
|
||||||
|
self.cxx_symbols.extend(["TARGET_FF_%s" % t for t in self.target.supported_form_factors])
|
||||||
|
|
||||||
|
return list(set(self.cxx_symbols)) # Return only unique symbols
|
||||||
|
|
||||||
# Extend the internal list of macros
|
# Extend the internal list of macros
|
||||||
def add_macros(self, new_macros):
|
def add_macros(self, new_macros):
|
||||||
|
|
|
@ -128,16 +128,17 @@ class ARM(mbedToolchain):
|
||||||
def get_config_option(self, config_header):
|
def get_config_option(self, config_header):
|
||||||
return ['--preinclude=' + config_header]
|
return ['--preinclude=' + config_header]
|
||||||
|
|
||||||
def get_compile_options(self, defines, includes):
|
def get_compile_options(self, defines, includes, for_asm=False):
|
||||||
opts = ['-D%s' % d for d in defines]
|
opts = ['-D%s' % d for d in defines]
|
||||||
if self.RESPONSE_FILES:
|
if self.RESPONSE_FILES:
|
||||||
opts += ['--via', self.get_inc_file(includes)]
|
opts += ['--via', self.get_inc_file(includes)]
|
||||||
else:
|
else:
|
||||||
opts += ["-I%s" % i for i in includes]
|
opts += ["-I%s" % i for i in includes]
|
||||||
|
|
||||||
config_header = self.get_config_header()
|
if not for_asm:
|
||||||
if config_header is not None:
|
config_header = self.get_config_header()
|
||||||
opts = opts + self.get_config_option(config_header)
|
if config_header is not None:
|
||||||
|
opts = opts + self.get_config_option(config_header)
|
||||||
return opts
|
return opts
|
||||||
|
|
||||||
@hook_tool
|
@hook_tool
|
||||||
|
@ -148,7 +149,7 @@ class ARM(mbedToolchain):
|
||||||
tempfile = join(dir, basename(object) + '.E.s')
|
tempfile = join(dir, basename(object) + '.E.s')
|
||||||
|
|
||||||
# Build preprocess assemble command
|
# Build preprocess assemble command
|
||||||
cmd_pre = self.asm + self.get_compile_options(self.get_symbols(), includes) + ["-E", "-o", tempfile, source]
|
cmd_pre = self.asm + self.get_compile_options(self.get_symbols(True), includes) + ["-E", "-o", tempfile, source]
|
||||||
|
|
||||||
# Build main assemble command
|
# Build main assemble command
|
||||||
cmd = self.asm + ["-o", object, tempfile]
|
cmd = self.asm + ["-o", object, tempfile]
|
||||||
|
|
|
@ -170,22 +170,23 @@ class GCC(mbedToolchain):
|
||||||
def get_config_option(self, config_header):
|
def get_config_option(self, config_header):
|
||||||
return ['-include', config_header]
|
return ['-include', config_header]
|
||||||
|
|
||||||
def get_compile_options(self, defines, includes):
|
def get_compile_options(self, defines, includes, for_asm=False):
|
||||||
opts = ['-D%s' % d for d in defines]
|
opts = ['-D%s' % d for d in defines]
|
||||||
if self.RESPONSE_FILES:
|
if self.RESPONSE_FILES:
|
||||||
opts += ['@%s' % self.get_inc_file(includes)]
|
opts += ['@%s' % self.get_inc_file(includes)]
|
||||||
else:
|
else:
|
||||||
opts += ["-I%s" % i for i in includes]
|
opts += ["-I%s" % i for i in includes]
|
||||||
|
|
||||||
config_header = self.get_config_header()
|
if not for_asm:
|
||||||
if config_header is not None:
|
config_header = self.get_config_header()
|
||||||
opts = opts + self.get_config_option(config_header)
|
if config_header is not None:
|
||||||
|
opts = opts + self.get_config_option(config_header)
|
||||||
return opts
|
return opts
|
||||||
|
|
||||||
@hook_tool
|
@hook_tool
|
||||||
def assemble(self, source, object, includes):
|
def assemble(self, source, object, includes):
|
||||||
# Build assemble command
|
# Build assemble command
|
||||||
cmd = self.asm + self.get_compile_options(self.get_symbols(), includes) + ["-o", object, source]
|
cmd = self.asm + self.get_compile_options(self.get_symbols(True), includes) + ["-o", object, source]
|
||||||
|
|
||||||
# Call cmdline hook
|
# Call cmdline hook
|
||||||
cmd = self.hook.get_cmdline_assembler(cmd)
|
cmd = self.hook.get_cmdline_assembler(cmd)
|
||||||
|
|
|
@ -151,12 +151,7 @@ class IAR(mbedToolchain):
|
||||||
else:
|
else:
|
||||||
opts += ["-I%s" % i for i in includes]
|
opts += ["-I%s" % i for i in includes]
|
||||||
|
|
||||||
config_header = self.get_config_header()
|
if not for_asm:
|
||||||
if for_asm:
|
|
||||||
# The assembler doesn't support '--preinclude', so we need to add
|
|
||||||
# the macros directly
|
|
||||||
opts = opts + ['-D%s' % d for d in self.get_config_macros()]
|
|
||||||
else:
|
|
||||||
config_header = self.get_config_header()
|
config_header = self.get_config_header()
|
||||||
if config_header is not None:
|
if config_header is not None:
|
||||||
opts = opts + self.get_config_option(config_header)
|
opts = opts + self.get_config_option(config_header)
|
||||||
|
@ -165,7 +160,7 @@ class IAR(mbedToolchain):
|
||||||
@hook_tool
|
@hook_tool
|
||||||
def assemble(self, source, object, includes):
|
def assemble(self, source, object, includes):
|
||||||
# Build assemble command
|
# Build assemble command
|
||||||
cmd = self.asm + self.get_compile_options(self.get_symbols(), includes, for_asm=True) + ["-o", object, source]
|
cmd = self.asm + self.get_compile_options(self.get_symbols(True), includes, True) + ["-o", object, source]
|
||||||
|
|
||||||
# Call cmdline hook
|
# Call cmdline hook
|
||||||
cmd = self.hook.get_cmdline_assembler(cmd)
|
cmd = self.hook.get_cmdline_assembler(cmd)
|
||||||
|
|
Loading…
Reference in New Issue