From 1bc640b97255819a0c4f022a5bc08ef2670e7e1d Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Mon, 16 Mar 2020 15:36:52 +0100 Subject: [PATCH] cmake: deprecation of board names This commit introduces boards/deprecated.cmake to allow deprecation of existing boards, when a board is renamed. This allows users to still specify the old board name, and let Zephyr build system to select the new board name. Signed-off-by: Torsten Rasmussen --- CODEOWNERS | 1 + boards/deprecated.cmake | 11 +++++++++++ cmake/app/boilerplate.cmake | 9 ++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 boards/deprecated.cmake diff --git a/CODEOWNERS b/CODEOWNERS index 1ac415f9a25..e94dbc5c739 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -99,6 +99,7 @@ /boards/arm/stm32f3_disco/ @ydamigos /boards/arm/stm32*_eval/ @erwango /boards/common/ @mbolivar-nordic +/boards/deprecated.cmake @tejlmand /boards/nios2/ @wentongwu /boards/nios2/altera_max10/ @wentongwu /boards/arm/stm32_min_dev/ @cbsiddharth diff --git a/boards/deprecated.cmake b/boards/deprecated.cmake new file mode 100644 index 00000000000..fe618b596b4 --- /dev/null +++ b/boards/deprecated.cmake @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: Apache-2.0 + +# This file contains boards in Zephyr which has been replaced with a new board +# name. +# This allows the system to automatically change the board while at the same +# time prints a warning to the user, that the board name is deprecated. +# +# To add a board rename, add a line in following format: +# set(_DEPRECATED ) + +set(nrf51_pca10028_DEPRECATED nrf51dk_nrf51422) diff --git a/cmake/app/boilerplate.cmake b/cmake/app/boilerplate.cmake index 51b521e4a28..7cc79d48262 100644 --- a/cmake/app/boilerplate.cmake +++ b/cmake/app/boilerplate.cmake @@ -158,7 +158,7 @@ if(CACHED_BOARD) # Warn the user if it looks like he is trying to change the board # without cleaning first if(board_cli_argument) - if(NOT (CACHED_BOARD STREQUAL board_cli_argument)) + if(NOT ((CACHED_BOARD STREQUAL board_cli_argument) OR (BOARD_DEPRECATED STREQUAL board_cli_argument))) message(WARNING "The build directory must be cleaned pristinely when changing boards") # TODO: Support changing boards without requiring a clean build endif() @@ -181,6 +181,13 @@ endif() assert(BOARD "BOARD not set") message(STATUS "Board: ${BOARD}") +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}) + message(WARNING "Deprecated BOARD=${BOARD_DEPRECATED} name specified, board automatically changed to: ${BOARD}.") +endif() + # Store the selected board in the cache set(CACHED_BOARD ${BOARD} CACHE STRING "Selected board")