Skip to content

Commit 7089062

Browse files
committed
Uvision and IAR working cc and asm specific defines
1 parent 4cef2c9 commit 7089062

File tree

4 files changed

+27
-35
lines changed

4 files changed

+27
-35
lines changed

tools/export/exporters.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, target, inputDir, program_name, build_url_resolver, extra_sym
4343
self.build_url_resolver = build_url_resolver
4444
jinja_loader = FileSystemLoader(os.path.dirname(os.path.abspath(__file__)))
4545
self.jinja_environment = Environment(loader=jinja_loader)
46-
self.extra_symbols = extra_symbols
46+
self.extra_symbols = extra_symbols if extra_symbols else []
4747
self.config_macros = []
4848
self.sources_relative = sources_relative
4949
self.config_header = None
@@ -59,6 +59,11 @@ def flags(self):
5959
def progen_flags(self):
6060
if not hasattr(self, "_progen_flag_cache") :
6161
self._progen_flag_cache = dict([(key + "_flags", value) for key,value in self.flags.iteritems()])
62+
asm_defines = ["-D"+symbol for symbol in self.toolchain.get_symbols(True)]
63+
c_defines = ["-D" + symbol for symbol in self.toolchain.get_symbols()]
64+
self._progen_flag_cache['asm_flags'] += asm_defines
65+
self._progen_flag_cache['c_flags'] += c_defines
66+
self._progen_flag_cache['cxx_flags'] += c_defines
6267
if self.config_header:
6368
self._progen_flag_cache['c_flags'] += self.toolchain.get_config_option(self.config_header)
6469
self._progen_flag_cache['cxx_flags'] += self.toolchain.get_config_option(self.config_header)
@@ -214,11 +219,16 @@ def get_symbols(self, add_extra_symbols=True):
214219
""" This function returns symbols which must be exported.
215220
Please add / overwrite symbols in each exporter separately
216221
"""
217-
symbols = self.toolchain.get_symbols() + self.config_macros
222+
218223
# We have extra symbols from e.g. libraries, we want to have them also added to export
219-
if add_extra_symbols:
220-
if self.extra_symbols is not None:
221-
symbols.extend(self.extra_symbols)
224+
extra = self.extra_symbols if add_extra_symbols else []
225+
if hasattr(self, "MBED_CONFIG_HEADER_SUPPORTED") and self.MBED_CONFIG_HEADER_SUPPORTED:
226+
# If the config header is supported, we will preinclude it and do not not
227+
# need the macros as preprocessor flags
228+
return extra
229+
230+
symbols = self.toolchain.get_symbols(True) + self.toolchain.get_symbols() \
231+
+ self.config_macros + extra
222232
return symbols
223233

224234
def zip_working_directory_and_clean_up(tempdirectory=None, destination=None, program_name=None, clean=True):

tools/export/iar.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ def generate(self, progen_build=False):
7676
project_data['tool_specific']['iar'].setdefault("misc", {})
7777
project_data['tool_specific']['iar'].update(tool_specific['iar'])
7878
project_data['tool_specific']['iar']['misc'].update(self.progen_flags)
79-
project_data['tool_specific']['iar']['misc']['asm_flags'].extend(
80-
['-D%s' % d for d in self.toolchain.get_symbols()])
8179
# VLA is enabled via template IccAllowVLA
8280
project_data['tool_specific']['iar']['misc']['c_flags'].remove("--vla")
8381
project_data['common']['build_dir'] = os.path.join(project_data['common']['build_dir'], 'iar_arm')

tools/export/uvision4.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,14 @@ def generate(self, progen_build=False):
7373

7474
# get flags from toolchain and apply
7575
project_data['tool_specific']['uvision']['misc'] = {}
76-
# asm flags only, common are not valid within uvision project, they are armcc specific
77-
project_data['tool_specific']['uvision']['misc']['asm_flags'] = list(set(self.progen_flags['asm_flags']))
76+
# need to make this a string for progen. Only adds preprocessor when "macros" set
77+
asm_flag_string = '--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' + ",".join(
78+
list(set(self.progen_flags['asm_flags'])))
79+
project_data['tool_specific']['uvision']['misc']['asm_flags'] = [asm_flag_string]
7880
# cxx flags included, as uvision have them all in one tab
79-
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']))
81+
project_data['tool_specific']['uvision']['misc']['c_flags'] = list(set(
82+
['-D__ASSERT_MSG'] + self.progen_flags['common_flags'] + self.progen_flags['c_flags'] + self.progen_flags[
83+
'cxx_flags']))
8084
# not compatible with c99 flag set in the template
8185
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--c99")
8286
# cpp is not required as it's implicit for cpp files
@@ -85,17 +89,6 @@ def generate(self, progen_build=False):
8589
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--no_vla")
8690
project_data['tool_specific']['uvision']['misc']['ld_flags'] = self.progen_flags['ld_flags']
8791

88-
i = 0
89-
for macro in project_data['common']['macros']:
90-
# armasm does not like floating numbers in macros, timestamp to int
91-
if macro.startswith('MBED_BUILD_TIMESTAMP'):
92-
timestamp = macro[len('MBED_BUILD_TIMESTAMP='):]
93-
project_data['common']['macros'][i] = 'MBED_BUILD_TIMESTAMP=' + str(int(float(timestamp)))
94-
# armasm does not even accept MACRO=string
95-
if macro.startswith('MBED_USERNAME'):
96-
project_data['common']['macros'].pop(i)
97-
i += 1
98-
project_data['common']['macros'].append('__ASSERT_MSG')
9992
project_data['common']['build_dir'] = project_data['common']['build_dir'] + '\\' + 'uvision4'
10093
if progen_build:
10194
self.progen_gen_file('uvision', project_data, True)

tools/export/uvision5.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ def generate(self, progen_build=False):
7373

7474
# get flags from toolchain and apply
7575
project_data['tool_specific']['uvision5']['misc'] = {}
76-
# asm flags only, common are not valid within uvision project, they are armcc specific
77-
project_data['tool_specific']['uvision5']['misc']['asm_flags'] = list(set(self.progen_flags['asm_flags']))
76+
77+
# need to make this a string got progen. Only adds preprocessor when "macros" set
78+
asm_flag_string = '--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' + ",".join(list(set(self.progen_flags['asm_flags'])))
79+
project_data['tool_specific']['uvision5']['misc']['asm_flags'] = [asm_flag_string]
7880
# cxx flags included, as uvision have them all in one tab
79-
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']))
81+
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']))
8082
# not compatible with c99 flag set in the template
8183
project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--c99")
8284
# cpp is not required as it's implicit for cpp files
@@ -85,17 +87,6 @@ def generate(self, progen_build=False):
8587
project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--no_vla")
8688
project_data['tool_specific']['uvision5']['misc']['ld_flags'] = self.progen_flags['ld_flags']
8789

88-
i = 0
89-
for macro in project_data['common']['macros']:
90-
# armasm does not like floating numbers in macros, timestamp to int
91-
if macro.startswith('MBED_BUILD_TIMESTAMP'):
92-
timestamp = macro[len('MBED_BUILD_TIMESTAMP='):]
93-
project_data['common']['macros'][i] = 'MBED_BUILD_TIMESTAMP=' + str(int(float(timestamp)))
94-
# armasm does not even accept MACRO=string
95-
if macro.startswith('MBED_USERNAME'):
96-
project_data['common']['macros'].pop(i)
97-
i += 1
98-
project_data['common']['macros'].append('__ASSERT_MSG')
9990
project_data['common']['build_dir'] = project_data['common']['build_dir'] + '\\' + 'uvision5'
10091
if progen_build:
10192
self.progen_gen_file('uvision5', project_data, True)

0 commit comments

Comments
 (0)