diff options
author | Jeremy Bettis <jbettis@google.com> | 2023-03-29 23:13:46 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-04-03 18:15:49 +0000 |
commit | c02695e85c4978a9e58bd812c190dc5bc204e40a (patch) | |
tree | c3cf084eba25ca31734292f60c9fb848f095a0ee /util/kconfig_check.py | |
parent | d5e9eb12022a47e24366ef060e9e69aa198d4ec4 (diff) | |
download | chrome-ec-c02695e85c4978a9e58bd812c190dc5bc204e40a.tar.gz |
ec: Fix kconfig_check.py
The kconfig_check.py tool was reporting all symbols in the Kconfigs as
configs, including things like
```
config PLATFORM_EC_PREINIT_HW_CYCLES_PER_SEC
default 100000000
```
would return CONFIG_PLATFORM_EC_PREINIT_HW_CYCLES_PER_SEC and
CONFIG_100000000 as valid configs.
Read only Symbol node names instead.
Include Kconfigs in platform/ec but outside of platform/ec/zephyr also.
Also include Kconfig.zephyr from third_party/zephyr/main, which was
previously omitted. This requires setting some environment variables.
BRANCH=None
BUG=b:272518464
TEST=make buildall
Change-Id: I02e86f5c96f1e9943386d1610af1b2ab07550754
Signed-off-by: Jeremy Bettis <jbettis@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4383371
Auto-Submit: Jeremy Bettis <jbettis@chromium.org>
Tested-by: Jeremy Bettis <jbettis@chromium.org>
Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'util/kconfig_check.py')
-rwxr-xr-x | util/kconfig_check.py | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/util/kconfig_check.py b/util/kconfig_check.py index 1b67f0c846..aebaa24cbd 100755 --- a/util/kconfig_check.py +++ b/util/kconfig_check.py @@ -2,6 +2,7 @@ # Copyright 2021 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. + """Kconfig checker Checks that the .config file provided does not introduce any new ad-hoc CONFIG @@ -285,21 +286,37 @@ class KconfigCheck: List of config and menuconfig options found """ if USE_KCONFIGLIB and try_kconfiglib: - os.environ["srctree"] = srcdir - kconf = kconfiglib.Kconfig( - "Kconfig", - warn=False, - search_paths=search_paths, - allow_empty_macros=True, + os.environ.update( + { + "srctree": srcdir, + "SOC_DIR": "soc", + "ARCH_DIR": "arch", + "BOARD_DIR": "boards/*/*", + "ARCH": "*", + } ) - - # There is always a MODULES config, since kconfiglib is designed for - # linux, but we don't want it - kconfigs = [name for name in kconf.syms if name != "MODULES"] - - if prefix: - re_drop_prefix = re.compile(r"^%s" % prefix) - kconfigs = [re_drop_prefix.sub("", name) for name in kconfigs] + kconfigs = [] + for filename in [ + "Kconfig", + os.path.join(os.environ["ZEPHYR_BASE"], "Kconfig.zephyr"), + ]: + kconf = kconfiglib.Kconfig( + filename, + warn=False, + search_paths=search_paths, + allow_empty_macros=True, + ) + + symbols = [ + node.item.name + for node in kconf.node_iter() + if isinstance(node.item, kconfiglib.Symbol) + ] + + if prefix: + re_drop_prefix = re.compile(r"^%s" % prefix) + symbols = [re_drop_prefix.sub("", name) for name in symbols] + kconfigs += symbols else: kconfigs = [] # Remove the prefix if present |