Correct post-build filtering options

pull/10065/head
Jimmy Brisson 2019-03-12 11:10:22 -05:00
parent 401a3c8551
commit 7380451f6e
2 changed files with 8 additions and 7 deletions

View File

@ -356,7 +356,7 @@ class Target(namedtuple("Target", "name json_data resolution_order resolution_or
def is_PSA_non_secure_target(self): def is_PSA_non_secure_target(self):
return 'NSPE_Target' in self.labels 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 """Initialize the post-build hooks for a toolchain. For now, this
function only allows "post binary" hooks (hooks that are executed function only allows "post binary" hooks (hooks that are executed
after the binary image is extracted from the executable file) 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)) ("not found in class '%s'" % class_name))
# Check if the hook specification also has toolchain restrictions # Check if the hook specification also has toolchain restrictions
toolchain_restrictions = set(hook_data.get("toolchains", [])) toolchain_restrictions = set(hook_data.get("toolchains", []))
toolchain_labels = set(c.__name__ for c in getmro(toolchain.__class__))
if toolchain_restrictions and \ if toolchain_restrictions and \
not toolchain_labels.intersection(toolchain_restrictions): not set(toolchain_labels).intersection(toolchain_restrictions):
return return
return getattr(cls, function_name) return getattr(cls, function_name)

View File

@ -136,8 +136,6 @@ class mbedToolchain:
self.target = target self.target = target
self.name = self.__class__.__name__ self.name = self.__class__.__name__
# compile/assemble/link/binary hooks
self._post_build_hook = target.get_post_build_hook(self.name)
# Toolchain flags # Toolchain flags
self.flags = deepcopy(build_profile or self.profile_template) self.flags = deepcopy(build_profile or self.profile_template)
@ -754,9 +752,13 @@ class mbedToolchain:
else: else:
updatable = None 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.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. # Initialize memap and process map file. This doesn't generate output.
self.mem_stats(mapfile) self.mem_stats(mapfile)