Skip to content

Commit 04a31f3

Browse files
authored
Merge pull request ARMmbed#3534 from sarahmarshy/export-debug
Turn on debugging by default when exporting. Remove optimizations for IAR and Uvision
2 parents e592c8a + 2bf1f6b commit 04a31f3

File tree

5 files changed

+21
-30
lines changed

5 files changed

+21
-30
lines changed

tools/export/iar/__init__.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,15 @@ def generate(self):
8989
self.resources.c_sources + self.resources.cpp_sources + \
9090
self.resources.objects + self.resources.libraries
9191
flags = self.flags
92-
flags['c_flags'] = list(set(flags['common_flags']
92+
c_flags = list(set(flags['common_flags']
9393
+ flags['c_flags']
9494
+ flags['cxx_flags']))
95-
if '--vla' in flags['c_flags']:
96-
flags['c_flags'].remove('--vla')
97-
if '--no_static_destruction' in flags['c_flags']:
98-
flags['c_flags'].remove('--no_static_destruction')
99-
#Optimizations
100-
if '-Oh' in flags['c_flags']:
101-
flags['c_flags'].remove('-Oh')
95+
# Flags set in template to be set by user in IDE
96+
template = ["--vla", "--no_static_destruction"]
97+
# Flag invalid if set in template
98+
# Optimizations are also set in template
99+
invalid_flag = lambda x: x in template or re.match("-O(\d|time|n)", x)
100+
flags['c_flags'] = [flag for flag in c_flags if not invalid_flag(flag)]
102101

103102
try:
104103
debugger = DeviceCMSIS(self.target).debug.replace('-','').upper()

tools/export/uvision/__init__.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -155,27 +155,19 @@ def uv_files(self, files):
155155
def format_flags(self):
156156
"""Format toolchain flags for Uvision"""
157157
flags = copy.deepcopy(self.flags)
158+
# to be preprocessed with armcc
158159
asm_flag_string = '--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' + \
159160
",".join(flags['asm_flags'])
160-
# asm flags only, common are not valid within uvision project,
161-
# they are armcc specific
162161
flags['asm_flags'] = asm_flag_string
163-
# cxx flags included, as uvision have them all in one tab
164-
flags['c_flags'] = list(set(['-D__ASSERT_MSG']
165-
+ flags['common_flags']
166-
+ flags['c_flags']
167-
+ flags['cxx_flags']))
168-
# not compatible with c99 flag set in the template
169-
try: flags['c_flags'].remove("--c99")
170-
except ValueError: pass
171-
# cpp is not required as it's implicit for cpp files
172-
try: flags['c_flags'].remove("--cpp")
173-
except ValueError: pass
174-
# we want no-vla for only cxx, but it's also applied for C in IDE,
175-
# thus we remove it
176-
try: flags['c_flags'].remove("--no_vla")
177-
except ValueError: pass
178-
flags['c_flags'] =" ".join(flags['c_flags'])
162+
# All non-asm flags are in one template field
163+
c_flags = list(set(flags['c_flags'] + flags['cxx_flags'] +flags['common_flags']))
164+
# These flags are in template to be set by user i n IDE
165+
template = ["--no_vla", "--cpp", "--c99"]
166+
# Flag is invalid if set in template
167+
# Optimizations are also set in the template
168+
invalid_flag = lambda x: x in template or re.match("-O(\d|time)", x)
169+
flags['c_flags'] = [flag for flag in c_flags if not invalid_flag(flag)]
170+
flags['c_flags'] = " ".join(flags['c_flags'])
179171
return flags
180172

181173
def format_src(self, srcs):

tools/export/uvision/uvision.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@
351351
</ArmAdsMisc>
352352
<Cads>
353353
<interw>0</interw>
354-
<Optim>2</Optim>
354+
<Optim>1</Optim>
355355
<oTime>0</oTime>
356356
<SplitLS>0</SplitLS>
357357
<OneElfS>0</OneElfS>

tools/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def list_profiles():
100100
"""
101101
return [fn.replace(".json", "") for fn in listdir(join(dirname(__file__), "profiles")) if fn.endswith(".json")]
102102

103-
def extract_profile(parser, options, toolchain):
103+
def extract_profile(parser, options, toolchain, fallback="default"):
104104
"""Extract a Toolchain profile from parsed options
105105
106106
Positional arguments:
@@ -110,7 +110,7 @@ def extract_profile(parser, options, toolchain):
110110
"""
111111
profile = {'c': [], 'cxx': [], 'ld': [], 'common': [], 'asm': []}
112112
filenames = options.profile or [join(dirname(__file__), "profiles",
113-
"default.json")]
113+
fallback + ".json")]
114114
for filename in filenames:
115115
contents = load(open(filename))
116116
try:

tools/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def main():
235235
exporter, toolchain_name = get_exporter_toolchain(options.ide)
236236
if options.mcu not in exporter.TARGETS:
237237
args_error(parser, "%s not supported by %s"%(options.mcu,options.ide))
238-
profile = extract_profile(parser, options, toolchain_name)
238+
profile = extract_profile(parser, options, toolchain_name, fallback="debug")
239239
if options.clean:
240240
rmtree(BUILD_DIR)
241241
export(options.mcu, options.ide, build=options.build,

0 commit comments

Comments
 (0)