Skip to content

gnu: Add legacy Zephyr compatibility #989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmake/Zephyr-sdkConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Comment on lines -16 to +20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

What about using Zephyr version?

SDK 1.0.0 support will be available from Zephyr 4.3.0 (well, 4.2.99/main at this time), so we can set the default ZEPHYR_TOOLCHAIN_VARIANT=zephyr when Zephyr_VERSION VERSION_LESS 4.2.99

endif()

# Those are CMake package parameters.
Expand Down
14 changes: 14 additions & 0 deletions scripts/template_setup_posix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo " -o Old zephyr version compatibility"
echo " -o Create symbolic links matching the old SDK layout for old Zephyr (<= 4.2) compatibility"

echo " -c Register Zephyr SDK CMake package"
echo
echo "Supported GNU Toolchains:"
Expand Down Expand Up @@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ask_yn "Old zephyr version compatibility" && do_old_zephyr="y"
ask_yn "Create symbolic links for old Zephyr compatibility" && do_old_zephyr="y"


echo
}

Expand Down Expand Up @@ -159,6 +162,9 @@ else
-c)
do_cmake_pkg="y"
;;
-o)
do_old_zephyr="y"
;;
'-?')
usage
exit 0
Expand Down Expand Up @@ -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
Comment on lines +313 to +314
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to symlink hosttools/* to . for host tools.

echo
fi

echo "All done."
if [ "${interactive}" = "y" ]; then
read -n 1 -s -r -p "Press any key to exit ..."
Expand Down
Loading