@@ -386,10 +386,13 @@ def kconfig_snippet(meta, path, kconfig_file=None, blobs=False, taint_blobs=Fals
386386 return '\n ' .join (snippet )
387387
388388
389- def process_kconfig_module_dir (module , meta ):
389+ def process_kconfig_module_dir (module , meta , cmake_output ):
390390 module_path = PurePath (module )
391391 name_sanitized = meta ['name-sanitized' ]
392- return f'ZEPHYR_{ name_sanitized .upper ()} _MODULE_DIR={ module_path .as_posix ()} \n '
392+
393+ if cmake_output is False :
394+ return f'ZEPHYR_{ name_sanitized .upper ()} _MODULE_DIR={ module_path .as_posix ()} \n '
395+ return f'list(APPEND kconfig_env_dirs ZEPHYR_{ name_sanitized .upper ()} _MODULE_DIR={ module_path .as_posix ()} )\n '
393396
394397
395398def process_kconfig (module , meta ):
@@ -870,6 +873,7 @@ def main():
870873 args = parser .parse_args ()
871874
872875 kconfig_module_dirs = ""
876+ kconfig_module_dirs_cmake = "set(kconfig_env_dirs)\n "
873877 kconfig = ""
874878 cmake = ""
875879 sysbuild_kconfig = ""
@@ -882,7 +886,8 @@ def main():
882886 args .modules , args .extra_modules )
883887
884888 for module in modules :
885- kconfig_module_dirs += process_kconfig_module_dir (module .project , module .meta )
889+ kconfig_module_dirs += process_kconfig_module_dir (module .project , module .meta , False )
890+ kconfig_module_dirs_cmake += process_kconfig_module_dir (module .project , module .meta , True )
886891 kconfig += process_kconfig (module .project , module .meta )
887892 cmake += process_cmake (module .project , module .meta )
888893 sysbuild_kconfig += process_sysbuildkconfig (
@@ -894,13 +899,20 @@ def main():
894899 if args .kconfig_out or args .sysbuild_kconfig_out :
895900 if args .kconfig_out :
896901 kconfig_module_dirs_out = PurePath (args .kconfig_out ).parent / 'kconfig_module_dirs.env'
902+ kconfig_module_dirs_cmake_out = PurePath (args .kconfig_out ).parent / \
903+ 'kconfig_module_dirs.cmake'
897904 elif args .sysbuild_kconfig_out :
898905 kconfig_module_dirs_out = PurePath (args .sysbuild_kconfig_out ).parent / \
899906 'kconfig_module_dirs.env'
907+ kconfig_module_dirs_cmake_out = PurePath (args .sysbuild_kconfig_out ).parent / \
908+ 'kconfig_module_dirs.cmake'
900909
901910 with open (kconfig_module_dirs_out , 'w' , encoding = "utf-8" ) as fp :
902911 fp .write (kconfig_module_dirs )
903912
913+ with open (kconfig_module_dirs_cmake_out , 'w' , encoding = "utf-8" ) as fp :
914+ fp .write (kconfig_module_dirs_cmake )
915+
904916 if args .kconfig_out :
905917 with open (args .kconfig_out , 'w' , encoding = "utf-8" ) as fp :
906918 fp .write (kconfig )
0 commit comments