Skip to content

Add post-build hook white-list to exporters #3875

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, 2017
Merged
Show file tree
Hide file tree
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
12 changes: 9 additions & 3 deletions tools/export/embitz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@
"""
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

Expand Down
17 changes: 17 additions & 0 deletions tools/export/exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,20 @@ def build(project_name, log_name='build_log.txt', cleanup=True):
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))
11 changes: 7 additions & 4 deletions tools/export/gnuarmeclipse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
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
Expand All @@ -58,13 +58,16 @@ def id(self):
# =============================================================================


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
Expand Down
16 changes: 9 additions & 7 deletions tools/export/makefile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -168,8 +173,7 @@ def build(project_name, log_name="build_log.txt", cleanup=True):

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"
Expand All @@ -187,8 +191,7 @@ def prepare_sys_lib(libname):

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"
Expand All @@ -206,8 +209,7 @@ def prepare_sys_lib(libname):

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"
Expand Down
11 changes: 0 additions & 11 deletions tools/export/makefile/make-gcc-arm_nxp.tmpl

This file was deleted.