Uvision and IAR working cc and asm specific defines

pull/2377/head
Sarah Marsh 2016-08-04 16:03:20 -05:00
parent 4cef2c917f
commit 70890620f7
4 changed files with 27 additions and 35 deletions

View File

@ -43,7 +43,7 @@ class Exporter(object):
self.build_url_resolver = build_url_resolver self.build_url_resolver = build_url_resolver
jinja_loader = FileSystemLoader(os.path.dirname(os.path.abspath(__file__))) jinja_loader = FileSystemLoader(os.path.dirname(os.path.abspath(__file__)))
self.jinja_environment = Environment(loader=jinja_loader) self.jinja_environment = Environment(loader=jinja_loader)
self.extra_symbols = extra_symbols self.extra_symbols = extra_symbols if extra_symbols else []
self.config_macros = [] self.config_macros = []
self.sources_relative = sources_relative self.sources_relative = sources_relative
self.config_header = None self.config_header = None
@ -59,6 +59,11 @@ class Exporter(object):
def progen_flags(self): def progen_flags(self):
if not hasattr(self, "_progen_flag_cache") : if not hasattr(self, "_progen_flag_cache") :
self._progen_flag_cache = dict([(key + "_flags", value) for key,value in self.flags.iteritems()]) self._progen_flag_cache = dict([(key + "_flags", value) for key,value in self.flags.iteritems()])
asm_defines = ["-D"+symbol for symbol in self.toolchain.get_symbols(True)]
c_defines = ["-D" + symbol for symbol in self.toolchain.get_symbols()]
self._progen_flag_cache['asm_flags'] += asm_defines
self._progen_flag_cache['c_flags'] += c_defines
self._progen_flag_cache['cxx_flags'] += c_defines
if self.config_header: if self.config_header:
self._progen_flag_cache['c_flags'] += self.toolchain.get_config_option(self.config_header) self._progen_flag_cache['c_flags'] += self.toolchain.get_config_option(self.config_header)
self._progen_flag_cache['cxx_flags'] += self.toolchain.get_config_option(self.config_header) self._progen_flag_cache['cxx_flags'] += self.toolchain.get_config_option(self.config_header)
@ -214,11 +219,16 @@ class Exporter(object):
""" This function returns symbols which must be exported. """ This function returns symbols which must be exported.
Please add / overwrite symbols in each exporter separately Please add / overwrite symbols in each exporter separately
""" """
symbols = self.toolchain.get_symbols() + self.config_macros
# We have extra symbols from e.g. libraries, we want to have them also added to export # We have extra symbols from e.g. libraries, we want to have them also added to export
if add_extra_symbols: extra = self.extra_symbols if add_extra_symbols else []
if self.extra_symbols is not None: if hasattr(self, "MBED_CONFIG_HEADER_SUPPORTED") and self.MBED_CONFIG_HEADER_SUPPORTED:
symbols.extend(self.extra_symbols) # If the config header is supported, we will preinclude it and do not not
# need the macros as preprocessor flags
return extra
symbols = self.toolchain.get_symbols(True) + self.toolchain.get_symbols() \
+ self.config_macros + extra
return symbols return symbols
def zip_working_directory_and_clean_up(tempdirectory=None, destination=None, program_name=None, clean=True): def zip_working_directory_and_clean_up(tempdirectory=None, destination=None, program_name=None, clean=True):

View File

@ -76,8 +76,6 @@ class IAREmbeddedWorkbench(Exporter):
project_data['tool_specific']['iar'].setdefault("misc", {}) project_data['tool_specific']['iar'].setdefault("misc", {})
project_data['tool_specific']['iar'].update(tool_specific['iar']) project_data['tool_specific']['iar'].update(tool_specific['iar'])
project_data['tool_specific']['iar']['misc'].update(self.progen_flags) project_data['tool_specific']['iar']['misc'].update(self.progen_flags)
project_data['tool_specific']['iar']['misc']['asm_flags'].extend(
['-D%s' % d for d in self.toolchain.get_symbols()])
# VLA is enabled via template IccAllowVLA # VLA is enabled via template IccAllowVLA
project_data['tool_specific']['iar']['misc']['c_flags'].remove("--vla") project_data['tool_specific']['iar']['misc']['c_flags'].remove("--vla")
project_data['common']['build_dir'] = os.path.join(project_data['common']['build_dir'], 'iar_arm') project_data['common']['build_dir'] = os.path.join(project_data['common']['build_dir'], 'iar_arm')

View File

@ -73,10 +73,14 @@ class Uvision4(Exporter):
# get flags from toolchain and apply # get flags from toolchain and apply
project_data['tool_specific']['uvision']['misc'] = {} project_data['tool_specific']['uvision']['misc'] = {}
# asm flags only, common are not valid within uvision project, they are armcc specific # need to make this a string for progen. Only adds preprocessor when "macros" set
project_data['tool_specific']['uvision']['misc']['asm_flags'] = list(set(self.progen_flags['asm_flags'])) asm_flag_string = '--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' + ",".join(
list(set(self.progen_flags['asm_flags'])))
project_data['tool_specific']['uvision']['misc']['asm_flags'] = [asm_flag_string]
# cxx flags included, as uvision have them all in one tab # cxx flags included, as uvision have them all in one tab
project_data['tool_specific']['uvision']['misc']['c_flags'] = list(set(self.progen_flags['common_flags'] + self.progen_flags['c_flags'] + self.progen_flags['cxx_flags'])) project_data['tool_specific']['uvision']['misc']['c_flags'] = list(set(
['-D__ASSERT_MSG'] + self.progen_flags['common_flags'] + self.progen_flags['c_flags'] + self.progen_flags[
'cxx_flags']))
# not compatible with c99 flag set in the template # not compatible with c99 flag set in the template
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--c99") project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--c99")
# cpp is not required as it's implicit for cpp files # cpp is not required as it's implicit for cpp files
@ -85,17 +89,6 @@ class Uvision4(Exporter):
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--no_vla") project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--no_vla")
project_data['tool_specific']['uvision']['misc']['ld_flags'] = self.progen_flags['ld_flags'] project_data['tool_specific']['uvision']['misc']['ld_flags'] = self.progen_flags['ld_flags']
i = 0
for macro in project_data['common']['macros']:
# armasm does not like floating numbers in macros, timestamp to int
if macro.startswith('MBED_BUILD_TIMESTAMP'):
timestamp = macro[len('MBED_BUILD_TIMESTAMP='):]
project_data['common']['macros'][i] = 'MBED_BUILD_TIMESTAMP=' + str(int(float(timestamp)))
# armasm does not even accept MACRO=string
if macro.startswith('MBED_USERNAME'):
project_data['common']['macros'].pop(i)
i += 1
project_data['common']['macros'].append('__ASSERT_MSG')
project_data['common']['build_dir'] = project_data['common']['build_dir'] + '\\' + 'uvision4' project_data['common']['build_dir'] = project_data['common']['build_dir'] + '\\' + 'uvision4'
if progen_build: if progen_build:
self.progen_gen_file('uvision', project_data, True) self.progen_gen_file('uvision', project_data, True)

View File

@ -73,10 +73,12 @@ class Uvision5(Exporter):
# get flags from toolchain and apply # get flags from toolchain and apply
project_data['tool_specific']['uvision5']['misc'] = {} project_data['tool_specific']['uvision5']['misc'] = {}
# asm flags only, common are not valid within uvision project, they are armcc specific
project_data['tool_specific']['uvision5']['misc']['asm_flags'] = list(set(self.progen_flags['asm_flags'])) # need to make this a string got progen. Only adds preprocessor when "macros" set
asm_flag_string = '--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' + ",".join(list(set(self.progen_flags['asm_flags'])))
project_data['tool_specific']['uvision5']['misc']['asm_flags'] = [asm_flag_string]
# cxx flags included, as uvision have them all in one tab # cxx flags included, as uvision have them all in one tab
project_data['tool_specific']['uvision5']['misc']['c_flags'] = list(set(self.progen_flags['common_flags'] + self.progen_flags['c_flags'] + self.progen_flags['cxx_flags'])) project_data['tool_specific']['uvision5']['misc']['c_flags'] = list(set(['-D__ASSERT_MSG']+self.progen_flags['common_flags'] + self.progen_flags['c_flags'] + self.progen_flags['cxx_flags']))
# not compatible with c99 flag set in the template # not compatible with c99 flag set in the template
project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--c99") project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--c99")
# cpp is not required as it's implicit for cpp files # cpp is not required as it's implicit for cpp files
@ -85,17 +87,6 @@ class Uvision5(Exporter):
project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--no_vla") project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--no_vla")
project_data['tool_specific']['uvision5']['misc']['ld_flags'] = self.progen_flags['ld_flags'] project_data['tool_specific']['uvision5']['misc']['ld_flags'] = self.progen_flags['ld_flags']
i = 0
for macro in project_data['common']['macros']:
# armasm does not like floating numbers in macros, timestamp to int
if macro.startswith('MBED_BUILD_TIMESTAMP'):
timestamp = macro[len('MBED_BUILD_TIMESTAMP='):]
project_data['common']['macros'][i] = 'MBED_BUILD_TIMESTAMP=' + str(int(float(timestamp)))
# armasm does not even accept MACRO=string
if macro.startswith('MBED_USERNAME'):
project_data['common']['macros'].pop(i)
i += 1
project_data['common']['macros'].append('__ASSERT_MSG')
project_data['common']['build_dir'] = project_data['common']['build_dir'] + '\\' + 'uvision5' project_data['common']['build_dir'] = project_data['common']['build_dir'] + '\\' + 'uvision5'
if progen_build: if progen_build:
self.progen_gen_file('uvision5', project_data, True) self.progen_gen_file('uvision5', project_data, True)