From 6228a18d649fde934047eab9c0c8b198be48c8eb Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Fri, 2 Aug 2019 10:55:23 -0500 Subject: [PATCH] cmake: Support SDK versions more broadly The SDK version is of the form X.Y.Z. Change the cmake scripts to be based on X.Y of the version. This allows us to easily support newer toolchains without having to explicitly add cmake files for the version as well as removes duplication between those files. Signed-off-by: Kumar Gala Signed-off-by: Carles Cufi --- .../toolchain/zephyr/0.10.0/host-tools.cmake | 13 -------- cmake/toolchain/zephyr/0.10.0/target.cmake | 32 ------------------- cmake/toolchain/zephyr/0.10.1/generic.cmake | 14 -------- .../zephyr/{0.10.0 => 0.10}/generic.cmake | 0 .../zephyr/{0.10.1 => 0.10}/host-tools.cmake | 0 .../zephyr/{0.10.1 => 0.10}/target.cmake | 0 cmake/toolchain/zephyr/generic.cmake | 2 +- cmake/toolchain/zephyr/host-tools.cmake | 3 +- cmake/toolchain/zephyr/target.cmake | 2 +- 9 files changed, 4 insertions(+), 62 deletions(-) delete mode 100644 cmake/toolchain/zephyr/0.10.0/host-tools.cmake delete mode 100644 cmake/toolchain/zephyr/0.10.0/target.cmake delete mode 100644 cmake/toolchain/zephyr/0.10.1/generic.cmake rename cmake/toolchain/zephyr/{0.10.0 => 0.10}/generic.cmake (100%) rename cmake/toolchain/zephyr/{0.10.1 => 0.10}/host-tools.cmake (100%) rename cmake/toolchain/zephyr/{0.10.1 => 0.10}/target.cmake (100%) diff --git a/cmake/toolchain/zephyr/0.10.0/host-tools.cmake b/cmake/toolchain/zephyr/0.10.0/host-tools.cmake deleted file mode 100644 index 843b2dea75b..00000000000 --- a/cmake/toolchain/zephyr/0.10.0/host-tools.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - - -set(HOST_TOOLS_HOME ${ZEPHYR_SDK_INSTALL_DIR}/sysroots/${TOOLCHAIN_ARCH}-pokysdk-linux) - -# Path used for searching by the find_*() functions, with appropriate -# suffixes added. Ensures that the SDK's host tools will be found when -# we call, e.g. find_program(QEMU qemu-system-x86) -list(APPEND CMAKE_PREFIX_PATH ${HOST_TOOLS_HOME}/usr) - -# TODO: Use find_* somehow for these as well? -set_ifndef(QEMU_BIOS ${HOST_TOOLS_HOME}/usr/share/qemu) -set_ifndef(OPENOCD_DEFAULT_PATH ${HOST_TOOLS_HOME}/usr/share/openocd/scripts) diff --git a/cmake/toolchain/zephyr/0.10.0/target.cmake b/cmake/toolchain/zephyr/0.10.0/target.cmake deleted file mode 100644 index 2b45d3f52c9..00000000000 --- a/cmake/toolchain/zephyr/0.10.0/target.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -# Determine if we have an IAMCU toolchain or not. -if(CONFIG_X86_IAMCU) - set(CROSS_COMPILE_TARGET_x86 i586-zephyr-elfiamcu) -else() - set(CROSS_COMPILE_TARGET_x86 i586-zephyr-elf) -endif() - -set(CROSS_COMPILE_TARGET_arm arm-zephyr-eabi) -set(CROSS_COMPILE_TARGET_nios2 nios2-zephyr-elf) -set(CROSS_COMPILE_TARGET_riscv riscv32-zephyr-elf) -set(CROSS_COMPILE_TARGET_mips mipsel-zephyr-elf) -set(CROSS_COMPILE_TARGET_xtensa xtensa-zephyr-elf) -set(CROSS_COMPILE_TARGET_arc arc-zephyr-elf) - -set(CROSS_COMPILE_TARGET ${CROSS_COMPILE_TARGET_${ARCH}}) -set(SYSROOT_TARGET ${CROSS_COMPILE_TARGET}) - -set(CROSS_COMPILE ${TOOLCHAIN_HOME}/${CROSS_COMPILE_TARGET}/bin/${CROSS_COMPILE_TARGET}-) - -if("${ARCH}" STREQUAL "xtensa") - set(SYSROOT_DIR ${TOOLCHAIN_HOME}/${SYSROOT_TARGET}) - set(TOOLCHAIN_INCLUDES - ${SYSROOT_DIR}/include/arch/include - ${SYSROOT_DIR}/include - ) - - LIST(APPEND TOOLCHAIN_LIBS hal) - LIST(APPEND LIB_INCLUDE_DIR -L${SYSROOT_DIR}/lib) -endif() -set(SYSROOT_DIR ${TOOLCHAIN_HOME}/${SYSROOT_TARGET}/${SYSROOT_TARGET}) diff --git a/cmake/toolchain/zephyr/0.10.1/generic.cmake b/cmake/toolchain/zephyr/0.10.1/generic.cmake deleted file mode 100644 index 7d31614da9b..00000000000 --- a/cmake/toolchain/zephyr/0.10.1/generic.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -set(TOOLCHAIN_HOME ${ZEPHYR_SDK_INSTALL_DIR}) - -set(COMPILER gcc) -set(LINKER ld) -set(BINTOOLS gnu) - -set(CROSS_COMPILE_TARGET i586-${TOOLCHAIN_VENDOR}-elf) -set(SYSROOT_TARGET i586-${TOOLCHAIN_VENDOR}-elf) - -set(CROSS_COMPILE ${TOOLCHAIN_HOME}/${CROSS_COMPILE_TARGET}/bin/${CROSS_COMPILE_TARGET}-) -set(SYSROOT_DIR ${ZEPHYR_SDK_INSTALL_DIR}/sysroots/${SYSROOT_TARGET}/usr) -set(TOOLCHAIN_HAS_NEWLIB ON CACHE BOOL "True if toolchain supports newlib") diff --git a/cmake/toolchain/zephyr/0.10.0/generic.cmake b/cmake/toolchain/zephyr/0.10/generic.cmake similarity index 100% rename from cmake/toolchain/zephyr/0.10.0/generic.cmake rename to cmake/toolchain/zephyr/0.10/generic.cmake diff --git a/cmake/toolchain/zephyr/0.10.1/host-tools.cmake b/cmake/toolchain/zephyr/0.10/host-tools.cmake similarity index 100% rename from cmake/toolchain/zephyr/0.10.1/host-tools.cmake rename to cmake/toolchain/zephyr/0.10/host-tools.cmake diff --git a/cmake/toolchain/zephyr/0.10.1/target.cmake b/cmake/toolchain/zephyr/0.10/target.cmake similarity index 100% rename from cmake/toolchain/zephyr/0.10.1/target.cmake rename to cmake/toolchain/zephyr/0.10/target.cmake diff --git a/cmake/toolchain/zephyr/generic.cmake b/cmake/toolchain/zephyr/generic.cmake index 3d2ef513066..e1bb2894404 100644 --- a/cmake/toolchain/zephyr/generic.cmake +++ b/cmake/toolchain/zephyr/generic.cmake @@ -4,4 +4,4 @@ if (NOT ZEPHYR_SDK_INSTALL_DIR) message(FATAL_ERROR "ZEPHYR_SDK_INSTALL_DIR must be set") endif() -include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/${SDK_VERSION}/generic.cmake) +include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/${SDK_MAJOR_MINOR}/generic.cmake) diff --git a/cmake/toolchain/zephyr/host-tools.cmake b/cmake/toolchain/zephyr/host-tools.cmake index f81de395832..3a5be5c7c35 100644 --- a/cmake/toolchain/zephyr/host-tools.cmake +++ b/cmake/toolchain/zephyr/host-tools.cmake @@ -34,6 +34,7 @@ file(READ ${sdk_version_path} SDK_VERSION_PRE1) string(REGEX REPLACE "-.*" "" SDK_VERSION_PRE2 ${SDK_VERSION_PRE1}) # Strip any trailing spaces/newlines from the version string string(STRIP ${SDK_VERSION_PRE2} SDK_VERSION) +string(REGEX MATCH "([0-9]*).([0-9]*)" SDK_MAJOR_MINOR ${SDK_VERSION}) if(${REQUIRED_SDK_VER} VERSION_GREATER ${SDK_VERSION}) message(FATAL_ERROR "The SDK version you are using is too old, please update your SDK. You need at least SDK version ${REQUIRED_SDK_VER}. @@ -43,4 +44,4 @@ https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${REQUIRED_SDK_V ") endif() -include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/${SDK_VERSION}/host-tools.cmake) +include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/${SDK_MAJOR_MINOR}/host-tools.cmake) diff --git a/cmake/toolchain/zephyr/target.cmake b/cmake/toolchain/zephyr/target.cmake index 1c3b93bb688..27fb12b775d 100644 --- a/cmake/toolchain/zephyr/target.cmake +++ b/cmake/toolchain/zephyr/target.cmake @@ -1,3 +1,3 @@ # SPDX-License-Identifier: Apache-2.0 -include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/${SDK_VERSION}/target.cmake) +include(${ZEPHYR_BASE}/cmake/toolchain/zephyr/${SDK_MAJOR_MINOR}/target.cmake)