Skip to content

Commit 6b6187a

Browse files
committed
export: Add missing flags to Sw4STM32
Some of the optimization and warning flags, which were supported by the gnuarmeclipse exporter, were missing from the sw4stm32.
1 parent c13b80c commit 6b6187a

File tree

2 files changed

+74
-13
lines changed

2 files changed

+74
-13
lines changed

tools/export/sw4stm32/__init__.py

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,46 @@ def process_sw_options(self, opts, flags_in):
287287
opts['cpp']['preprocess'] = False
288288
if '-E' in flags_in['cxx_flags']:
289289
opts['cpp']['preprocess'] = True
290+
opts['c']['slowflashdata'] = False
291+
if '-mslow-flash-data' in flags_in['c_flags']:
292+
opts['c']['slowflashdata'] = True
293+
opts['cpp']['slowflashdata'] = False
294+
if '-mslow-flash-data' in flags_in['cxx_flags']:
295+
opts['cpp']['slowflashdata'] = True
296+
if opts['common']['optimization.messagelength']:
297+
opts['common']['optimization.other'] += ' -fmessage-length=0'
298+
if opts['common']['optimization.signedchar']:
299+
opts['common']['optimization.other'] += ' -fsigned-char'
300+
if opts['common']['optimization.nocommon']:
301+
opts['common']['optimization.other'] += ' -fno-common'
302+
if opts['common']['optimization.noinlinefunctions']:
303+
opts['common']['optimization.other'] += ' -fno-inline-functions'
304+
if opts['common']['optimization.freestanding']:
305+
opts['common']['optimization.other'] += ' -ffreestanding'
306+
if opts['common']['optimization.nobuiltin']:
307+
opts['common']['optimization.other'] += ' -fno-builtin'
308+
if opts['common']['optimization.spconstant']:
309+
opts['common']['optimization.other'] += ' -fsingle-precision-constant'
310+
if opts['common']['optimization.nomoveloopinvariants']:
311+
opts['common']['optimization.other'] += ' -fno-move-loop-invariants'
312+
if opts['common']['warnings.unused']:
313+
opts['common']['warnings.other'] += ' -Wunused'
314+
if opts['common']['warnings.uninitialized']:
315+
opts['common']['warnings.other'] += ' -Wuninitialized'
316+
if opts['common']['warnings.missingdeclaration']:
317+
opts['common']['warnings.other'] += ' -Wmissing-declarations'
318+
if opts['common']['warnings.pointerarith']:
319+
opts['common']['warnings.other'] += ' -Wpointer-arith'
320+
if opts['common']['warnings.padded']:
321+
opts['common']['warnings.other'] += ' -Wpadded'
322+
if opts['common']['warnings.shadow']:
323+
opts['common']['warnings.other'] += ' -Wshadow'
324+
if opts['common']['warnings.logicalop']:
325+
opts['common']['warnings.other'] += ' -Wlogical-op'
326+
if opts['common']['warnings.agreggatereturn']:
327+
opts['common']['warnings.other'] += ' -Waggregate-return'
328+
if opts['common']['warnings.floatequal']:
329+
opts['common']['warnings.other'] += ' -Wfloat-equal'
290330
opts['ld']['strip'] = False
291331
if '-s' in flags_in['ld_flags']:
292332
opts['ld']['strip'] = True
@@ -313,8 +353,20 @@ def process_sw_options(self, opts, flags_in):
313353
item = opts['ld']['flags'][index]
314354
if not item.startswith('-Wl,'):
315355
opts['ld']['flags'][index] = '-Wl,' + item
356+
# Strange System Workbench feature: If first parameter in Other flags is a
357+
# define (-D...), Other flags will be replaced by defines and other flags
358+
# are completely ignored. Moving -D parameters to defines.
359+
for compiler in ['c', 'cpp', 'as']:
360+
tmpList = opts[compiler]['other'].split(' ')
361+
otherList = []
362+
for item in tmpList:
363+
if item.startswith('-D'):
364+
opts[compiler]['defines'].append(str(item[2:]))
365+
else:
366+
otherList.append(item)
367+
opts[compiler]['other'] = ' '.join(otherList)
316368
# Assembler options
317-
for as_def in self.as_defines:
369+
for as_def in opts['as']['defines']:
318370
if '=' in as_def:
319371
opts['as']['other'] += ' --defsym ' + as_def
320372
else:
@@ -369,11 +421,7 @@ def generate(self):
369421

370422
lib_dirs = [self.filter_dot(s) for s in self.resources.lib_dirs]
371423

372-
preproc_cmd = ""
373-
# Hack for Windows. Build fails if command contains parentheses.
374-
preproc_cmd = '"' + \
375-
self.toolchain.preproc[0] + '"' + " " + \
376-
" ".join(self.toolchain.preproc[1:])
424+
preproc_cmd = basename(self.toolchain.preproc[0]) + " " + " ".join(self.toolchain.preproc[1:])
377425

378426
for id in ['debug', 'release']:
379427
opts = {}
@@ -418,10 +466,11 @@ def generate(self):
418466

419467
self.process_options(opts, flags)
420468

421-
self.process_sw_options(opts, flags)
422-
423469
opts['c']['defines'] = self.c_defines
424470
opts['cpp']['defines'] = self.cpp_defines
471+
opts['as']['defines'] = self.as_defines
472+
473+
self.process_sw_options(opts, flags)
425474

426475
opts['ld']['library_paths'] = [
427476
self.filter_dot(s) for s in self.resources.lib_dirs]

tools/export/sw4stm32/cproject_common.tmpl

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,14 @@
108108
{% if opts['common']['optimization.functionsections'] %}
109109
<option id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.ffunction.{{u.id}}" name="Place the function in their own section (-ffunction-sections)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.ffunction" useByScannerDiscovery="false" value="true" valueType="boolean"/>
110110
{% endif %}
111-
{% if opts['c']['other'] != '' or opts['c']['otherwarnings'] != ''%}
112-
<option id="fr.ac6.managedbuid.gnu.c.compiler.option.misc.other.{{u.id}}" name="Other flags" superClass="fr.ac6.managedbuid.gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="{{opts['c']['other']}} {{opts['c']['otherwarnings']}}" valueType="string"/>
111+
{% if opts['c']['otheroptimizations'] != '' or opts['common']['optimization.other'] != '' %}
112+
<option id="gnu.c.compiler.option.optimization.flags.{{u.id}}" superClass="gnu.c.compiler.option.optimization.flags" useByScannerDiscovery="false" value="{{opts['c']['otheroptimizations']}} {{opts['common']['optimization.other']}}" valueType="string"/>
113+
{% endif %}
114+
{% if opts['c']['other'] != '' or opts['c']['otherwarnings'] != '' or opts['common']['warnings.other'] != '' %}
115+
<option id="fr.ac6.managedbuid.gnu.c.compiler.option.misc.other.{{u.id}}" name="Other flags" superClass="fr.ac6.managedbuid.gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="{{opts['c']['other']}} {{opts['c']['otherwarnings']}} {{opts['common']['warnings.other']}}" valueType="string"/>
116+
{% endif %}
117+
{% if opts['c']['slowflashdata'] %}
118+
<option id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.pcrop.{{u.id}}" name="No data reads in code memory (-mslow-flash-data) " superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.pcrop" useByScannerDiscovery="false" value="true" valueType="boolean"/>
113119
{% endif %}
114120
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c.{{opts['uid']['tool_c_compiler_input']}}" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.c"/>
115121
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s.{{u.id}}" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.input.s"/>
@@ -191,8 +197,14 @@
191197
{% if opts['common']['optimization.functionsections'] %}
192198
<option id="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.ffunction.{{u.id}}" name="Place the function in their own section (-ffunction-sections)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.compiler.ffunction" useByScannerDiscovery="false" value="true" valueType="boolean"/>
193199
{% endif %}
194-
{% if opts['cpp']['other'] != '' or opts['cpp']['otherwarnings'] != ''%}
195-
<option id="fr.ac6.managedbuild.gnu.cpp.compiler.option.misc.other.{{u.id}}" name="Other flags" superClass="fr.ac6.managedbuild.gnu.cpp.compiler.option.misc.other" useByScannerDiscovery="false" value="{{opts['cpp']['other']}} {{opts['cpp']['otherwarnings']}}" valueType="string"/>
200+
{% if opts['cpp']['otheroptimizations'] != '' or opts['common']['optimization.other'] != '' %}
201+
<option id="gnu.cpp.compiler.option.optimization.flags.{{u.id}}" superClass="gnu.cpp.compiler.option.optimization.flags" useByScannerDiscovery="false" value="{{opts['cpp']['otheroptimizations']}} {{opts['common']['optimization.other']}}" valueType="string"/>
202+
{% endif %}
203+
{% if opts['cpp']['other'] != '' or opts['cpp']['otherwarnings'] != '' or opts['common']['warnings.other'] != '' %}
204+
<option id="fr.ac6.managedbuild.gnu.cpp.compiler.option.misc.other.{{u.id}}" name="Other flags" superClass="fr.ac6.managedbuild.gnu.cpp.compiler.option.misc.other" useByScannerDiscovery="false" value="{{opts['cpp']['other']}} {{opts['cpp']['otherwarnings']}} {{opts['common']['warnings.other']}}" valueType="string"/>
205+
{% endif %}
206+
{% if opts['cpp']['slowflashdata'] %}
207+
<option id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.pcrop.{{u.id}}" name="No data reads in code memory (-mslow-flash-data) " superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.pcrop" useByScannerDiscovery="false" value="true" valueType="boolean"/>
196208
{% endif %}
197209
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.cpp.{{opts['uid']['tool_cpp_compiler_input']}}" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.cpp"/>
198210
<inputType id="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.s.{{u.id}}" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.compiler.input.s"/>
@@ -262,7 +274,7 @@
262274
<listOptionValue builtIn="false" value="&quot;{{path}}&quot;"/>
263275
{% endfor %}
264276
</option>
265-
{% if opts['as']['other'] != '' or opts['as']['otherwarnings'] != ''%}
277+
{% if opts['as']['other'] != '' or opts['as']['otherwarnings'] != '' %}
266278
<option id="gnu.both.asm.option.flags.{{u.id}}" superClass="gnu.both.asm.option.flags" useByScannerDiscovery="false" value="{{opts['as']['other']}} {{opts['as']['otherwarnings']}}" valueType="string"/>
267279
{% endif %}
268280
{% for item in opts['as']['otherwarnings'] %}

0 commit comments

Comments
 (0)