Clone of official tools
Diff: export/makefile/__init__.py
- Revision:
- 36:96847d42f010
- Parent:
- 35:da9c89f8be7d
- Child:
- 40:7d3fa6b99b2b
--- a/export/makefile/__init__.py Wed Feb 15 13:53:18 2017 -0600 +++ b/export/makefile/__init__.py Thu Jun 22 11:12:28 2017 -0500 @@ -21,7 +21,7 @@ from subprocess import check_output, CalledProcessError, Popen, PIPE import shutil from jinja2.exceptions import TemplateNotFound -from tools.export.exporters import Exporter +from tools.export.exporters import Exporter, filter_supported from tools.utils import NotSupportedException from tools.targets import TARGET_MAP @@ -35,6 +35,13 @@ MBED_CONFIG_HEADER_SUPPORTED = True + POST_BINARY_WHITELIST = set([ + "MCU_NRF51Code.binary_hook", + "TEENSY3_1Code.binary_hook", + "LPCTargetCode.lpc_patch", + "LPC4088Code.binary_hook" + ]) + def generate(self): """Generate the makefile @@ -78,15 +85,21 @@ 'asm_cmd': " ".join(["\'" + part + "\'" for part in ([basename(self.toolchain.asm[0])] + self.toolchain.asm[1:])]), - 'ld_cmd': " ".join(["\'" + part + "\'" for part - in ([basename(self.toolchain.ld[0])] + - self.toolchain.ld[1:])]), + 'ld_cmd': "\'" + basename(self.toolchain.ld[0]) + "\'", 'elf2bin_cmd': "\'" + basename(self.toolchain.elf2bin) + "\'", 'link_script_ext': self.toolchain.LINKER_EXT, 'link_script_option': self.LINK_SCRIPT_OPTION, 'user_library_flag': self.USER_LIBRARY_FLAG, } + if hasattr(self.toolchain, "preproc"): + ctx['pp_cmd'] = " ".join(["\'" + part + "\'" for part + in ([basename(self.toolchain.preproc[0])] + + self.toolchain.preproc[1:] + + self.toolchain.ld[1:])]) + else: + ctx['pp_cmd'] = None + for key in ['include_paths', 'library_paths', 'linker_script', 'hex_files']: if isinstance(ctx[key], list): @@ -98,7 +111,7 @@ for key in ['include_paths', 'library_paths', 'hex_files', 'to_be_compiled']: ctx[key] = sorted(ctx[key]) - ctx.update(self.flags) + ctx.update(self.format_flags()) for templatefile in \ ['makefile/%s_%s.tmpl' % (self.TEMPLATE, @@ -115,6 +128,17 @@ else: raise NotSupportedException("This make tool is in development") + def format_flags(self): + """Format toolchain flags for Makefile""" + flags = {} + for k, v in self.flags.iteritems(): + if k in ['asm_flags', 'c_flags', 'cxx_flags']: + flags[k] = map(lambda x: x.replace('"', '\\"'), v) + else: + flags[k] = v + + return flags + @staticmethod def build(project_name, log_name="build_log.txt", cleanup=True): """ Build Make project """ @@ -162,8 +186,7 @@ class GccArm(Makefile): """GCC ARM specific makefile target""" - TARGETS = [target for target, obj in TARGET_MAP.iteritems() - if "GCC_ARM" in obj.supported_toolchains] + TARGETS = filter_supported("GCC_ARM", Makefile.POST_BINARY_WHITELIST) NAME = 'Make-GCC-ARM' TEMPLATE = 'make-gcc-arm' TOOLCHAIN = "GCC_ARM" @@ -181,8 +204,7 @@ class Armc5(Makefile): """ARM Compiler 5 specific makefile target""" - TARGETS = [target for target, obj in TARGET_MAP.iteritems() - if "ARM" in obj.supported_toolchains] + TARGETS = filter_supported("ARM", Makefile.POST_BINARY_WHITELIST) NAME = 'Make-ARMc5' TEMPLATE = 'make-armc5' TOOLCHAIN = "ARM" @@ -200,8 +222,7 @@ class IAR(Makefile): """IAR specific makefile target""" - TARGETS = [target for target, obj in TARGET_MAP.iteritems() - if "IAR" in obj.supported_toolchains] + TARGETS = filter_supported("IAR", Makefile.POST_BINARY_WHITELIST) NAME = 'Make-IAR' TEMPLATE = 'make-iar' TOOLCHAIN = "IAR"