@@ -155,27 +155,19 @@ def uv_files(self, files):
155
155
def format_flags (self ):
156
156
"""Format toolchain flags for Uvision"""
157
157
flags = copy .deepcopy (self .flags )
158
+ # to be preprocessed with armcc
158
159
asm_flag_string = '--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' + \
159
160
"," .join (flags ['asm_flags' ])
160
- # asm flags only, common are not valid within uvision project,
161
- # they are armcc specific
162
161
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' ])
179
171
return flags
180
172
181
173
def format_src (self , srcs ):
0 commit comments