@@ -723,6 +723,61 @@ def parse_kconfig(self):
723
723
# Clean up the temporary directory
724
724
shutil .rmtree (kconfiglib_dir )
725
725
726
+ def module_kconfigs (self , regex ):
727
+ manifest = Manifest .from_file ()
728
+ kconfigs = ""
729
+
730
+ # Use hard coded paths for Zephyr for tests, samples and ext. module root
731
+ tmp_output = git ("grep" , "-I" , "-h" , "--perl-regexp" , regex , "--" , ":tests" , ":samples" ,
732
+ ":modules" , cwd = ZEPHYR_BASE , ignore_non_zero = True )
733
+
734
+ if len (tmp_output ) > 0 :
735
+ kconfigs += tmp_output + "\n "
736
+
737
+ for project in manifest .get_projects ([]):
738
+ if not manifest .is_active (project ):
739
+ continue
740
+
741
+ if not project .is_cloned ():
742
+ continue
743
+
744
+ module_path = PurePath (project .abspath )
745
+ module_yml = module_path .joinpath ('zephyr/module.yml' )
746
+
747
+ if not Path (module_yml ).is_file ():
748
+ module_yml = module_path .joinpath ('zephyr/module.yaml' )
749
+
750
+ if Path (module_yml ).is_file ():
751
+ dirs = []
752
+
753
+ with Path (module_yml ).open ('r' , encoding = 'utf-8' ) as f :
754
+ meta = yaml .load (f .read (), Loader = SafeLoader )
755
+
756
+ for folder_type in ['samples' , 'tests' ]:
757
+ if folder_type in meta :
758
+ for path_ext in meta [folder_type ]:
759
+ path_full = module_path .joinpath (path_ext )
760
+
761
+ if Path (path_full ).is_dir ():
762
+ dirs .append (":" + path_ext )
763
+
764
+ # Add ext. module root, if one is defined
765
+ if 'build' in meta and 'settings' in meta ['build' ] and \
766
+ 'module_ext_root' in meta ['build' ]['settings' ]:
767
+ path_full = module_path .joinpath (meta ['build' ]['settings' ]['module_ext_root' ])
768
+
769
+ if Path (path_full ).is_dir ():
770
+ dirs .append (":" + meta ['build' ]['settings' ]['module_ext_root' ])
771
+
772
+ if len (dirs ) > 0 :
773
+ tmp_output = git ("grep" , "-I" , "-h" , "--perl-regexp" , regex , "--" ,
774
+ * dirs , cwd = module_path , ignore_non_zero = True )
775
+
776
+ if len (tmp_output ) > 0 :
777
+ kconfigs += tmp_output + "\n "
778
+
779
+ return kconfigs
780
+
726
781
def get_logging_syms (self , kconf ):
727
782
# Returns a set() with the names of the Kconfig symbols generated with
728
783
# logging template in samples/tests folders. The Kconfig symbols doesn't
@@ -743,9 +798,8 @@ def get_logging_syms(self, kconf):
743
798
# Warning: Needs to work with both --perl-regexp and the 're' module.
744
799
regex = r"^\s*(?:module\s*=\s*)([A-Z0-9_]+)\s*(?:#|$)"
745
800
746
- # Grep samples/ and tests/ for symbol definitions
747
- grep_stdout = git ("grep" , "-I" , "-h" , "--perl-regexp" , regex , "--" ,
748
- ":samples" , ":tests" , cwd = ZEPHYR_BASE )
801
+ # Grep samples/ and tests/ for symbol definitions in all modules
802
+ grep_stdout = self .module_kconfigs (regex )
749
803
750
804
names = re .findall (regex , grep_stdout , re .MULTILINE )
751
805
@@ -898,9 +952,8 @@ def get_defined_syms(self, kconf):
898
952
# (?:...) is a non-capturing group.
899
953
regex = r"^\s*(?:menu)?config\s*([A-Z0-9_]+)\s*(?:#|$)"
900
954
901
- # Grep samples/ and tests/ for symbol definitions
902
- grep_stdout = git ("grep" , "-I" , "-h" , "--perl-regexp" , regex , "--" ,
903
- ":samples" , ":tests" , cwd = ZEPHYR_BASE )
955
+ # Grep samples/ and tests/ for symbol definitions in all modules
956
+ grep_stdout = self .module_kconfigs (regex )
904
957
905
958
# Generate combined list of configs and choices from the main Kconfig tree.
906
959
kconf_syms = kconf .unique_defined_syms + kconf .unique_choices
0 commit comments