Skip to content

Commit

Permalink
Uvision and IAR working cc and asm specific defines
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahmarshy committed Aug 4, 2016
1 parent 4cef2c9 commit 7089062
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 35 deletions.
20 changes: 15 additions & 5 deletions tools/export/exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, target, inputDir, program_name, build_url_resolver, extra_sym
self.build_url_resolver = build_url_resolver
jinja_loader = FileSystemLoader(os.path.dirname(os.path.abspath(__file__)))
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.sources_relative = sources_relative
self.config_header = None
Expand All @@ -59,6 +59,11 @@ def flags(self):
def progen_flags(self):
if not hasattr(self, "_progen_flag_cache") :
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:
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)
Expand Down Expand Up @@ -214,11 +219,16 @@ def get_symbols(self, add_extra_symbols=True):
""" This function returns symbols which must be exported.
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
if add_extra_symbols:
if self.extra_symbols is not None:
symbols.extend(self.extra_symbols)
extra = self.extra_symbols if add_extra_symbols else []
if hasattr(self, "MBED_CONFIG_HEADER_SUPPORTED") and self.MBED_CONFIG_HEADER_SUPPORTED:
# 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

def zip_working_directory_and_clean_up(tempdirectory=None, destination=None, program_name=None, clean=True):
Expand Down
2 changes: 0 additions & 2 deletions tools/export/iar.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ def generate(self, progen_build=False):
project_data['tool_specific']['iar'].setdefault("misc", {})
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']['asm_flags'].extend(
['-D%s' % d for d in self.toolchain.get_symbols()])
# VLA is enabled via template IccAllowVLA
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')
Expand Down
21 changes: 7 additions & 14 deletions tools/export/uvision4.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,14 @@ def generate(self, progen_build=False):

# get flags from toolchain and apply
project_data['tool_specific']['uvision']['misc'] = {}
# asm flags only, common are not valid within uvision project, they are armcc specific
project_data['tool_specific']['uvision']['misc']['asm_flags'] = list(set(self.progen_flags['asm_flags']))
# need to make this a string for 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']['uvision']['misc']['asm_flags'] = [asm_flag_string]
# 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
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--c99")
# cpp is not required as it's implicit for cpp files
Expand All @@ -85,17 +89,6 @@ def generate(self, progen_build=False):
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--no_vla")
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'
if progen_build:
self.progen_gen_file('uvision', project_data, True)
Expand Down
19 changes: 5 additions & 14 deletions tools/export/uvision5.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ def generate(self, progen_build=False):

# get flags from toolchain and apply
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
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
project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--c99")
# cpp is not required as it's implicit for cpp files
Expand All @@ -85,17 +87,6 @@ def generate(self, progen_build=False):
project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--no_vla")
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'
if progen_build:
self.progen_gen_file('uvision5', project_data, True)
Expand Down

0 comments on commit 7089062

Please sign in to comment.