From 9e950dc32acf426361c0f6554e128e5ebba190f5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 31 Jul 2025 13:52:18 -0700 Subject: [PATCH] gnu: Add legacy Zephyr compatibility In setup.sh, add option to create symlinks from gnu/ so that paths match previous SDK versions. In Zephyr-sdkConfig.cmake, set ZEPHYR_TOOLCHAIN_VARIANT to zephyr/gnu only when Zephyr sets ZEPHYR_TOOLCHAIN_VARIANT_COMPILER_SUPPORT before finding the SDK module. This will require a change to Zephyr, which is unfortunate. Ideally, we'd use some existing mechanism to detect when to make this switch. Signed-off-by: Keith Packard --- cmake/Zephyr-sdkConfig.cmake | 6 +++++- scripts/template_setup_posix | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cmake/Zephyr-sdkConfig.cmake b/cmake/Zephyr-sdkConfig.cmake index e9662d5e..8104c43f 100644 --- a/cmake/Zephyr-sdkConfig.cmake +++ b/cmake/Zephyr-sdkConfig.cmake @@ -13,7 +13,11 @@ get_filename_component(ZEPHYR_SDK_INSTALL_DIR ${CMAKE_CURRENT_LIST_DIR}/.. ABSOL set(ZEPHYR_SDK_INSTALL_DIR ${ZEPHYR_SDK_INSTALL_DIR}) if(NOT DEFINED ZEPHYR_TOOLCHAIN_VARIANT) - set(ZEPHYR_TOOLCHAIN_VARIANT "zephyr/gnu") + if(DEFINED ZEPHYR_TOOLCHAIN_VARIANT_COMPILER_SUPPORT) + set(ZEPHYR_TOOLCHAIN_VARIANT "zephyr/gnu") + else() + set(ZEPHYR_TOOLCHAIN_VARIANT "zephyr") + endif() endif() # Those are CMake package parameters. diff --git a/scripts/template_setup_posix b/scripts/template_setup_posix index d680bf85..812bd75f 100644 --- a/scripts/template_setup_posix +++ b/scripts/template_setup_posix @@ -69,6 +69,7 @@ usage() echo " all Install all GNU toolchains" echo " -l Install LLVM toolchain" echo " -h Install host tools" + echo " -o Old zephyr version compatibility" echo " -c Register Zephyr SDK CMake package" echo echo "Supported GNU Toolchains:" @@ -117,6 +118,8 @@ user_prompt() # Environment Configurations ask_yn "Register Zephyr SDK CMake package" && do_cmake_pkg="y" + ask_yn "Old zephyr version compatibility" && do_old_zephyr="y" + echo } @@ -159,6 +162,9 @@ else -c) do_cmake_pkg="y" ;; + -o) + do_old_zephyr="y" + ;; '-?') usage exit 0 @@ -301,6 +307,14 @@ if [ "${do_cmake_pkg}" = "y" ]; then echo fi +# Create compatibility links for old Zephyr versions +if [ "${do_old_zephyr}" = "y" ]; then + echo "Creating links for old Zephyr compatibility ..." + ln -sr gnu/* . || assert_rc "ERROR: Creating toolchain links" 50 + ln -sr cmake/zephyr/gnu/* cmake/zephyr || assert_rc "ERROR: Creating cmake links" 50 + echo +fi + echo "All done." if [ "${interactive}" = "y" ]; then read -n 1 -s -r -p "Press any key to exit ..."