From 9de541b9c278cf0d9e42c71abc6f84ebbf0419f2 Mon Sep 17 00:00:00 2001 From: Fabio Baltieri Date: Tue, 13 Jun 2023 18:42:49 +0100 Subject: [PATCH] scripts: ci: check_compliance: add a no-modules Kconfig check Add a variation of the basic Kconfig check that runs with no modules, catches symbols that are used in the main repository but are defined only in modules, which are potentially problematic if a downstream project is not using the specific module. Signed-off-by: Fabio Baltieri --- .gitignore | 1 + scripts/ci/check_compliance.py | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 735440b4cac..16e54c46628 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,7 @@ Identity.txt ImageSize.txt Kconfig.txt KconfigBasic.txt +KconfigBasicNoModules.txt MaintainersFormat.txt Nits.txt Pylint.txt diff --git a/scripts/ci/check_compliance.py b/scripts/ci/check_compliance.py index 56187409810..f5e3002fd5e 100755 --- a/scripts/ci/check_compliance.py +++ b/scripts/ci/check_compliance.py @@ -268,7 +268,9 @@ class KconfigCheck(ComplianceTest): doc = "See https://docs.zephyrproject.org/latest/guides/kconfig/index.html for more details." path_hint = "" - def run(self, full=True): + def run(self, full=True, no_modules=False): + self.no_modules = no_modules + kconf = self.parse_kconfig() self.check_top_menu_not_too_long(kconf) @@ -287,6 +289,11 @@ class KconfigCheck(ComplianceTest): This is needed to complete Kconfig sanity tests. """ + if self.no_modules: + with open(modules_file, 'w') as fp_module_file: + fp_module_file.write("# Empty\n") + return + # Invoke the script directly using the Python executable since this is # not a module nor a pip-installed Python utility zephyr_module_path = os.path.join(ZEPHYR_BASE, "scripts", @@ -711,6 +718,18 @@ class KconfigBasicCheck(KconfigCheck): def run(self): super().run(full=False) +class KconfigBasicNoModulesCheck(KconfigCheck): + """ + Checks if we are introducing any new warnings/errors with Kconfig when no + modules are available. Catches symbols used in the main repository but + defined only in a module. + """ + name = "KconfigBasicNoModules" + doc = "See https://docs.zephyrproject.org/latest/guides/kconfig/index.html for more details." + path_hint = "" + def run(self): + super().run(full=False, no_modules=True) + class Nits(ComplianceTest): """