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 <jamie.mccrae@nordicsemi.no>
This commit is contained in:
Jamie McCrae 2024-04-10 13:58:54 +01:00 committed by Fabio Baltieri
parent 43c323a835
commit 6f58159a72
2 changed files with 37 additions and 12 deletions

View File

@ -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)

View File

@ -1538,6 +1538,11 @@ endfunction()
# [BUILD <type>]
# [MERGE [REVERSE]]
# )
# zephyr_build_string(<out-variable>
# BOARD_QUALIFIERS <qualifiers>
# [BUILD <type>]
# [MERGE [REVERSE]]
# )
#
# <out-variable>: Output variable where the build string will be returned.
# SHORT <out-variable>: 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} <list> BOARD_QUALIFIERS ${BUILD_STR_BOARD_QUALIFIERS} ...)"
" given without BOARD argument, please specify BOARD"
"zephyr_build_string(${ARGV0} <list> 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} <list> 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}=<path>`")
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})