qconfig: Allow searching for CONFIG values
Add basic support for searching for matching of non-matching values. Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/20
This commit is contained in:
@@ -85,6 +85,20 @@ example, to find boards which enabled CONFIG_SCSI but not CONFIG_BLK::
|
|||||||
3 matches
|
3 matches
|
||||||
pg_wcom_seli8_defconfig highbank_defconfig pg_wcom_expu1_defconfig
|
pg_wcom_seli8_defconfig highbank_defconfig pg_wcom_expu1_defconfig
|
||||||
|
|
||||||
|
It is also possible to search for particular values. For example, this finds all
|
||||||
|
boards with an empty string for `CONFIG_DEFAULT_FDT_FILE`::
|
||||||
|
|
||||||
|
./tools/qconfig.py -f DEFAULT_FDT_FILE=\"\"
|
||||||
|
1092 matches
|
||||||
|
...
|
||||||
|
|
||||||
|
This finds boards which have a value for SYS_MAXARGS other than 64::
|
||||||
|
|
||||||
|
./tools/qconfig.py -f ~SYS_MAXARGS=64
|
||||||
|
cfg CONFIG_SYS_MAXARGS
|
||||||
|
281 matches
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
Finding implied CONFIGs
|
Finding implied CONFIGs
|
||||||
-----------------------
|
-----------------------
|
||||||
|
@@ -1079,7 +1079,7 @@ def do_imply_config(config_list, add_imply, imply_flags, skip_added,
|
|||||||
for linenum in sorted(linenums, reverse=True):
|
for linenum in sorted(linenums, reverse=True):
|
||||||
add_imply_rule(config[CONFIG_LEN:], fname, linenum)
|
add_imply_rule(config[CONFIG_LEN:], fname, linenum)
|
||||||
|
|
||||||
def defconfig_matches(configs, re_match):
|
def defconfig_matches(configs, re_match, re_val):
|
||||||
"""Check if any CONFIG option matches a regex
|
"""Check if any CONFIG option matches a regex
|
||||||
|
|
||||||
The match must be complete, i.e. from the start to end of the CONFIG option.
|
The match must be complete, i.e. from the start to end of the CONFIG option.
|
||||||
@@ -1089,12 +1089,14 @@ def defconfig_matches(configs, re_match):
|
|||||||
key: CONFIG option
|
key: CONFIG option
|
||||||
value: Value of option
|
value: Value of option
|
||||||
re_match (re.Pattern): Match to check
|
re_match (re.Pattern): Match to check
|
||||||
|
re_val (re.Pattern): Regular expression to check against value (or None)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: True if any CONFIG matches the regex
|
bool: True if any CONFIG matches the regex
|
||||||
"""
|
"""
|
||||||
for cfg in configs:
|
for cfg, val in configs.items():
|
||||||
if re_match.fullmatch(cfg):
|
if re_match.fullmatch(cfg):
|
||||||
|
if not re_val or re_val.fullmatch(val):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -1123,6 +1125,11 @@ def do_find_config(config_list):
|
|||||||
if cfg[0] == '~':
|
if cfg[0] == '~':
|
||||||
want = False
|
want = False
|
||||||
cfg = cfg[1:]
|
cfg = cfg[1:]
|
||||||
|
val = None
|
||||||
|
re_val = None
|
||||||
|
if '=' in cfg:
|
||||||
|
cfg, val = cfg.split('=', maxsplit=1)
|
||||||
|
re_val = re.compile(val)
|
||||||
|
|
||||||
# Search everything that is still in the running. If it has a config
|
# Search everything that is still in the running. If it has a config
|
||||||
# that we want, or doesn't have one that we don't, add it into the
|
# that we want, or doesn't have one that we don't, add it into the
|
||||||
@@ -1131,7 +1138,7 @@ def do_find_config(config_list):
|
|||||||
out = set()
|
out = set()
|
||||||
re_match = re.compile(cfg)
|
re_match = re.compile(cfg)
|
||||||
for defc in in_list:
|
for defc in in_list:
|
||||||
has_cfg = defconfig_matches(config_db[defc], re_match)
|
has_cfg = defconfig_matches(config_db[defc], re_match, re_val)
|
||||||
if has_cfg == want:
|
if has_cfg == want:
|
||||||
out.add(defc)
|
out.add(defc)
|
||||||
print(f'{len(out)} matches')
|
print(f'{len(out)} matches')
|
||||||
|
Reference in New Issue
Block a user