Browse Source

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 <Torsten.Rasmussen@nordicsemi.no>
pull/80202/head
Torsten Rasmussen 1 year ago committed by Henrik Brix Andersen
parent
commit
e2f5ac01c7
  1. 36
      cmake/modules/hwm_v2.cmake

36
cmake/modules/hwm_v2.cmake

@ -24,9 +24,11 @@ if(NOT HWMv2) @@ -24,9 +24,11 @@ if(NOT HWMv2)
endif()
# Internal helper function for creation of Kconfig files.
function(kconfig_gen bin_dir file dirs)
file(MAKE_DIRECTORY "${bin_dir}")
set(kconfig_file ${bin_dir}/${file})
function(kconfig_gen bin_dir file dirs comment)
set(kconfig_header "# Load ${comment} descriptions.\n")
set(kconfig_file ${KCONFIG_BINARY_DIR}/${bin_dir}/${file})
file(WRITE ${kconfig_file} "${kconfig_header}")
foreach(dir ${dirs})
cmake_path(CONVERT "${dir}" TO_CMAKE_PATH_LIST dir)
file(APPEND ${kconfig_file} "osource \"${dir}/${file}\"\n")
@ -92,28 +94,12 @@ while(TRUE) @@ -92,28 +94,12 @@ while(TRUE)
endwhile()
list(REMOVE_DUPLICATES kconfig_soc_source_dir)
# Support multiple ARCH_ROOT and SOC_ROOT
set(arch_kconfig_file Kconfig)
set(soc_defconfig_file Kconfig.defconfig)
set(soc_zephyr_file Kconfig)
set(soc_kconfig_file Kconfig.soc)
set(soc_sysbuild_file Kconfig.sysbuild)
set(arch_kconfig_header "# Load arch Kconfig descriptions.\n")
set(defconfig_header "# Load Zephyr SoC Kconfig defconfig.\n")
set(soc_zephyr_header "# Load Zephyr SoC Kconfig descriptions.\n")
set(soc_kconfig_header "# Load SoC Kconfig descriptions.\n")
set(soc_sysbuild_header "# Load SoC sysbuild Kconfig descriptions.\n")
file(WRITE ${KCONFIG_BINARY_DIR}/arch/${arch_kconfig_file} "${arch_kconfig_header}")
file(WRITE ${KCONFIG_BINARY_DIR}/soc/${soc_defconfig_file} "${defconfig_header}")
file(WRITE ${KCONFIG_BINARY_DIR}/soc/${soc_zephyr_file} "${soc_zephyr_header}")
file(WRITE ${KCONFIG_BINARY_DIR}/soc/${soc_kconfig_file} "${soc_kconfig_header}")
file(WRITE ${KCONFIG_BINARY_DIR}/soc/${soc_sysbuild_file} "${soc_sysbuild_header}")
kconfig_gen("${KCONFIG_BINARY_DIR}/arch" "${arch_kconfig_file}" "${kconfig_arch_source_dir}")
kconfig_gen("${KCONFIG_BINARY_DIR}/soc" "${soc_defconfig_file}" "${kconfig_soc_source_dir}")
kconfig_gen("${KCONFIG_BINARY_DIR}/soc" "${soc_zephyr_file}" "${kconfig_soc_source_dir}")
kconfig_gen("${KCONFIG_BINARY_DIR}/soc" "${soc_kconfig_file}" "${kconfig_soc_source_dir}")
kconfig_gen("${KCONFIG_BINARY_DIR}/soc" "${soc_sysbuild_file}" "${kconfig_soc_source_dir}")
# Support multiple ARCH_ROOT, SOC_ROOT and BOARD_ROOT
kconfig_gen("arch" "Kconfig" "${kconfig_arch_source_dir}" "Zephyr Arch Kconfig")
kconfig_gen("soc" "Kconfig.defconfig" "${kconfig_soc_source_dir}" "Zephyr SoC defconfig")
kconfig_gen("soc" "Kconfig" "${kconfig_soc_source_dir}" "Zephyr SoC Kconfig")
kconfig_gen("soc" "Kconfig.soc" "${kconfig_soc_source_dir}" "SoC Kconfig")
kconfig_gen("soc" "Kconfig.sysbuild" "${kconfig_soc_source_dir}" "Sysbuild SoC Kconfig")
# Clear variables created by cmake_parse_arguments
unset(SOC_V2_NAME)

Loading…
Cancel
Save