@@ -762,6 +762,61 @@ def parse_kconfig(self):
762
762
# Clean up the temporary directory
763
763
shutil .rmtree (kconfiglib_dir )
764
764
765
+ def module_kconfigs (self , regex ):
766
+ manifest = Manifest .from_file ()
767
+ kconfigs = ""
768
+
769
+ # Use hard coded paths for Zephyr for tests, samples and ext. module root
770
+ tmp_output = git ("grep" , "-I" , "-h" , "--perl-regexp" , regex , "--" , ":tests" , ":samples" ,
771
+ ":modules" , cwd = ZEPHYR_BASE , ignore_non_zero = True )
772
+
773
+ if len (tmp_output ) > 0 :
774
+ kconfigs += tmp_output + "\n "
775
+
776
+ for project in manifest .get_projects ([]):
777
+ if not manifest .is_active (project ):
778
+ continue
779
+
780
+ if not project .is_cloned ():
781
+ continue
782
+
783
+ module_path = PurePath (project .abspath )
784
+ module_yml = module_path .joinpath ('zephyr/module.yml' )
785
+
786
+ if not Path (module_yml ).is_file ():
787
+ module_yml = module_path .joinpath ('zephyr/module.yaml' )
788
+
789
+ if Path (module_yml ).is_file ():
790
+ dirs = []
791
+
792
+ with Path (module_yml ).open ('r' , encoding = 'utf-8' ) as f :
793
+ meta = yaml .load (f .read (), Loader = SafeLoader )
794
+
795
+ for folder_type in ['samples' , 'tests' ]:
796
+ if folder_type in meta :
797
+ for path_ext in meta [folder_type ]:
798
+ path_full = module_path .joinpath (path_ext )
799
+
800
+ if Path (path_full ).is_dir ():
801
+ dirs .append (":" + path_ext )
802
+
803
+ # Add ext. module root, if one is defined
804
+ if 'build' in meta and 'settings' in meta ['build' ] and \
805
+ 'module_ext_root' in meta ['build' ]['settings' ]:
806
+ path_full = module_path .joinpath (meta ['build' ]['settings' ]['module_ext_root' ])
807
+
808
+ if Path (path_full ).is_dir ():
809
+ dirs .append (":" + meta ['build' ]['settings' ]['module_ext_root' ])
810
+
811
+ if len (dirs ) > 0 :
812
+ tmp_output = git ("grep" , "-I" , "-h" , "--perl-regexp" , regex , "--" ,
813
+ * dirs , cwd = module_path , ignore_non_zero = True )
814
+
815
+ if len (tmp_output ) > 0 :
816
+ kconfigs += tmp_output + "\n "
817
+
818
+ return kconfigs
819
+
765
820
def get_logging_syms (self , kconf ):
766
821
# Returns a set() with the names of the Kconfig symbols generated with
767
822
# logging template in samples/tests folders. The Kconfig symbols doesn't
@@ -782,9 +837,8 @@ def get_logging_syms(self, kconf):
782
837
# Warning: Needs to work with both --perl-regexp and the 're' module.
783
838
regex = r"^\s*(?:module\s*=\s*)([A-Z0-9_]+)\s*(?:#|$)"
784
839
785
- # Grep samples/ and tests/ for symbol definitions
786
- grep_stdout = git ("grep" , "-I" , "-h" , "--perl-regexp" , regex , "--" ,
787
- ":samples" , ":tests" , cwd = ZEPHYR_BASE )
840
+ # Grep samples/ and tests/ for symbol definitions in all modules
841
+ grep_stdout = self .module_kconfigs (regex )
788
842
789
843
names = re .findall (regex , grep_stdout , re .MULTILINE )
790
844
@@ -931,9 +985,8 @@ def get_defined_syms(self, kconf):
931
985
# (?:...) is a non-capturing group.
932
986
regex = r"^\s*(?:menu)?config\s*([A-Z0-9_]+)\s*(?:#|$)"
933
987
934
- # Grep samples/ and tests/ for symbol definitions
935
- grep_stdout = git ("grep" , "-I" , "-h" , "--perl-regexp" , regex , "--" ,
936
- ":samples" , ":tests" , cwd = ZEPHYR_BASE )
988
+ # Grep samples/ and tests/ for symbol definitions in all modules
989
+ grep_stdout = self .module_kconfigs (regex )
937
990
938
991
# Generate combined list of configs and choices from the main Kconfig tree.
939
992
kconf_syms = kconf .unique_defined_syms + kconf .unique_choices
0 commit comments