diff --git a/tools/export/embitz/__init__.py b/tools/export/embitz/__init__.py index 338b996f8b..e75bc835c3 100644 --- a/tools/export/embitz/__init__.py +++ b/tools/export/embitz/__init__.py @@ -16,14 +16,20 @@ limitations under the License. """ from os.path import splitext, basename from tools.targets import TARGET_MAP -from tools.export.exporters import Exporter +from tools.export.exporters import Exporter, filter_supported + + +POST_BINARY_WHITELIST = set([ + "TEENSY3_1Code.binary_hook" +]) + class EmBitz(Exporter): NAME = 'EmBitz' TOOLCHAIN = 'GCC_ARM' - TARGETS = [target for target, obj in TARGET_MAP.iteritems() - if "GCC_ARM" in obj.supported_toolchains] + + TARGETS = filter_supported("GCC_ARM", POST_BINARY_WHITELIST) MBED_CONFIG_HEADER_SUPPORTED = True diff --git a/tools/export/exporters.py b/tools/export/exporters.py index 58797acb02..e0fa5ae19b 100644 --- a/tools/export/exporters.py +++ b/tools/export/exporters.py @@ -176,3 +176,20 @@ class Exporter(object): def generate(self): """Generate an IDE/tool specific project file""" raise NotImplemented("Implement a generate function in Exporter child class") + + +def filter_supported(compiler, whitelist): + """Generate a list of supported targets for a given compiler and post-binary hook + white-list.""" + def supported_p(obj): + """Internal inner function used for filtering""" + if compiler not in obj.supported_toolchains: + return False + if not hasattr(obj, "post_binary_hook"): + return True + if obj.post_binary_hook['function'] in whitelist: + return True + else: + return False + return list(target for target, obj in TARGET_MAP.iteritems() + if supported_p(obj)) diff --git a/tools/export/gnuarmeclipse/__init__.py b/tools/export/gnuarmeclipse/__init__.py index ced50dec4c..9f7eb4e72d 100644 --- a/tools/export/gnuarmeclipse/__init__.py +++ b/tools/export/gnuarmeclipse/__init__.py @@ -33,7 +33,7 @@ from os.path import splitext, basename, relpath, dirname, exists, join, dirname from random import randint from json import load -from tools.export.exporters import Exporter +from tools.export.exporters import Exporter, filter_supported from tools.options import list_profiles from tools.targets import TARGET_MAP from tools.utils import NotSupportedException @@ -58,13 +58,16 @@ u = UID() # ============================================================================= +POST_BINARY_WHITELIST = set([ + "TEENSY3_1Code.binary_hook", + "MCU_NRF51Code.binary_hook", +]) + class GNUARMEclipse(Exporter): NAME = 'GNU ARM Eclipse' TOOLCHAIN = 'GCC_ARM' - # Indirectly support all GCC_ARM targets. - TARGETS = [target for target, obj in TARGET_MAP.iteritems() - if 'GCC_ARM' in obj.supported_toolchains] + TARGETS = filter_supported("GCC_ARM", POST_BINARY_WHITELIST) # override @property diff --git a/tools/export/makefile/__init__.py b/tools/export/makefile/__init__.py index a76369cda7..0df1a58a31 100644 --- a/tools/export/makefile/__init__.py +++ b/tools/export/makefile/__init__.py @@ -21,7 +21,7 @@ import sys 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,11 @@ class Makefile(Exporter): MBED_CONFIG_HEADER_SUPPORTED = True + POST_BINARY_WHITELIST = set([ + "MCU_NRF51Code.binary_hook", + "TEENSY3_1Code.binary_hook" + ]) + def generate(self): """Generate the makefile @@ -168,8 +173,7 @@ class Makefile(Exporter): 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" @@ -187,8 +191,7 @@ class GccArm(Makefile): 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" @@ -206,8 +209,7 @@ class Armc5(Makefile): 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" diff --git a/tools/export/makefile/make-gcc-arm_nxp.tmpl b/tools/export/makefile/make-gcc-arm_nxp.tmpl deleted file mode 100644 index d9ebb15a27..0000000000 --- a/tools/export/makefile/make-gcc-arm_nxp.tmpl +++ /dev/null @@ -1,11 +0,0 @@ -{% extends "makefile/make-gcc-arm.tmpl" %} - -{% block target_project_elf %} -{{ super() }} - @echo "" - @echo "*****" - @echo "***** You must modify vector checksum value in *.bin and *.hex files." - @echo "*****" - @echo "" -{% endblock %} -