From 7380451f6eb285151d0d9fa849262318bb47aeca Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Tue, 12 Mar 2019 11:10:22 -0500 Subject: [PATCH] Correct post-build filtering options --- tools/targets/__init__.py | 5 ++--- tools/toolchains/mbed_toolchain.py | 10 ++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/targets/__init__.py b/tools/targets/__init__.py index b122ef1adb..d8fad4c7ea 100644 --- a/tools/targets/__init__.py +++ b/tools/targets/__init__.py @@ -356,7 +356,7 @@ class Target(namedtuple("Target", "name json_data resolution_order resolution_or def is_PSA_non_secure_target(self): return 'NSPE_Target' in self.labels - def get_post_build_hook(self, toolchain): + def get_post_build_hook(self, toolchain_labels): """Initialize the post-build hooks for a toolchain. For now, this function only allows "post binary" hooks (hooks that are executed after the binary image is extracted from the executable file) @@ -401,9 +401,8 @@ class Target(namedtuple("Target", "name json_data resolution_order resolution_or ("not found in class '%s'" % class_name)) # Check if the hook specification also has toolchain restrictions toolchain_restrictions = set(hook_data.get("toolchains", [])) - toolchain_labels = set(c.__name__ for c in getmro(toolchain.__class__)) if toolchain_restrictions and \ - not toolchain_labels.intersection(toolchain_restrictions): + not set(toolchain_labels).intersection(toolchain_restrictions): return return getattr(cls, function_name) diff --git a/tools/toolchains/mbed_toolchain.py b/tools/toolchains/mbed_toolchain.py index ba67ec3060..8016dc689b 100755 --- a/tools/toolchains/mbed_toolchain.py +++ b/tools/toolchains/mbed_toolchain.py @@ -136,8 +136,6 @@ class mbedToolchain: self.target = target self.name = self.__class__.__name__ - # compile/assemble/link/binary hooks - self._post_build_hook = target.get_post_build_hook(self.name) # Toolchain flags self.flags = deepcopy(build_profile or self.profile_template) @@ -754,9 +752,13 @@ class mbedToolchain: else: updatable = None - if self._post_build_hook: + # compile/assemble/link/binary hooks + post_build_hook = self.target.get_post_build_hook( + self._get_toolchain_labels() + ) + if post_build_hook: self.progress("post-build", name) - self._post_build_hook(self, r, elf, full_path) + post_build_hook(self, r, elf, full_path) # Initialize memap and process map file. This doesn't generate output. self.mem_stats(mapfile)