Skip to content

Fix include paths for the assembler for makefiles #9946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions tools/export/makefile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
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
Expand All @@ -38,6 +38,15 @@
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
Expand Down Expand Up @@ -139,12 +148,14 @@ def generate(self):
# 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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one question - how does this fixes the issue - why paths for asm preprocessed files were not correct? I can see magic above based on -I or preinclude - shall we add some details to the commit msg?

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 \
Expand Down Expand Up @@ -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
Expand All @@ -311,7 +326,7 @@ def is_target_supported(cls, target_name):
else:
return apply_supported_whitelist(
cls.TOOLCHAIN, cls.POST_BINARY_WHITELIST, target)


class IAR(Makefile):
"""IAR specific makefile target"""
Expand Down