From a3eacb877cfa20f3b66a228255ab00b15d516feb Mon Sep 17 00:00:00 2001 From: Steven Schaus Date: Mon, 3 Oct 2022 22:23:47 -0700 Subject: [PATCH] Load RuntimeConfig from plugins Implements support for dynamically loading additional RuntimeConfig and associated RuntimeParameter that are defined in a plugin. Currently, the various RuntimeConfig's are hard coded in a list within WA. This patch extends RuntimeParameterManager to use PluginLoader to load RuntimeConfig classes and append to the hard coded list. The implementation, as written, does not allow loading RuntimeConfig from a plugin if it has the same name as one of the hard coded RuntimeConfig. This is meant to prevent conflicts and unexpected behavior. --- wa/framework/target/runtime_parameter_manager.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wa/framework/target/runtime_parameter_manager.py b/wa/framework/target/runtime_parameter_manager.py index c4623550..77365dd2 100644 --- a/wa/framework/target/runtime_parameter_manager.py +++ b/wa/framework/target/runtime_parameter_manager.py @@ -22,6 +22,7 @@ from wa.framework.target.runtime_config import (SysfileValuesRuntimeConfig, CpuidleRuntimeConfig, AndroidRuntimeConfig) from wa.utils.types import obj_dict, caseless_string +from wa.framework import pluginloader class RuntimeParameterManager(object): @@ -37,9 +38,16 @@ class RuntimeParameterManager(object): def __init__(self, target): self.target = target - self.runtime_configs = [cls(self.target) for cls in self.runtime_config_cls] self.runtime_params = {} + try: + for rt_cls in pluginloader.list_plugins(kind='runtime-config'): + if rt_cls not in self.runtime_config_cls: + self.runtime_config_cls.append(rt_cls) + except ValueError: + pass + self.runtime_configs = [cls(self.target) for cls in self.runtime_config_cls] + runtime_parameter = namedtuple('RuntimeParameter', 'cfg_point, rt_config') for cfg in self.runtime_configs: for param in cfg.supported_parameters: