Skip to content

Commit 42d77ec

Browse files
authored
Merge pull request #6658 from theotherjimmy/lib-override-target
Allow library configs to override target configs
2 parents 951e70f + 7a6f2e4 commit 42d77ec

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

tools/config/__init__.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def get_full_name(name, unit_name, unit_kind, label=None,
117117
unit_name, unit_kind, label)))
118118
prefix = temp[0]
119119
# Check if the given parameter prefix matches the expected prefix
120-
if (unit_kind == "library" and prefix != unit_name) or \
120+
if (unit_kind == "library" and prefix not in [unit_name, "target"]) or \
121121
(unit_kind == "target" and prefix != "target"):
122122
raise ConfigException(
123123
"Invalid prefix '%s' for parameter name '%s' in '%s'" %
@@ -858,21 +858,20 @@ def get_target_config_data(self):
858858
params[full_name].set_value(val, tname, "target")
859859
return params
860860

861-
def get_lib_config_data(self):
861+
def get_lib_config_data(self, target_data):
862862
""" Read and interpret configuration data defined by libraries. It is
863863
assumed that "add_config_files" above was already called and the library
864864
configuration data exists in self.lib_config_data
865865
866866
Arguments: None
867867
"""
868-
all_params, macros = {}, {}
868+
macros = {}
869869
for lib_name, lib_data in self.lib_config_data.items():
870-
all_params.update(self._process_config_and_overrides(lib_data, {},
871-
lib_name,
872-
"library"))
870+
self._process_config_and_overrides(
871+
lib_data, target_data, lib_name, "library")
873872
_process_macros(lib_data.get("macros", []), macros, lib_name,
874873
"library")
875-
return all_params, macros
874+
return target_data, macros
876875

877876
def get_app_config_data(self, params, macros):
878877
""" Read and interpret the configuration data defined by the target. The
@@ -902,10 +901,9 @@ def get_config_data(self):
902901
Arguments: None
903902
"""
904903
all_params = self.get_target_config_data()
905-
lib_params, macros = self.get_lib_config_data()
906-
all_params.update(lib_params)
907-
self.get_app_config_data(all_params, macros)
908-
return all_params, macros
904+
lib_params, macros = self.get_lib_config_data(all_params)
905+
self.get_app_config_data(lib_params, macros)
906+
return lib_params, macros
909907

910908
@staticmethod
911909
def _check_required_parameters(params):

0 commit comments

Comments
 (0)