@@ -753,6 +753,61 @@ def parse_kconfig(self):
753753            # Clean up the temporary directory 
754754            shutil .rmtree (kconfiglib_dir )
755755
756+     def  module_kconfigs (self , regex ):
757+         manifest  =  Manifest .from_file ()
758+         kconfigs  =  "" 
759+ 
760+         # Use hard coded paths for Zephyr for tests, samples and ext. module root 
761+         tmp_output  =  git ("grep" , "-I" , "-h" , "--perl-regexp" , regex , "--" , ":tests" , ":samples" ,
762+                          ":modules" , cwd = ZEPHYR_BASE , ignore_non_zero = True )
763+ 
764+         if  len (tmp_output ) >  0 :
765+             kconfigs  +=  tmp_output  +  "\n " 
766+ 
767+         for  project  in  manifest .get_projects ([]):
768+             if  not  manifest .is_active (project ):
769+                 continue 
770+ 
771+             if  not  project .is_cloned ():
772+                 continue 
773+ 
774+             module_path  =  PurePath (project .abspath )
775+             module_yml  =  module_path .joinpath ('zephyr/module.yml' )
776+ 
777+             if  not  Path (module_yml ).is_file ():
778+                 module_yml  =  module_path .joinpath ('zephyr/module.yaml' )
779+ 
780+             if  Path (module_yml ).is_file ():
781+                 dirs  =  []
782+ 
783+                 with  Path (module_yml ).open ('r' , encoding = 'utf-8' ) as  f :
784+                     meta  =  yaml .load (f .read (), Loader = SafeLoader )
785+ 
786+                 for  folder_type  in  ['samples' , 'tests' ]:
787+                     if  folder_type  in  meta :
788+                         for  path_ext  in  meta [folder_type ]:
789+                             path_full  =  module_path .joinpath (path_ext )
790+ 
791+                             if  Path (path_full ).is_dir ():
792+                                 dirs .append (":"  +  path_ext )
793+ 
794+                 # Add ext. module root, if one is defined 
795+                 if  'build'  in  meta  and  'settings'  in  meta ['build' ] and  \
796+                      'module_ext_root'  in  meta ['build' ]['settings' ]:
797+                     path_full  =  module_path .joinpath (meta ['build' ]['settings' ]['module_ext_root' ])
798+ 
799+                     if  Path (path_full ).is_dir ():
800+                         dirs .append (":"  +  meta ['build' ]['settings' ]['module_ext_root' ])
801+ 
802+                 if  len (dirs ) >  0 :
803+                     tmp_output  =  git ("grep" , "-I" , "-h" , "--perl-regexp" , regex , "--" ,
804+                                      * dirs , cwd = module_path , ignore_non_zero = True )
805+ 
806+                     if  len (tmp_output ) >  0 :
807+                         kconfigs  +=  tmp_output  +  "\n " 
808+ 
809+         return  kconfigs 
810+ 
756811    def  get_logging_syms (self , kconf ):
757812        # Returns a set() with the names of the Kconfig symbols generated with 
758813        # logging template in samples/tests folders. The Kconfig symbols doesn't 
@@ -773,9 +828,8 @@ def get_logging_syms(self, kconf):
773828        # Warning: Needs to work with both --perl-regexp and the 're' module. 
774829        regex  =  r"^\s*(?:module\s*=\s*)([A-Z0-9_]+)\s*(?:#|$)" 
775830
776-         # Grep samples/ and tests/ for symbol definitions 
777-         grep_stdout  =  git ("grep" , "-I" , "-h" , "--perl-regexp" , regex , "--" ,
778-                           ":samples" , ":tests" , cwd = ZEPHYR_BASE )
831+         # Grep samples/ and tests/ for symbol definitions in all modules 
832+         grep_stdout  =  self .module_kconfigs (regex )
779833
780834        names  =  re .findall (regex , grep_stdout , re .MULTILINE )
781835
@@ -922,9 +976,8 @@ def get_defined_syms(self, kconf):
922976        # (?:...) is a non-capturing group. 
923977        regex  =  r"^\s*(?:menu)?config\s*([A-Z0-9_]+)\s*(?:#|$)" 
924978
925-         # Grep samples/ and tests/ for symbol definitions 
926-         grep_stdout  =  git ("grep" , "-I" , "-h" , "--perl-regexp" , regex , "--" ,
927-                           ":samples" , ":tests" , cwd = ZEPHYR_BASE )
979+         # Grep samples/ and tests/ for symbol definitions in all modules 
980+         grep_stdout  =  self .module_kconfigs (regex )
928981
929982        # Generate combined list of configs and choices from the main Kconfig tree. 
930983        kconf_syms  =  kconf .unique_defined_syms  +  kconf .unique_choices 
0 commit comments