mirror of
https://xff.cz/git/u-boot/
synced 2025-10-22 10:31:56 +02:00
moveconfig: Read the database in a separate function
Move this code out into a function so it can be used elsewhere. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -1339,6 +1339,54 @@ IMPLY_FLAGS = {
|
|||||||
'Allow Kconfig options outside arch/ and /board/ to imply'],
|
'Allow Kconfig options outside arch/ and /board/ to imply'],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
def read_database():
|
||||||
|
"""Read in the config database
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
tuple:
|
||||||
|
set of all config options seen (each a str)
|
||||||
|
set of all defconfigs seen (each a str)
|
||||||
|
dict of configs for each defconfig:
|
||||||
|
key: defconfig name, e.g. "MPC8548CDS_legacy_defconfig"
|
||||||
|
value: dict:
|
||||||
|
key: CONFIG option
|
||||||
|
value: Value of option
|
||||||
|
dict of defconfigs for each config:
|
||||||
|
key: CONFIG option
|
||||||
|
value: set of boards using that option
|
||||||
|
|
||||||
|
"""
|
||||||
|
configs = {}
|
||||||
|
|
||||||
|
# key is defconfig name, value is dict of (CONFIG_xxx, value)
|
||||||
|
config_db = {}
|
||||||
|
|
||||||
|
# Set of all config options we have seen
|
||||||
|
all_configs = set()
|
||||||
|
|
||||||
|
# Set of all defconfigs we have seen
|
||||||
|
all_defconfigs = set()
|
||||||
|
|
||||||
|
defconfig_db = collections.defaultdict(set)
|
||||||
|
with open(CONFIG_DATABASE) as fd:
|
||||||
|
for line in fd.readlines():
|
||||||
|
line = line.rstrip()
|
||||||
|
if not line: # Separator between defconfigs
|
||||||
|
config_db[defconfig] = configs
|
||||||
|
all_defconfigs.add(defconfig)
|
||||||
|
configs = {}
|
||||||
|
elif line[0] == ' ': # CONFIG line
|
||||||
|
config, value = line.strip().split('=', 1)
|
||||||
|
configs[config] = value
|
||||||
|
defconfig_db[config].add(defconfig)
|
||||||
|
all_configs.add(config)
|
||||||
|
else: # New defconfig
|
||||||
|
defconfig = line
|
||||||
|
|
||||||
|
return all_configs, all_defconfigs, config_db, defconfig_db
|
||||||
|
|
||||||
|
|
||||||
def do_imply_config(config_list, add_imply, imply_flags, skip_added,
|
def do_imply_config(config_list, add_imply, imply_flags, skip_added,
|
||||||
check_kconfig=True, find_superset=False):
|
check_kconfig=True, find_superset=False):
|
||||||
"""Find CONFIG options which imply those in the list
|
"""Find CONFIG options which imply those in the list
|
||||||
@@ -1385,35 +1433,7 @@ def do_imply_config(config_list, add_imply, imply_flags, skip_added,
|
|||||||
if add_imply and add_imply != 'all':
|
if add_imply and add_imply != 'all':
|
||||||
add_imply = add_imply.split(',')
|
add_imply = add_imply.split(',')
|
||||||
|
|
||||||
# key is defconfig name, value is dict of (CONFIG_xxx, value)
|
all_configs, all_defconfigs, config_db, defconfig_db = read_database()
|
||||||
config_db = {}
|
|
||||||
|
|
||||||
# Holds a dict containing the set of defconfigs that contain each config
|
|
||||||
# key is config, value is set of defconfigs using that config
|
|
||||||
defconfig_db = collections.defaultdict(set)
|
|
||||||
|
|
||||||
# Set of all config options we have seen
|
|
||||||
all_configs = set()
|
|
||||||
|
|
||||||
# Set of all defconfigs we have seen
|
|
||||||
all_defconfigs = set()
|
|
||||||
|
|
||||||
# Read in the database
|
|
||||||
configs = {}
|
|
||||||
with open(CONFIG_DATABASE) as fd:
|
|
||||||
for line in fd.readlines():
|
|
||||||
line = line.rstrip()
|
|
||||||
if not line: # Separator between defconfigs
|
|
||||||
config_db[defconfig] = configs
|
|
||||||
all_defconfigs.add(defconfig)
|
|
||||||
configs = {}
|
|
||||||
elif line[0] == ' ': # CONFIG line
|
|
||||||
config, value = line.strip().split('=', 1)
|
|
||||||
configs[config] = value
|
|
||||||
defconfig_db[config].add(defconfig)
|
|
||||||
all_configs.add(config)
|
|
||||||
else: # New defconfig
|
|
||||||
defconfig = line
|
|
||||||
|
|
||||||
# Work through each target config option in turn, independently
|
# Work through each target config option in turn, independently
|
||||||
for config in config_list:
|
for config in config_list:
|
||||||
|
Reference in New Issue
Block a user