Skip invalid undefined errors

pull/7277/head
Jimmy Brisson 2018-06-21 11:49:22 -05:00
parent 12f490fa02
commit 2a9923f86e
2 changed files with 24 additions and 35 deletions

View File

@ -137,27 +137,7 @@ def get_config(src_paths, target, toolchain_name, app_config=None):
app_config=app_config) app_config=app_config)
# Scan src_path for config files # Scan src_path for config files
resources = toolchain.scan_resources(src_paths[0]) scan_resources(src_paths, toolchain)
for path in src_paths[1:]:
resources.add(toolchain.scan_resources(path))
# Update configuration files until added features creates no changes
prev_features = set()
while True:
# Update the configuration with any .json files found while scanning
toolchain.config.add_config_files(resources.json_files)
# Add features while we find new ones
features = set(toolchain.config.get_features())
if features == prev_features:
break
for feature in features:
if feature in resources.features:
resources += resources.features[feature]
prev_features = features
toolchain.config.validate_config()
if toolchain.config.has_regions: if toolchain.config.has_regions:
_ = list(toolchain.config.regions) _ = list(toolchain.config.regions)

View File

@ -68,6 +68,19 @@ class ConfigException(Exception):
errors""" errors"""
pass pass
class UndefinedParameter(ConfigException):
def __init__(self, param, name, kind, label):
self.param = param
self.name = name
self.kind = kind
self.label = label
def __str__(self):
return "Attempt to override undefined parameter '{}' in '{}'".format(
self.param,
ConfigParameter.get_display_name(self.name, self.kind, self.label),
)
class ConfigParameter(object): class ConfigParameter(object):
"""This class keeps information about a single configuration parameter""" """This class keeps information about a single configuration parameter"""
@ -857,13 +870,8 @@ class Config(object):
continue continue
else: else:
self.config_errors.append( self.config_errors.append(
ConfigException( UndefinedParameter(
"Attempt to override undefined parameter" + full_name, unit_name, unit_kind, label))
(" '%s' in '%s'"
% (full_name,
ConfigParameter.get_display_name(unit_name,
unit_kind,
label)))))
for cumulatives in self.cumulative_overrides.values(): for cumulatives in self.cumulative_overrides.values():
cumulatives.update_target(self.target) cumulatives.update_target(self.target)
@ -911,10 +919,7 @@ class Config(object):
continue continue
if (full_name not in params) or \ if (full_name not in params) or \
(params[full_name].defined_by[7:] not in rel_names): (params[full_name].defined_by[7:] not in rel_names):
raise ConfigException( raise UndefinedParameter(name, tname, "target", "")
"Attempt to override undefined parameter '%s' in '%s'"
% (name,
ConfigParameter.get_display_name(tname, "target")))
# Otherwise update the value of the parameter # Otherwise update the value of the parameter
params[full_name].set_value(val, tname, "target") params[full_name].set_value(val, tname, "target")
return params return params
@ -1050,8 +1055,13 @@ class Config(object):
Arguments: None Arguments: None
""" """
if self.config_errors: params, _ = self.get_config_data()
raise self.config_errors[0] for error in self.config_errors:
if (isinstance(error, UndefinedParameter) and
error.param in params):
continue
else:
raise error
return True return True
@ -1071,7 +1081,6 @@ class Config(object):
""" """
# Update configuration files until added features creates no changes # Update configuration files until added features creates no changes
prev_features = set() prev_features = set()
self.validate_config()
while True: while True:
# Add/update the configuration with any .json files found while # Add/update the configuration with any .json files found while
# scanning # scanning