@@ -118,8 +118,6 @@ class Uvision(Exporter):
118
118
project file (.uvprojx).
119
119
The needed information can be viewed in uvision.tmpl
120
120
"""
121
- NAME = 'uvision5'
122
- TOOLCHAIN = 'ARM'
123
121
124
122
POST_BINARY_WHITELIST = set ([
125
123
"MCU_NRF51Code.binary_hook" ,
@@ -131,22 +129,6 @@ class Uvision(Exporter):
131
129
"NCS36510TargetCode.ncs36510_addfib"
132
130
])
133
131
134
- @classmethod
135
- def is_target_supported (cls , target_name ):
136
- target = TARGET_MAP [target_name ]
137
- if not (set (target .supported_toolchains ).intersection (
138
- set (["ARM" , "uARM" ]))):
139
- return False
140
- if not DeviceCMSIS .check_supported (target_name ):
141
- return False
142
- if "Cortex-A" in target .core :
143
- return False
144
- if not hasattr (target , "post_binary_hook" ):
145
- return True
146
- if target .post_binary_hook ['function' ] in cls .POST_BINARY_WHITELIST :
147
- return True
148
- else :
149
- return False
150
132
151
133
#File associations within .uvprojx file
152
134
file_types = {'.cpp' : 8 , '.c' : 1 , '.s' : 2 ,
@@ -177,22 +159,28 @@ def uv_files(self, files):
177
159
def format_flags (self ):
178
160
"""Format toolchain flags for Uvision"""
179
161
flags = copy .deepcopy (self .flags )
180
- # to be preprocessed with armcc
181
162
asm_flag_string = (
182
163
'--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' +
183
164
"," .join (filter (lambda f : f .startswith ("-D" ), flags ['asm_flags' ])))
184
165
flags ['asm_flags' ] = asm_flag_string
185
- # All non-asm flags are in one template field
186
- c_flags = list (set (flags ['c_flags' ] + flags ['cxx_flags' ] + flags ['common_flags' ]))
187
- ld_flags = list (set (flags ['ld_flags' ] ))
188
- # These flags are in template to be set by user i n IDE
189
- template = ["--no_vla" , "--cpp" , "--c99" ]
190
- # Flag is invalid if set in template
191
- # Optimizations are also set in the template
192
- invalid_flag = lambda x : x in template or re .match ("-O(\d|time)" , x )
193
- flags ['c_flags' ] = [flag .replace ('"' ,'\\ "' ) for flag in c_flags if not invalid_flag (flag )]
194
- flags ['c_flags' ] = " " .join (flags ['c_flags' ])
195
- flags ['ld_flags' ] = " " .join (flags ['ld_flags' ])
166
+
167
+ c_flags = set (
168
+ flags ['c_flags' ] + flags ['cxx_flags' ] + flags ['common_flags' ]
169
+ )
170
+ in_template = set (
171
+ ["--no_vla" , "--cpp" , "--c99" , "-std=gnu99" , "-std=g++98" ]
172
+ )
173
+
174
+ def valid_flag (x ):
175
+ return x not in in_template or not x .startswith ("-O" )
176
+
177
+ def is_define (s ):
178
+ return s .startswith ("-D" )
179
+
180
+ flags ['c_flags' ] = " " .join (f .replace ('"' , '\\ "' ) for f in c_flags
181
+ if (valid_flag (f ) and not is_define (f )))
182
+ flags ['c_defines' ] = " " .join (f [2 :] for f in c_flags if is_define (f ))
183
+ flags ['ld_flags' ] = " " .join (set (flags ['ld_flags' ]))
196
184
return flags
197
185
198
186
def format_src (self , srcs ):
@@ -244,6 +232,8 @@ def generate(self):
244
232
else :
245
233
ctx ['fpu_setting' ] = 1
246
234
ctx ['fputype' ] = self .format_fpu (core )
235
+ ctx ['armc6' ] = int (self .TOOLCHAIN is 'ARMC6' )
236
+ ctx ['toolchain_name' ] = self .TOOLCHAIN_NAME
247
237
ctx .update (self .format_flags ())
248
238
self .gen_file ('uvision/uvision.tmpl' , ctx , self .project_name + ".uvprojx" )
249
239
self .gen_file ('uvision/uvision_debug.tmpl' , ctx , self .project_name + ".uvoptx" )
@@ -285,3 +275,54 @@ def build(project_name, log_name='build_log.txt', cleanup=True):
285
275
return - 1
286
276
else :
287
277
return 0
278
+
279
+ class UvisionArmc5 (Uvision ):
280
+ NAME = 'uvision5-armc5'
281
+ TOOLCHAIN = 'ARM'
282
+ TOOLCHAIN_NAME = ''
283
+
284
+ @classmethod
285
+ def is_target_supported (cls , target_name ):
286
+ target = TARGET_MAP [target_name ]
287
+ if not (set (target .supported_toolchains ).intersection (
288
+ set (["ARM" , "uARM" ]))):
289
+ return False
290
+ if not DeviceCMSIS .check_supported (target_name ):
291
+ return False
292
+ if "Cortex-A" in target .core :
293
+ return False
294
+ if not hasattr (target , "post_binary_hook" ):
295
+ return True
296
+ if target .post_binary_hook ['function' ] in cls .POST_BINARY_WHITELIST :
297
+ return True
298
+ else :
299
+ return False
300
+
301
+ @classmethod
302
+ def is_target_supported (cls , target_name ):
303
+ target = TARGET_MAP [target_name ]
304
+ return apply_supported_whitelist (
305
+ cls .TOOLCHAIN , cls .POST_BINARY_WHITELIST , target ) and \
306
+ DeviceCMSIS .check_supported (target_name )
307
+
308
+ class UvisionArmc6 (Uvision ):
309
+ NAME = 'uvision5-armc6'
310
+ TOOLCHAIN = 'ARMC6'
311
+ TOOLCHAIN_NAME = '6070000::V6.7::.\ARMCLANG'
312
+
313
+ @classmethod
314
+ def is_target_supported (cls , target_name ):
315
+ target = TARGET_MAP [target_name ]
316
+ if not (set (target .supported_toolchains ).intersection (
317
+ set (["ARMC6" ]))):
318
+ return False
319
+ if not DeviceCMSIS .check_supported (target_name ):
320
+ return False
321
+ if "Cortex-A" in target .core :
322
+ return False
323
+ if not hasattr (target , "post_binary_hook" ):
324
+ return True
325
+ if target .post_binary_hook ['function' ] in cls .POST_BINARY_WHITELIST :
326
+ return True
327
+ else :
328
+ return False
0 commit comments