Skip to content

Commit 58372d3

Browse files
committed
Allow ARMC6 to run post-binary-hooks marked for ARM
1 parent 7b42891 commit 58372d3

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

tools/hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __init__(self, target, toolchain):
6565
_HOOKS.clear()
6666
self._cmdline_hooks = {}
6767
self.toolchain = toolchain
68-
target.init_hooks(self, toolchain.__class__.__name__)
68+
target.init_hooks(self, toolchain)
6969

7070
# Hook various functions directly
7171
@staticmethod

tools/targets/__init__.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import inspect
2323
import sys
2424
from copy import copy
25+
from inspect import getmro
2526
from collections import namedtuple, Mapping
2627
from tools.targets.LPC import patch
2728
from tools.paths import TOOLS_BOOTLOADERS
@@ -310,10 +311,14 @@ def labels(self):
310311
labels.append("UVISOR_UNSUPPORTED")
311312
return labels
312313

313-
def init_hooks(self, hook, toolchain_name):
314+
def init_hooks(self, hook, toolchain):
314315
"""Initialize the post-build hooks for a toolchain. For now, this
315316
function only allows "post binary" hooks (hooks that are executed
316317
after the binary image is extracted from the executable file)
318+
319+
Positional Arguments:
320+
hook - the hook object to add post-binary-hooks to
321+
toolchain - the toolchain object for inspection
317322
"""
318323

319324
# If there's no hook, simply return
@@ -329,7 +334,7 @@ def init_hooks(self, hook, toolchain_name):
329334
("Invalid format for hook '%s' in target '%s'"
330335
% (hook_data["function"], self.name)) +
331336
" (must be 'class_name.function_name')")
332-
class_name, function_name = temp[0], temp[1]
337+
class_name, function_name = temp
333338
# "class_name" must refer to a class in this file, so check if the
334339
# class exists
335340
mdata = self.get_module_data()
@@ -349,10 +354,11 @@ def init_hooks(self, hook, toolchain_name):
349354
("required by '%s' " % hook_data["function"]) +
350355
("in target '%s' " % self.name) +
351356
("not found in class '%s'" % class_name))
352-
# Check if the hook specification also has target restrictions
353-
toolchain_restrictions = hook_data.get("toolchains", [])
357+
# Check if the hook specification also has toolchain restrictions
358+
toolchain_restrictions = set(hook_data.get("toolchains", []))
359+
toolchain_labels = set(c.__name__ for c in getmro(toolchain.__class__))
354360
if toolchain_restrictions and \
355-
(toolchain_name not in toolchain_restrictions):
361+
not toolchain_labels.intersection(toolchain_restrictions):
356362
return
357363
# Finally, hook the requested function
358364
hook.hook_add_binary("post", getattr(cls, function_name))

tools/toolchains/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from itertools import chain
2727
from inspect import getmro
2828
from copy import deepcopy
29-
from tools.config import Config
3029
from abc import ABCMeta, abstractmethod
3130
from distutils.spawn import find_executable
3231

@@ -1257,7 +1256,7 @@ def get_config_header(self):
12571256
else:
12581257
prev_data = None
12591258
# Get the current configuration data
1260-
crt_data = Config.config_to_header(self.config_data) if self.config_data else None
1259+
crt_data = self.config.config_to_header(self.config_data) if self.config_data else None
12611260
# "changed" indicates if a configuration change was detected
12621261
changed = False
12631262
if prev_data is not None: # a previous mbed_config.h exists
@@ -1553,7 +1552,7 @@ def redirect_symbol(source, sync, build_dir):
15531552

15541553
# Return the list of macros geenrated by the build system
15551554
def get_config_macros(self):
1556-
return Config.config_to_macros(self.config_data) if self.config_data else []
1555+
return self.config.config_to_macros(self.config_data) if self.config_data else []
15571556

15581557
@property
15591558
def report(self):

0 commit comments

Comments
 (0)