Skip to content

[build tools] Added support for cumulative attributes in configs directly #1906

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 3 commits into from
Jun 11, 2016
Merged
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
22 changes: 22 additions & 0 deletions tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def __init__(self, target, top_level_dirs = []):
self.processed_configs = {}
self.target = target if isinstance(target, str) else target.name
self.target_labels = Target.get_target(self.target).get_labels()
self.target_instance = Target.get_target(self.target)

# Add one or more configuration files
def add_config_files(self, flist):
Expand Down Expand Up @@ -221,6 +222,27 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
for label, overrides in data.get("target_overrides", {}).items():
# If the label is defined by the target or it has the special value "*", process the overrides
if (label == '*') or (label in self.target_labels):
# Parse out cumulative attributes
for attr in Target._Target__cumulative_attributes:
attrs = getattr(self.target_instance, attr)

if attr in overrides:
del attrs[:]
attrs.extend(overrides[attr])
del overrides[attr]

if attr+'_add' in overrides:
attrs.extend(overrides[attr+'_add'])
del overrides[attr+'_add']

if attr+'_remove' in overrides:
for a in overrides[attr+'_remove']:
attrs.remove(a)
del overrides[attr+'_remove']

setattr(self.target_instance, attr, attrs)

# Consider the others as overrides
for name, v in overrides.items():
# Get the full name of the parameter
full_name = ConfigParameter.get_full_name(name, unit_name, unit_kind, label)
Expand Down