diff --git a/cmake/modules/hwm_v2.cmake b/cmake/modules/hwm_v2.cmake index 45238f212b3..b514a33c5b0 100644 --- a/cmake/modules/hwm_v2.cmake +++ b/cmake/modules/hwm_v2.cmake @@ -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) 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)