From 105a2bae84ab58164e8b801ee884726fcd1d0679 Mon Sep 17 00:00:00 2001 From: Grzegorz Swiderski Date: Thu, 15 Feb 2024 18:08:34 +0100 Subject: [PATCH] cmake: modules: boards: Fix board deprecation for HWMv2 Deprecating boards comes with similar challenges as with board aliases, since BOARD_DEPRECATED is also set after parsing BOARD as user input. With this patch, a deprecated board can be properly translated to a board with identifiers. This opens up the possibility of recording all legacy board names in `boards/deprecated.cmake`, such as: set(mps2_an521_remote_DEPRECATED mps2/an521/cpu1) Unlike with aliases, though, there are additional restrictions for building with BOARD=, which only makes this feature suitable for deprecating v1 boards: * BOARD=/ is never allowed. * BOARD=@ is not allowed if the old board already corresponds to a new board revision: set(_DEPRECATED @) Future enhancements will be needed for deprecating v2 boards. Signed-off-by: Grzegorz Swiderski --- cmake/modules/boards.cmake | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/cmake/modules/boards.cmake b/cmake/modules/boards.cmake index e8d4fbb344e..0854653445d 100644 --- a/cmake/modules/boards.cmake +++ b/cmake/modules/boards.cmake @@ -92,11 +92,30 @@ if(DEFINED ZEPHYR_BOARD_ALIASES) set(BOARD_IDENTIFIER ${BOARD_ALIAS_IDENTIFIER}${BOARD_IDENTIFIER}) endif() endif() + include(${ZEPHYR_BASE}/boards/deprecated.cmake) if(${BOARD}_DEPRECATED) set(BOARD_DEPRECATED ${BOARD} CACHE STRING "Deprecated board name, provided by user") - set(BOARD ${${BOARD}_DEPRECATED}) + parse_board_components(${BOARD}_DEPRECATED BOARD BOARD_DEPRECATED_REVISION BOARD_DEPRECATED_IDENTIFIER) message(WARNING "Deprecated BOARD=${BOARD_DEPRECATED} name specified, board automatically changed to: ${BOARD}.") + if(DEFINED BOARD_DEPRECATED_REVISION) + if(DEFINED BOARD_REVISION) + message(FATAL_ERROR + "Invalid board revision: ${BOARD_REVISION}\n" + "Deprecated board '${BOARD_DEPRECATED}' is now implemented as a revision of another board " + "(${BOARD}@${BOARD_DEPRECATED_REVISION}), so the specified revision does not apply. " + "Please consult the documentation for '${BOARD}' to see how to build for the new board." + ) + endif() + set(BOARD_REVISION ${BOARD_DEPRECATED_REVISION}) + endif() + if(DEFINED BOARD_IDENTIFIER) + message(FATAL_ERROR + "Deprecated boards cannot have board identifiers: ${BOARD_DEPRECATED}${BOARD_IDENTIFIER}.\n" + "Please consult the documentation for '${BOARD}' to see how to build for the new board." + ) + endif() + set(BOARD_IDENTIFIER ${BOARD_DEPRECATED_IDENTIFIER}) endif() zephyr_boilerplate_watch(BOARD)