Skip to content

Support default_toolchain override in mbed_app.json #4371

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

Closed
wants to merge 4 commits into from
Closed
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
23 changes: 18 additions & 5 deletions tools/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ def __init__(self, name, additions=None, removals=None, strict=False):
self.removals = set()
self.strict = strict

self.isList = True
self.override = None

def remove_cumulative_overrides(self, overrides):
"""Extend the list of override removals.

Expand Down Expand Up @@ -260,8 +263,10 @@ def add_cumulative_overrides(self, overrides):
raise ConfigException(
"Configuration conflict. The %s %s both added and removed."
% (self.name[:-1], override))

self.additions |= set(overrides)
if( self.isList == True ):
self.additions |= set(overrides)
else:
self.override = overrides

def strict_cumulative_overrides(self, overrides):
"""Remove all overrides that are not the specified ones
Expand All @@ -276,10 +281,14 @@ def strict_cumulative_overrides(self, overrides):

def update_target(self, target):
"""Update the attributes of a target based on this override"""
setattr(target, self.name,

if( self.isList == True ):
setattr(target, self.name,
list((set(getattr(target, self.name, []))
| self.additions) - self.removals))

else:
if( self.override != None ):
setattr(target, self.name, self.override)

def _process_config_parameters(data, params, unit_name, unit_kind):
"""Process a "config_parameters" section in either a target, a library,
Expand Down Expand Up @@ -606,7 +615,9 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
for attr, cumulatives in self.cumulative_overrides.iteritems():
if 'target.'+attr in overrides:
key = 'target.' + attr
if not isinstance(overrides[key], list):
if( type(getattr(self.target, attr, [])) != type(list()) ):
cumulatives.isList = False
if (cumulatives.isList == True) and (not isinstance(overrides[key], list)):
raise ConfigException(
"The value of %s.%s is not of type %s" %
(unit_name, "target_overrides." + key,
Expand Down Expand Up @@ -655,6 +666,8 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
label)))))

for cumulatives in self.cumulative_overrides.itervalues():
if( type(getattr(self.target, cumulatives.name, [])) != type(list()) ):
cumulatives.isList = False
cumulatives.update_target(self.target)

return params
Expand Down
2 changes: 1 addition & 1 deletion tools/targets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def wrapper(*args, **kwargs):

# Cumulative attributes can have values appended to them, so they
# need to be computed differently than regular attributes
CUMULATIVE_ATTRIBUTES = ['extra_labels', 'macros', 'device_has', 'features']
CUMULATIVE_ATTRIBUTES = ['extra_labels', 'macros', 'device_has', 'features', 'default_toolchain']


def get_resolution_order(json_data, target_name, order, level=0):
Expand Down