1818from builtins import str
1919
2020from os .path import splitext , basename , relpath , join , abspath , dirname ,\
21- exists
21+ exists , normpath
2222from os import remove
2323import sys
2424from subprocess import check_output , CalledProcessError , Popen , PIPE
3838def shell_escape (string ):
3939 return "" .join (SHELL_ESCAPE_TABLE .get (char , char ) for char in string )
4040
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
4150
4251class Makefile (Exporter ):
4352 """Generic Makefile template that mimics the behavior of the python build
@@ -139,12 +148,14 @@ def generate(self):
139148 # Add the virtual path the the include option in the ASM flags
140149 new_asm_flags = []
141150 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 ))
146157 else :
147- new_asm_flags .append (flag )
158+ new_asm_flags .append (_fix_include_asm_flag ( flag , ctx ) )
148159 ctx ['asm_flags' ] = new_asm_flags
149160
150161 for templatefile in \
@@ -273,33 +284,37 @@ class Armc5(Arm):
273284 NAME = 'Make-ARMc5'
274285 TOOLCHAIN = "ARM"
275286 PREPROCESS_ASM = True
276-
287+
277288 @classmethod
278289 def is_target_supported (cls , target_name ):
279290 target = TARGET_MAP [target_name ]
280-
281291 if int (target .build_tools_metadata ["version" ]) > 0 :
282292 #Although toolchain name is set to ARM above we should check for ARMC5 for 5.12/onwards
283293 if "ARMC5" not in target .supported_toolchains :
284294 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
288303
289304class Armc6 (Arm ):
290305 """ARM Compiler 6 (armclang) specific generic makefile target"""
291306 NAME = 'Make-ARMc6'
292307 TOOLCHAIN = "ARMC6"
293-
308+
294309 @classmethod
295310 def is_target_supported (cls , target_name ):
296311 target = TARGET_MAP [target_name ]
297-
312+
298313 if int (target .build_tools_metadata ["version" ]) > 0 :
299314 if not (len (set (target .supported_toolchains ).intersection (
300315 set (["ARM" , "ARMC6" ]))) > 0 ):
301316 return False
302-
317+
303318 if not apply_supported_whitelist (
304319 cls .TOOLCHAIN , cls .POST_BINARY_WHITELIST , target ):
305320 #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):
311326 else :
312327 return apply_supported_whitelist (
313328 cls .TOOLCHAIN , cls .POST_BINARY_WHITELIST , target )
314-
329+
315330
316331class IAR (Makefile ):
317332 """IAR specific makefile target"""
0 commit comments