Merge pull request #9946 from bridadan/fix_make_armc6

Fix include paths for the assembler for makefiles
pull/10043/head
Cruz Monrreal 2019-03-05 22:45:46 -06:00 committed by GitHub
commit b35b37d231
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 15 deletions

View File

@ -18,7 +18,7 @@ from __future__ import print_function, absolute_import
from builtins import str
from os.path import splitext, basename, relpath, join, abspath, dirname,\
exists
exists, normpath
from os import remove
import sys
from subprocess import check_output, CalledProcessError, Popen, PIPE
@ -38,6 +38,15 @@ SHELL_ESCAPE_TABLE = {
def shell_escape(string):
return "".join(SHELL_ESCAPE_TABLE.get(char, char) for char in string)
def _fix_include_asm_flag(flag, ctx):
if flag.startswith('-I'):
new_path = normpath(join(ctx['vpath'][0], flag[2:]))
return "-I{}".format(new_path)
elif flag.startswith('--preinclude='):
new_path = normpath(join(ctx['vpath'][0], flag[13:]))
return "--preinclude={}".format(new_path)
else:
return flag
class Makefile(Exporter):
"""Generic Makefile template that mimics the behavior of the python build
@ -139,12 +148,14 @@ class Makefile(Exporter):
# Add the virtual path the the include option in the ASM flags
new_asm_flags = []
for flag in ctx['asm_flags']:
if flag.startswith('-I'):
new_asm_flags.append("-I{}/{}".format(ctx['vpath'][0], flag[2:]))
elif flag.startswith('--preinclude='):
new_asm_flags.append("--preinclude={}/{}".format(ctx['vpath'][0], flag[13:]))
if flag.startswith('--cpreproc_opts='):
sub_flags = flag.split(',')
new_sub_flags = []
for sub_flag in sub_flags:
new_sub_flags.append(_fix_include_asm_flag(sub_flag, ctx))
new_asm_flags.append(','.join(new_sub_flags))
else:
new_asm_flags.append(flag)
new_asm_flags.append(_fix_include_asm_flag(flag, ctx))
ctx['asm_flags'] = new_asm_flags
for templatefile in \
@ -273,33 +284,37 @@ class Armc5(Arm):
NAME = 'Make-ARMc5'
TOOLCHAIN = "ARM"
PREPROCESS_ASM = True
@classmethod
def is_target_supported(cls, target_name):
target = TARGET_MAP[target_name]
if int(target.build_tools_metadata["version"]) > 0:
#Although toolchain name is set to ARM above we should check for ARMC5 for 5.12/onwards
if "ARMC5" not in target.supported_toolchains:
return False
return apply_supported_whitelist(
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target)
arm_res = apply_supported_whitelist(
"ARM", cls.POST_BINARY_WHITELIST, target
)
armc5_res = apply_supported_whitelist(
"ARMC5", cls.POST_BINARY_WHITELIST, target
)
return arm_res or armc5_res
class Armc6(Arm):
"""ARM Compiler 6 (armclang) specific generic makefile target"""
NAME = 'Make-ARMc6'
TOOLCHAIN = "ARMC6"
@classmethod
def is_target_supported(cls, target_name):
target = TARGET_MAP[target_name]
if int(target.build_tools_metadata["version"]) > 0:
if not (len(set(target.supported_toolchains).intersection(
set(["ARM", "ARMC6"]))) > 0):
return False
if not apply_supported_whitelist(
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target):
#ARMC6 is not in the list, but also check for ARM as ARM represents ARMC6 for 5.12/onwards
@ -311,7 +326,7 @@ class Armc6(Arm):
else:
return apply_supported_whitelist(
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target)
class IAR(Makefile):
"""IAR specific makefile target"""