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