Skip to content

Commit a87eec5

Browse files
nashifcarlescufi
authored andcommitted
cmake: Add board emulator extension functions
Adds new CMake extension functions that allow setting board-specific emulator arguments, similar to existing support for setting board-specific runner arguments. Originally authored by: Maureen Helm Signed-off-by: Anas Nashif <[email protected]>
1 parent 6b4ee8c commit a87eec5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

cmake/modules/extensions.cmake

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,39 @@ function(board_set_rimage_target target)
860860
zephyr_check_cache(RIMAGE_TARGET)
861861
endfunction()
862862

863+
function(board_emu_args emu)
864+
string(MAKE_C_IDENTIFIER ${emu} emu_id)
865+
# Note the "_EXPLICIT_" here, and see below.
866+
set_property(GLOBAL APPEND PROPERTY BOARD_EMU_ARGS_EXPLICIT_${emu_id} ${ARGN})
867+
endfunction()
868+
869+
function(board_finalize_emu_args emu)
870+
# If the application provided a macro to add additional emu
871+
# arguments, handle them.
872+
if(COMMAND app_set_emu_args)
873+
app_set_emu_args()
874+
endif()
875+
876+
# Retrieve the list of explicitly set arguments.
877+
string(MAKE_C_IDENTIFIER ${emu} emu_id)
878+
get_property(explicit GLOBAL PROPERTY "BOARD_EMU_ARGS_EXPLICIT_${emu_id}")
879+
880+
# Note no _EXPLICIT_ here. This property contains the final list.
881+
set_property(GLOBAL APPEND PROPERTY BOARD_EMU_ARGS_${emu_id}
882+
# Default arguments from the common emu file come first.
883+
${ARGN}
884+
# Arguments explicitly given with board_emu_args() come
885+
# next, so they take precedence over the common emu file.
886+
${explicit}
887+
# Arguments given via the CMake cache come last of all. Users
888+
# can provide variables in this way from the CMake command line.
889+
${BOARD_EMU_ARGS_${emu_id}}
890+
)
891+
892+
# Add the finalized emu to the global property list.
893+
set_property(GLOBAL APPEND PROPERTY ZEPHYR_EMUS ${emu})
894+
endfunction()
895+
863896
# Zephyr board revision:
864897
#
865898
# This section provides a function for revision checking.

0 commit comments

Comments
 (0)