Skip to content

Commit 769594f

Browse files
tejlmand57300
authored andcommitted
[nrf fromtree] cmake: cleanup hwm_v2.cmake module code
Cleanup the Kconfig generating code in hwm_v2.cmake by moving common logic inside the kconfig_gen() helper function. This prepares the code for board extension feature. Signed-off-by: Torsten Rasmussen <[email protected]> (cherry picked from commit e2f5ac0)
1 parent 5d57637 commit 769594f

File tree

1 file changed

+11
-25
lines changed

1 file changed

+11
-25
lines changed

cmake/modules/hwm_v2.cmake

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ if(NOT HWMv2)
2424
endif()
2525

2626
# Internal helper function for creation of Kconfig files.
27-
function(kconfig_gen bin_dir file dirs)
28-
file(MAKE_DIRECTORY "${bin_dir}")
29-
set(kconfig_file ${bin_dir}/${file})
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+
3032
foreach(dir ${dirs})
3133
cmake_path(CONVERT "${dir}" TO_CMAKE_PATH_LIST dir)
3234
file(APPEND ${kconfig_file} "osource \"${dir}/${file}\"\n")
@@ -92,28 +94,12 @@ while(TRUE)
9294
endwhile()
9395
list(REMOVE_DUPLICATES kconfig_soc_source_dir)
9496

95-
# Support multiple ARCH_ROOT and SOC_ROOT
96-
set(arch_kconfig_file Kconfig)
97-
set(soc_defconfig_file Kconfig.defconfig)
98-
set(soc_zephyr_file Kconfig)
99-
set(soc_kconfig_file Kconfig.soc)
100-
set(soc_sysbuild_file Kconfig.sysbuild)
101-
set(arch_kconfig_header "# Load arch Kconfig descriptions.\n")
102-
set(defconfig_header "# Load Zephyr SoC Kconfig defconfig.\n")
103-
set(soc_zephyr_header "# Load Zephyr SoC Kconfig descriptions.\n")
104-
set(soc_kconfig_header "# Load SoC Kconfig descriptions.\n")
105-
set(soc_sysbuild_header "# Load SoC sysbuild Kconfig descriptions.\n")
106-
file(WRITE ${KCONFIG_BINARY_DIR}/arch/${arch_kconfig_file} "${arch_kconfig_header}")
107-
file(WRITE ${KCONFIG_BINARY_DIR}/soc/${soc_defconfig_file} "${defconfig_header}")
108-
file(WRITE ${KCONFIG_BINARY_DIR}/soc/${soc_zephyr_file} "${soc_zephyr_header}")
109-
file(WRITE ${KCONFIG_BINARY_DIR}/soc/${soc_kconfig_file} "${soc_kconfig_header}")
110-
file(WRITE ${KCONFIG_BINARY_DIR}/soc/${soc_sysbuild_file} "${soc_sysbuild_header}")
111-
112-
kconfig_gen("${KCONFIG_BINARY_DIR}/arch" "${arch_kconfig_file}" "${kconfig_arch_source_dir}")
113-
kconfig_gen("${KCONFIG_BINARY_DIR}/soc" "${soc_defconfig_file}" "${kconfig_soc_source_dir}")
114-
kconfig_gen("${KCONFIG_BINARY_DIR}/soc" "${soc_zephyr_file}" "${kconfig_soc_source_dir}")
115-
kconfig_gen("${KCONFIG_BINARY_DIR}/soc" "${soc_kconfig_file}" "${kconfig_soc_source_dir}")
116-
kconfig_gen("${KCONFIG_BINARY_DIR}/soc" "${soc_sysbuild_file}" "${kconfig_soc_source_dir}")
97+
# Support multiple ARCH_ROOT, SOC_ROOT and BOARD_ROOT
98+
kconfig_gen("arch" "Kconfig" "${kconfig_arch_source_dir}" "Zephyr Arch Kconfig")
99+
kconfig_gen("soc" "Kconfig.defconfig" "${kconfig_soc_source_dir}" "Zephyr SoC defconfig")
100+
kconfig_gen("soc" "Kconfig" "${kconfig_soc_source_dir}" "Zephyr SoC Kconfig")
101+
kconfig_gen("soc" "Kconfig.soc" "${kconfig_soc_source_dir}" "SoC Kconfig")
102+
kconfig_gen("soc" "Kconfig.sysbuild" "${kconfig_soc_source_dir}" "Sysbuild SoC Kconfig")
117103

118104
# Clear variables created by cmake_parse_arguments
119105
unset(SOC_V2_NAME)

0 commit comments

Comments
 (0)