From: Simon Glass <simon.glass@canonical.com> Move the Config class from builder.py to cfgutil.py as part of an effort to split up the large builder.py file. This class holds parsed configuration data for boards. It fits naturally in cfgutil.py alongside the other Kconfig utilities. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- tools/buildman/builder.py | 27 +-------------------------- tools/buildman/cfgutil.py | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 3c0af07d624..5531e496271 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -20,6 +20,7 @@ import sys import threading from buildman import builderthread +from buildman.cfgutil import Config from u_boot_pylib import command from u_boot_pylib import gitutil from u_boot_pylib import terminal @@ -149,32 +150,6 @@ EXTRA_CONFIG_FILENAMES = [ 'autoconf.h', 'autoconf-spl.h','autoconf-tpl.h', ] -class Config: - """Holds information about configuration settings for a board.""" - def __init__(self, config_filename, target): - self.target = target - self.config = {} - for fname in config_filename: - self.config[fname] = {} - - def add(self, fname, key, value): - """Add a configuration value - - Args: - fname (str): Filename to add to (e.g. '.config') - key (str): Config key (e.g. 'CONFIG_DM') - value (str): Config value (e.g. 'y') - """ - self.config[fname][key] = value - - def __hash__(self): - val = 0 - for _, config in self.config.items(): - for key, value in config.items(): - print(key, value) - val = val ^ hash(key) & hash(value) - return val - class Environment: """Holds information about environment variables for a board.""" def __init__(self, target): diff --git a/tools/buildman/cfgutil.py b/tools/buildman/cfgutil.py index 5bc97d33595..ad6dee17829 100644 --- a/tools/buildman/cfgutil.py +++ b/tools/buildman/cfgutil.py @@ -3,12 +3,40 @@ # Written by Simon Glass <sjg@chromium.org> # -"""Utility functions for dealing with Kconfig .confing files""" +"""Utility functions for dealing with Kconfig .config files""" import re from u_boot_pylib import tools + +class Config: + """Holds information about configuration settings for a board.""" + def __init__(self, config_filename, target): + self.target = target + self.config = {} + for fname in config_filename: + self.config[fname] = {} + + def add(self, fname, key, value): + """Add a configuration value + + Args: + fname (str): Filename to add to (e.g. '.config') + key (str): Config key (e.g. 'CONFIG_DM') + value (str): Config value (e.g. 'y') + """ + self.config[fname][key] = value + + def __hash__(self): + val = 0 + for _, config in self.config.items(): + for key, value in config.items(): + print(key, value) + val = val ^ hash(key) & hash(value) + return val + + RE_LINE = re.compile(r'(# )?CONFIG_([A-Z0-9_]+)(=(.*)| is not set)') RE_CFG = re.compile(r'(~?)(CONFIG_)?([A-Z0-9_]+)(=.*)?') -- 2.43.0