From 2630fbaa75f3e6a412134949eae3d4d183d4c9b1 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Fri, 24 Jan 2020 09:39:40 -0600 Subject: [PATCH] cmake: Introduce optional Kconfig for toolchains MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow a given toolchain to specify Kconfig options that might be relevant to a feature available in that toolchain. For example, the ARM embedded GNU toolchain supports two variants of newlib and you select the smaller one via a spec file. We can use a Kconfig option like HAS_NEWLIB_LIBC_NANO to convey that this feature is supported by that toolchain. We look for the toolchain Kconfig in ${TOOLCHAIN_KCONFIG_DIR}/Kconfig, and default TOOLCHAIN_KCONFIG_DIR to: ${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT}) toolchain specific cmake files can override the default if needed. Additionally tweaked the zephyr/generic.cmake to use ${CMAKE_CURRENT_LIST_DIR} to reduce some duplication. Signed-off-by: Kumar Gala Signed-off-by: Sebastian Bøe Signed-off-by: Kumar Gala --- Kconfig.zephyr | 1 + cmake/generic_toolchain.cmake | 2 ++ cmake/kconfig.cmake | 2 ++ cmake/toolchain/gnuarmemb/Kconfig | 7 +++++++ cmake/toolchain/zephyr/0.11/Kconfig | 7 +++++++ cmake/toolchain/zephyr/generic.cmake | 4 +++- 6 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 cmake/toolchain/gnuarmemb/Kconfig create mode 100644 cmake/toolchain/zephyr/0.11/Kconfig diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 7f39ff2a5bc..6d067ec47bc 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -45,6 +45,7 @@ source "subsys/Kconfig" source "ext/Kconfig" +osource "$(TOOLCHAIN_KCONFIG_DIR)/Kconfig" menu "Build and Link Features" diff --git a/cmake/generic_toolchain.cmake b/cmake/generic_toolchain.cmake index c579ea76dc1..bd9fcdd55a9 100644 --- a/cmake/generic_toolchain.cmake +++ b/cmake/generic_toolchain.cmake @@ -63,6 +63,8 @@ endif() # Configure the toolchain based on what SDK/toolchain is in use. include(${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT}/generic.cmake) +set_ifndef(TOOLCHAIN_KCONFIG_DIR ${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT}) + # Configure the toolchain based on what toolchain technology is used # (gcc, host-gcc etc.) include(${TOOLCHAIN_ROOT}/cmake/compiler/${COMPILER}/generic.cmake OPTIONAL) diff --git a/cmake/kconfig.cmake b/cmake/kconfig.cmake index c1753fbc3b8..9dc8342dc70 100644 --- a/cmake/kconfig.cmake +++ b/cmake/kconfig.cmake @@ -48,6 +48,7 @@ set(ENV{ARCH_DIR} ${ARCH_DIR}) set(ENV{DEVICETREE_CONF} ${DEVICETREE_CONF}) set(ENV{DTS_POST_CPP} ${DTS_POST_CPP}) set(ENV{DTS_ROOT_BINDINGS} "${DTS_ROOT_BINDINGS}") +set(ENV{TOOLCHAIN_KCONFIG_DIR} "${TOOLCHAIN_KCONFIG_DIR}") # Allow out-of-tree users to add their own Kconfig python frontend # targets by appending targets to the CMake list @@ -90,6 +91,7 @@ foreach(kconfig_target SHIELD_AS_LIST=$ENV{SHIELD_AS_LIST} CMAKE_BINARY_DIR=$ENV{CMAKE_BINARY_DIR} ZEPHYR_TOOLCHAIN_VARIANT=${ZEPHYR_TOOLCHAIN_VARIANT} + TOOLCHAIN_KCONFIG_DIR=${TOOLCHAIN_KCONFIG_DIR} ARCH_DIR=$ENV{ARCH_DIR} DEVICETREE_CONF=${DEVICETREE_CONF} DTS_POST_CPP=${DTS_POST_CPP} diff --git a/cmake/toolchain/gnuarmemb/Kconfig b/cmake/toolchain/gnuarmemb/Kconfig new file mode 100644 index 00000000000..42e08668829 --- /dev/null +++ b/cmake/toolchain/gnuarmemb/Kconfig @@ -0,0 +1,7 @@ +# GNU ARM Embedded Toolchain + +# Copyright (c) 2020 Linaro Limited. +# SPDX-License-Identifier: Apache-2.0 + +config TOOLCHAIN_GNUARMEMB + def_bool y diff --git a/cmake/toolchain/zephyr/0.11/Kconfig b/cmake/toolchain/zephyr/0.11/Kconfig new file mode 100644 index 00000000000..3a3d8b62680 --- /dev/null +++ b/cmake/toolchain/zephyr/0.11/Kconfig @@ -0,0 +1,7 @@ +# Zephyr 0.11 SDK Toolchain + +# Copyright (c) 2020 Linaro Limited. +# SPDX-License-Identifier: Apache-2.0 + +config TOOLCHAIN_ZEPHYR_0_11 + def_bool y diff --git a/cmake/toolchain/zephyr/generic.cmake b/cmake/toolchain/zephyr/generic.cmake index e1bb2894404..be0622201ca 100644 --- a/cmake/toolchain/zephyr/generic.cmake +++ b/cmake/toolchain/zephyr/generic.cmake @@ -4,4 +4,6 @@ if (NOT ZEPHYR_SDK_INSTALL_DIR) message(FATAL_ERROR "ZEPHYR_SDK_INSTALL_DIR must be set") endif() -include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/${SDK_MAJOR_MINOR}/generic.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/${SDK_MAJOR_MINOR}/generic.cmake) + +set(TOOLCHAIN_KCONFIG_DIR ${CMAKE_CURRENT_LIST_DIR}/${SDK_MAJOR_MINOR})