@@ -505,6 +505,22 @@ class KconfigCheck(ComplianceTest):
505
505
# Kconfig symbol prefix/namespace.
506
506
CONFIG_ = "CONFIG_"
507
507
508
+ # If modules should be excluded from checks.
509
+ EXCLUDE_MODULES = False
510
+
511
+ # This block list contains a list of upstream Zephyr modules that should not be checked
512
+ # DO NOT MERGE CHANGES TO THIS WITHOUT BUILD SYSTEM AND CODE OWNER APPROVAL!
513
+ external_module_name_block_list = ['canopennode' , 'chre' , 'cmsis' , 'cmsis-dsp' , 'cmsis-nn' ,
514
+ 'cmsis_6' , 'edtt' , 'fatfs' , 'hal_st' , 'hal_tdk' ,
515
+ 'hal_wurthelektronik' , 'liblc3' , 'libmetal' , 'littlefs' ,
516
+ 'loramac-node' , 'lvgl' , 'lz4' , 'mipi-sys-t' , 'nanopb' ,
517
+ 'net-tools' , 'nrf_hw_models' , 'open-amp' , 'percepio' ,
518
+ 'picolibc' , 'segger' , 'tf-m-tests' , 'tinycrypt' ,
519
+ 'uoscore-uedhoc' , 'zscilib' ]
520
+
521
+ # Holds a list or directories/files which should not be checked
522
+ blocked_module_dirs = []
523
+
508
524
def run (self ):
509
525
kconf = self .parse_kconfig ()
510
526
@@ -542,13 +558,22 @@ def get_modules(self, _module_dirs_file, modules_file, sysbuild_modules_file, se
542
558
modules = [name for name in os .listdir (modules_dir ) if
543
559
modules_dir / name / 'Kconfig' ]
544
560
545
- nrf_modules_dir = ZEPHYR_BASE / Path ( '../ nrf/ modules' )
561
+ nrf_modules_dir = ( Path ( ZEPHYR_BASE ) / '..' / ' nrf' / ' modules'). resolve ( )
546
562
nrf_modules = []
563
+
564
+ for module in modules :
565
+ if module in self .external_module_name_block_list :
566
+ self .blocked_module_dirs .append (modules_dir / module / 'Kconfig' )
567
+
547
568
if os .path .exists (nrf_modules_dir ):
548
569
nrf_modules = [name for name in os .listdir (nrf_modules_dir ) if
549
570
os .path .exists (os .path .join (nrf_modules_dir , name ,
550
571
'Kconfig' ))]
551
572
573
+ for module in nrf_modules :
574
+ if module in self .external_module_name_block_list :
575
+ self .blocked_module_dirs .append (nrf_modules_dir / module / 'Kconfig' )
576
+
552
577
with open (modules_file , 'r' ) as fp_module_file :
553
578
content = fp_module_file .read ()
554
579
@@ -567,6 +592,7 @@ def get_modules(self, _module_dirs_file, modules_file, sysbuild_modules_file, se
567
592
re .sub ('[^a-zA-Z0-9]' , '_' , module ).upper (),
568
593
modules_dir / module / 'Kconfig'
569
594
))
595
+
570
596
# Add NRF as static entry as workaround for ext Kconfig root support
571
597
fp_module_file .write ("ZEPHYR_NRF_KCONFIG = {}\n " .format (
572
598
nrf_modules_dir / '..' / 'Kconfig.nrf'
@@ -1052,9 +1078,32 @@ def check_no_enable_in_boolean_prompt(self, kconf):
1052
1078
# Checks that boolean's prompt does not start with "Enable...".
1053
1079
1054
1080
for node in kconf .node_iter ():
1055
- # skip Kconfig nodes not in-tree (will present an absolute path)
1081
+ skip_node = False
1082
+
1083
+ # skip Kconfig nodes not in-tree when set to (will present an absolute path)
1056
1084
if os .path .isabs (node .filename ):
1057
- continue
1085
+ if self .EXCLUDE_MODULES is True :
1086
+ continue
1087
+
1088
+ normalised_file_name = Path (node .filename ).resolve ()
1089
+
1090
+ for module_name in self .external_module_name_block_list :
1091
+ # Workaround for being unable to use full_match() due to python version
1092
+ if '/modules/' in str (normalised_file_name ) and \
1093
+ ('/' + module_name + '/' ) in str (normalised_file_name ):
1094
+ skip_node = True
1095
+ break
1096
+
1097
+ if skip_node :
1098
+ continue
1099
+
1100
+ for blocked_dir in self .blocked_module_dirs :
1101
+ if normalised_file_name .match (blocked_dir , case_sensitive = True ):
1102
+ skip_node = True
1103
+ break
1104
+
1105
+ if skip_node :
1106
+ continue
1058
1107
1059
1108
# 'kconfiglib' is global
1060
1109
# pylint: disable=undefined-variable
@@ -1482,6 +1531,7 @@ class KconfigBasicNoModulesCheck(KconfigBasicCheck):
1482
1531
name = "KconfigBasicNoModules"
1483
1532
path_hint = "<zephyr-base>"
1484
1533
EMPTY_FILE_CONTENTS = "# Empty\n "
1534
+ EXCLUDE_MODULES = True
1485
1535
1486
1536
def get_modules (self , module_dirs_file , modules_file , sysbuild_modules_file , settings_file ):
1487
1537
with open (module_dirs_file , 'w' ) as fp_module_file :
@@ -1574,6 +1624,7 @@ class SysbuildKconfigBasicNoModulesCheck(SysbuildKconfigCheck, KconfigBasicNoMod
1574
1624
"""
1575
1625
name = "SysbuildKconfigBasicNoModules"
1576
1626
path_hint = "<zephyr-base>"
1627
+ EXCLUDE_MODULES = True
1577
1628
1578
1629
1579
1630
class Nits (ComplianceTest ):
0 commit comments