Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 55 additions & 3 deletions scripts/ci/check_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,22 @@ class KconfigCheck(ComplianceTest):
# Kconfig symbol prefix/namespace.
CONFIG_ = "CONFIG_"

# If modules should be excluded from checks.
EXCLUDE_MODULES = False

# This block list contains a list of upstream Zephyr modules that should not be checked
# DO NOT MERGE CHANGES TO THIS WITHOUT BUILD SYSTEM AND CODE OWNER APPROVAL!
external_module_name_block_list = ['canopennode', 'chre', 'cmsis', 'cmsis-dsp', 'cmsis-nn',
'cmsis_6', 'edtt', 'fatfs', 'hal_st', 'hal_tdk',
'hal_wurthelektronik', 'liblc3', 'libmetal', 'littlefs',
'loramac-node', 'lvgl', 'lz4', 'mipi-sys-t', 'nanopb',
'net-tools', 'nrf_hw_models', 'open-amp', 'percepio',
'picolibc', 'segger', 'tf-m-tests', 'tinycrypt',
'uoscore-uedhoc', 'zscilib']

# Holds a list or directories/files which should not be checked
blocked_module_dirs = []

def run(self):
kconf = self.parse_kconfig()

Expand Down Expand Up @@ -542,13 +558,22 @@ def get_modules(self, _module_dirs_file, modules_file, sysbuild_modules_file, se
modules = [name for name in os.listdir(modules_dir) if
modules_dir / name / 'Kconfig']

nrf_modules_dir = ZEPHYR_BASE / Path('../nrf/modules')
nrf_modules_dir = (Path(ZEPHYR_BASE) / '..' / 'nrf' / 'modules').resolve()
nrf_modules = []

for module in modules:
if module in self.external_module_name_block_list:
self.blocked_module_dirs.append(modules_dir / module / 'Kconfig')

if os.path.exists(nrf_modules_dir):
nrf_modules = [name for name in os.listdir(nrf_modules_dir) if
os.path.exists(os.path.join(nrf_modules_dir, name,
'Kconfig'))]

for module in nrf_modules:
if module in self.external_module_name_block_list:
self.blocked_module_dirs.append(nrf_modules_dir / module / 'Kconfig')

with open(modules_file, 'r') as fp_module_file:
content = fp_module_file.read()

Expand All @@ -567,6 +592,7 @@ def get_modules(self, _module_dirs_file, modules_file, sysbuild_modules_file, se
re.sub('[^a-zA-Z0-9]', '_', module).upper(),
modules_dir / module / 'Kconfig'
))

# Add NRF as static entry as workaround for ext Kconfig root support
fp_module_file.write("ZEPHYR_NRF_KCONFIG = {}\n".format(
nrf_modules_dir / '..' / 'Kconfig.nrf'
Expand Down Expand Up @@ -1052,9 +1078,32 @@ def check_no_enable_in_boolean_prompt(self, kconf):
# Checks that boolean's prompt does not start with "Enable...".

for node in kconf.node_iter():
# skip Kconfig nodes not in-tree (will present an absolute path)
skip_node = False

# skip Kconfig nodes not in-tree when set to (will present an absolute path)
if os.path.isabs(node.filename):
continue
if self.EXCLUDE_MODULES is True:
continue

normalised_file_name = Path(node.filename).resolve()

for module_name in self.external_module_name_block_list:
# Workaround for being unable to use full_match() due to python version
if '/modules/' in str(normalised_file_name) and \
('/' + module_name + '/') in str(normalised_file_name):
skip_node = True
break

if skip_node:
continue

for blocked_dir in self.blocked_module_dirs:
if normalised_file_name.match(blocked_dir, case_sensitive=True):
skip_node = True
break

if skip_node:
continue

# 'kconfiglib' is global
# pylint: disable=undefined-variable
Expand Down Expand Up @@ -1183,6 +1232,7 @@ def check_no_undef_outside_kconfig(self, kconf):
":!/doc/nrf/releases_and_maturity",
":!/doc/nrf/libraries/bin/lwm2m_carrier/CHANGELOG.rst",
":!/doc/nrf/app_dev/device_guides/nrf70/wifi_advanced_security_modes.rst",
":!/doc/nrf-bm/release_notes",
cwd=GIT_TOP)

# splitlines() supports various line terminators
Expand Down Expand Up @@ -1482,6 +1532,7 @@ class KconfigBasicNoModulesCheck(KconfigBasicCheck):
name = "KconfigBasicNoModules"
path_hint = "<zephyr-base>"
EMPTY_FILE_CONTENTS = "# Empty\n"
EXCLUDE_MODULES = True

def get_modules(self, module_dirs_file, modules_file, sysbuild_modules_file, settings_file):
with open(module_dirs_file, 'w') as fp_module_file:
Expand Down Expand Up @@ -1574,6 +1625,7 @@ class SysbuildKconfigBasicNoModulesCheck(SysbuildKconfigCheck, KconfigBasicNoMod
"""
name = "SysbuildKconfigBasicNoModules"
path_hint = "<zephyr-base>"
EXCLUDE_MODULES = True


class Nits(ComplianceTest):
Expand Down
Loading