From 6f58159a72e0eeed8a7ed6aec168e8c724ce6a22 Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Wed, 10 Apr 2024 13:58:54 +0100 Subject: [PATCH] cmake: Add support for socs folder and Kconfig fragments Adds support for a new ``socs`` folder that can be placed in application folders and functions similar to the ``boards`` folder, but works for SoCs instead of boards Signed-off-by: Jamie McCrae --- cmake/modules/configuration_files.cmake | 1 + cmake/modules/extensions.cmake | 48 ++++++++++++++++++------- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/cmake/modules/configuration_files.cmake b/cmake/modules/configuration_files.cmake index 78e7bf2a49..dda142441e 100644 --- a/cmake/modules/configuration_files.cmake +++ b/cmake/modules/configuration_files.cmake @@ -45,6 +45,7 @@ endif() zephyr_get(CONF_FILE SYSBUILD LOCAL) if(NOT DEFINED CONF_FILE) zephyr_file(CONF_FILES ${APPLICATION_CONFIG_DIR} KCONF CONF_FILE NAMES "prj.conf" SUFFIX ${FILE_SUFFIX} REQUIRED) + zephyr_file(CONF_FILES ${APPLICATION_CONFIG_DIR}/socs KCONF CONF_FILE QUALIFIERS SUFFIX ${FILE_SUFFIX}) zephyr_file(CONF_FILES ${APPLICATION_CONFIG_DIR}/boards KCONF CONF_FILE SUFFIX ${FILE_SUFFIX}) else() string(CONFIGURE "${CONF_FILE}" CONF_FILE_EXPANDED) diff --git a/cmake/modules/extensions.cmake b/cmake/modules/extensions.cmake index 6833d5de9c..35ab0e246b 100644 --- a/cmake/modules/extensions.cmake +++ b/cmake/modules/extensions.cmake @@ -1538,6 +1538,11 @@ endfunction() # [BUILD ] # [MERGE [REVERSE]] # ) +# zephyr_build_string( +# BOARD_QUALIFIERS +# [BUILD ] +# [MERGE [REVERSE]] +# ) # # : Output variable where the build string will be returned. # SHORT : Output variable where the shortened build string will be returned. @@ -1571,6 +1576,10 @@ endfunction() # `alpha_soc_bar_1_0_0;alpha_soc_bar` in `build_string` parameter. # `alpha_bar_1_0_0;alpha_bar` in `short_build_string` parameter. # +# calling +# zephyr_build_string(build_string BOARD_QUALIFIERS /soc/bar/foo) +# will return the string `soc_bar_foo` in `build_string` parameter. +# function(zephyr_build_string outvar) set(options MERGE REVERSE) set(single_args BOARD BOARD_QUALIFIERS BOARD_REVISION BUILD SHORT) @@ -1590,10 +1599,17 @@ function(zephyr_build_string outvar) ) endif() - if(DEFINED BUILD_STR_BOARD_QUALIFIERS AND NOT BUILD_STR_BOARD) + if(DEFINED BUILD_STR_BOARD_REVISION AND NOT DEFINED BUILD_STR_BOARD) message(FATAL_ERROR - "zephyr_build_string(${ARGV0} BOARD_QUALIFIERS ${BUILD_STR_BOARD_QUALIFIERS} ...)" - " given without BOARD argument, please specify BOARD" + "zephyr_build_string(${ARGV0} BOARD_REVISION ${BUILD_STR_BOARD_REVISION} ...)" + " given without BOARD argument, these must be used together" + ) + endif() + + if(DEFINED BUILD_STR_SHORT AND NOT DEFINED BUILD_STR_BOARD) + message(FATAL_ERROR + "zephyr_build_string(${ARGV0} SHORT ${BUILD_STR_SHORT} ...)" + " given without BOARD argument, these must be used together" ) endif() @@ -2572,7 +2588,7 @@ Please provide one of following: APPLICATION_ROOT, CONF_FILES") if(${ARGV0} STREQUAL APPLICATION_ROOT) set(single_args APPLICATION_ROOT) elseif(${ARGV0} STREQUAL CONF_FILES) - set(options REQUIRED) + set(options QUALIFIERS REQUIRED) set(single_args BOARD BOARD_REVISION BOARD_QUALIFIERS DTS KCONF DEFCONFIG BUILD SUFFIX) set(multi_args CONF_FILES NAMES) endif() @@ -2641,14 +2657,22 @@ Relative paths are only allowed with `-D${ARGV1}=`") set(dts_filename_list ${ZFILE_NAMES}) set(kconf_filename_list ${ZFILE_NAMES}) else() - zephyr_build_string(filename_list - SHORT shortened_filename_list - BOARD ${ZFILE_BOARD} - BOARD_REVISION ${ZFILE_BOARD_REVISION} - BOARD_QUALIFIERS ${ZFILE_BOARD_QUALIFIERS} - BUILD ${ZFILE_BUILD} - MERGE REVERSE - ) + if(NOT ZFILE_QUALIFIERS) + zephyr_build_string(filename_list + SHORT shortened_filename_list + BOARD ${ZFILE_BOARD} + BOARD_REVISION ${ZFILE_BOARD_REVISION} + BOARD_QUALIFIERS ${ZFILE_BOARD_QUALIFIERS} + BUILD ${ZFILE_BUILD} + MERGE REVERSE + ) + else() + zephyr_build_string(filename_list + BOARD_QUALIFIERS ${ZFILE_BOARD_QUALIFIERS} + BUILD ${ZFILE_BUILD} + MERGE REVERSE + ) + endif() set(dts_filename_list ${filename_list}) set(dts_shortened_filename_list ${shortened_filename_list})