Skip to content

Commit dbbf95a

Browse files
committed
cmake: move function for creation of Kconfig files to extensions
This function can be useful outside of HWMv2, for example to add Kconfig files to snippets. Signed-off-by: Johann Fischer <[email protected]>
1 parent c50777a commit dbbf95a

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

cmake/modules/extensions.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,6 +1954,25 @@ function(import_kconfig prefix kconfig_fragment)
19541954
endif()
19551955
endfunction()
19561956

1957+
# kconfig_gen(<binary_directory> <kconfig_file_name> <kconfig_directories> <comment>)
1958+
#
1959+
# Helper function for creation of Kconfig files
1960+
#
1961+
# <bin_dir> : Binary directory, such as: arch, soc, boards, snippets
1962+
# <file> : Kconfig file name, sich as: Kconfig, Kconfig.defconfig, Kconfig.sysbuild
1963+
# <dirs> : Kconfig directories
1964+
# <comment > : Comment
1965+
function(kconfig_gen bin_dir file dirs comment)
1966+
set(kconfig_header "# Load ${comment} descriptions.\n")
1967+
set(kconfig_file ${KCONFIG_BINARY_DIR}/${bin_dir}/${file})
1968+
file(WRITE ${kconfig_file} "${kconfig_header}")
1969+
1970+
foreach(dir ${dirs})
1971+
cmake_path(CONVERT "${dir}" TO_CMAKE_PATH_LIST dir)
1972+
file(APPEND ${kconfig_file} "osource \"${dir}/${file}\"\n")
1973+
endforeach()
1974+
endfunction()
1975+
19571976
########################################################
19581977
# 3. CMake-generic extensions
19591978
########################################################

cmake/modules/hwm_v2.cmake

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,6 @@ if(NOT HWMv2)
2323
return()
2424
endif()
2525

26-
# Internal helper function for creation of Kconfig files.
27-
function(kconfig_gen bin_dir file dirs comment)
28-
set(kconfig_header "# Load ${comment} descriptions.\n")
29-
set(kconfig_file ${KCONFIG_BINARY_DIR}/${bin_dir}/${file})
30-
file(WRITE ${kconfig_file} "${kconfig_header}")
31-
32-
foreach(dir ${dirs})
33-
cmake_path(CONVERT "${dir}" TO_CMAKE_PATH_LIST dir)
34-
file(APPEND ${kconfig_file} "osource \"${dir}/${file}\"\n")
35-
endforeach()
36-
endfunction()
37-
3826
# 'SOC_ROOT' and 'ARCH_ROOT' are prioritized lists of directories where their
3927
# implementations may be found. It always includes ${ZEPHYR_BASE}/[arch|soc]
4028
# at the lowest priority.

0 commit comments

Comments
 (0)