@@ -505,6 +505,22 @@ class KconfigCheck(ComplianceTest):
505505 # Kconfig symbol prefix/namespace.
506506 CONFIG_ = "CONFIG_"
507507
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+
508524 def run (self ):
509525 kconf = self .parse_kconfig ()
510526
@@ -542,13 +558,22 @@ def get_modules(self, _module_dirs_file, modules_file, sysbuild_modules_file, se
542558 modules = [name for name in os .listdir (modules_dir ) if
543559 modules_dir / name / 'Kconfig' ]
544560
545- nrf_modules_dir = ZEPHYR_BASE / Path ( '../ nrf/ modules' )
561+ nrf_modules_dir = ( Path ( ZEPHYR_BASE ) / '..' / ' nrf' / ' modules'). resolve ( )
546562 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+
547568 if os .path .exists (nrf_modules_dir ):
548569 nrf_modules = [name for name in os .listdir (nrf_modules_dir ) if
549570 os .path .exists (os .path .join (nrf_modules_dir , name ,
550571 'Kconfig' ))]
551572
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+
552577 with open (modules_file , 'r' ) as fp_module_file :
553578 content = fp_module_file .read ()
554579
@@ -567,6 +592,7 @@ def get_modules(self, _module_dirs_file, modules_file, sysbuild_modules_file, se
567592 re .sub ('[^a-zA-Z0-9]' , '_' , module ).upper (),
568593 modules_dir / module / 'Kconfig'
569594 ))
595+
570596 # Add NRF as static entry as workaround for ext Kconfig root support
571597 fp_module_file .write ("ZEPHYR_NRF_KCONFIG = {}\n " .format (
572598 nrf_modules_dir / '..' / 'Kconfig.nrf'
@@ -1052,9 +1078,32 @@ def check_no_enable_in_boolean_prompt(self, kconf):
10521078 # Checks that boolean's prompt does not start with "Enable...".
10531079
10541080 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)
10561084 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
10581107
10591108 # 'kconfiglib' is global
10601109 # pylint: disable=undefined-variable
@@ -1506,6 +1555,7 @@ class KconfigBasicNoModulesCheck(KconfigBasicCheck):
15061555 name = "KconfigBasicNoModules"
15071556 path_hint = "<zephyr-base>"
15081557 EMPTY_FILE_CONTENTS = "# Empty\n "
1558+ EXCLUDE_MODULES = True
15091559
15101560 def get_modules (self , module_dirs_file , modules_file , sysbuild_modules_file , settings_file ):
15111561 with open (module_dirs_file , 'w' ) as fp_module_file :
@@ -1598,6 +1648,7 @@ class SysbuildKconfigBasicNoModulesCheck(SysbuildKconfigCheck, KconfigBasicNoMod
15981648 """
15991649 name = "SysbuildKconfigBasicNoModules"
16001650 path_hint = "<zephyr-base>"
1651+ EXCLUDE_MODULES = True
16011652
16021653
16031654class Nits (ComplianceTest ):
0 commit comments