From 35e28e6315893f573ca0de8e5fd5a29e849435f9 Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Fri, 23 Aug 2024 14:40:34 +0200 Subject: [PATCH] scripts: handle auto defined ZEPHYR__MODULE settings in compliance Update check_compliance to handle auto defined ZEPHYR__MODULE Kconfig symbols. check_compliance runs three levels of Kconfig check. A basic and a full, both which uses the generated Kconfig.modules created according to Zephyr modules present. A Kconfig check where no Zephyr modules are sourced. This check ensures that Zephyr Kconfig tree doesn't refer to Kconfig symbols defined in Zephyr module's local Kconfig trees. However, there are a few auto generated symbols which are allowed, such as: `ZEPHYR__MODULE` and `ZEPHYR__MODULE_BLOBS`. Therefore, when testing no blobs, filter the generated Kconfig.modules file, so that no sourcing of extra Kconfig files are performed but lines defining `ZEPHYR__MODULE` and `ZEPHYR__MODULE_BLOBS` are preserved. Signed-off-by: Torsten Rasmussen --- scripts/ci/check_compliance.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/ci/check_compliance.py b/scripts/ci/check_compliance.py index 867a515c29c..e8f79a9f0c7 100755 --- a/scripts/ci/check_compliance.py +++ b/scripts/ci/check_compliance.py @@ -383,11 +383,6 @@ 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", @@ -415,6 +410,18 @@ class KconfigCheck(ComplianceTest): )) fp_module_file.write(content) + if self.no_modules: + module_define_content = "" + module_definition = re.compile('config ZEPHYR_.*_MODULE.*').search + with open(modules_file, 'r+') as fp_module_file: + for line in fp_module_file: + if module_definition(line): + module_define_content += line + module_define_content += "\tbool\n" + fp_module_file.seek(0) + fp_module_file.write(module_define_content) + fp_module_file.truncate() + def get_module_setting_root(self, root, settings_file): """ Parse the Zephyr module generated settings file given by 'settings_file'