18
18
from builtins import str
19
19
20
20
from os .path import splitext , basename , relpath , join , abspath , dirname ,\
21
- exists
21
+ exists , normpath
22
22
from os import remove
23
23
import sys
24
24
from subprocess import check_output , CalledProcessError , Popen , PIPE
38
38
def shell_escape (string ):
39
39
return "" .join (SHELL_ESCAPE_TABLE .get (char , char ) for char in string )
40
40
41
+ def _fix_include_asm_flag (flag , ctx ):
42
+ if flag .startswith ('-I' ):
43
+ new_path = normpath (join (ctx ['vpath' ][0 ], flag [2 :]))
44
+ return "-I{}" .format (new_path )
45
+ elif flag .startswith ('--preinclude=' ):
46
+ new_path = normpath (join (ctx ['vpath' ][0 ], flag [13 :]))
47
+ return "--preinclude={}" .format (new_path )
48
+ else :
49
+ return flag
41
50
42
51
class Makefile (Exporter ):
43
52
"""Generic Makefile template that mimics the behavior of the python build
@@ -139,12 +148,14 @@ def generate(self):
139
148
# Add the virtual path the the include option in the ASM flags
140
149
new_asm_flags = []
141
150
for flag in ctx ['asm_flags' ]:
142
- if flag .startswith ('-I' ):
143
- new_asm_flags .append ("-I{}/{}" .format (ctx ['vpath' ][0 ], flag [2 :]))
144
- elif flag .startswith ('--preinclude=' ):
145
- new_asm_flags .append ("--preinclude={}/{}" .format (ctx ['vpath' ][0 ], flag [13 :]))
151
+ if flag .startswith ('--cpreproc_opts=' ):
152
+ sub_flags = flag .split (',' )
153
+ new_sub_flags = []
154
+ for sub_flag in sub_flags :
155
+ new_sub_flags .append (_fix_include_asm_flag (sub_flag , ctx ))
156
+ new_asm_flags .append (',' .join (new_sub_flags ))
146
157
else :
147
- new_asm_flags .append (flag )
158
+ new_asm_flags .append (_fix_include_asm_flag ( flag , ctx ) )
148
159
ctx ['asm_flags' ] = new_asm_flags
149
160
150
161
for templatefile in \
@@ -273,33 +284,37 @@ class Armc5(Arm):
273
284
NAME = 'Make-ARMc5'
274
285
TOOLCHAIN = "ARM"
275
286
PREPROCESS_ASM = True
276
-
287
+
277
288
@classmethod
278
289
def is_target_supported (cls , target_name ):
279
290
target = TARGET_MAP [target_name ]
280
-
281
291
if int (target .build_tools_metadata ["version" ]) > 0 :
282
292
#Although toolchain name is set to ARM above we should check for ARMC5 for 5.12/onwards
283
293
if "ARMC5" not in target .supported_toolchains :
284
294
return False
285
-
286
- return apply_supported_whitelist (
287
- cls .TOOLCHAIN , cls .POST_BINARY_WHITELIST , target )
295
+
296
+ arm_res = apply_supported_whitelist (
297
+ "ARM" , cls .POST_BINARY_WHITELIST , target
298
+ )
299
+ armc5_res = apply_supported_whitelist (
300
+ "ARMC5" , cls .POST_BINARY_WHITELIST , target
301
+ )
302
+ return arm_res or armc5_res
288
303
289
304
class Armc6 (Arm ):
290
305
"""ARM Compiler 6 (armclang) specific generic makefile target"""
291
306
NAME = 'Make-ARMc6'
292
307
TOOLCHAIN = "ARMC6"
293
-
308
+
294
309
@classmethod
295
310
def is_target_supported (cls , target_name ):
296
311
target = TARGET_MAP [target_name ]
297
-
312
+
298
313
if int (target .build_tools_metadata ["version" ]) > 0 :
299
314
if not (len (set (target .supported_toolchains ).intersection (
300
315
set (["ARM" , "ARMC6" ]))) > 0 ):
301
316
return False
302
-
317
+
303
318
if not apply_supported_whitelist (
304
319
cls .TOOLCHAIN , cls .POST_BINARY_WHITELIST , target ):
305
320
#ARMC6 is not in the list, but also check for ARM as ARM represents ARMC6 for 5.12/onwards
@@ -311,7 +326,7 @@ def is_target_supported(cls, target_name):
311
326
else :
312
327
return apply_supported_whitelist (
313
328
cls .TOOLCHAIN , cls .POST_BINARY_WHITELIST , target )
314
-
329
+
315
330
316
331
class IAR (Makefile ):
317
332
"""IAR specific makefile target"""
0 commit comments