Files
build-toolchain/env.sh
Egor Tsyganchuk fa0e0243e1 Refactor env.sh to enhance toolchain path handling and usage instructions
- Simplified toolchain path resolution logic to support custom paths and global mode.
- Improved error handling and user feedback for toolchain detection.
- Streamlined environment variable exports and clarified usage instructions for better user experience.
2026-03-31 13:54:39 +03:00

42 lines
1.2 KiB
Bash
Executable File

TOP="$(pwd)"
TOOLCHAIN_PATH=""
GLOBAL_MODE=0
for arg in "$@"; do
if [ "$arg" = "--global" ]; then
GLOBAL_MODE=1
break
fi
done
if [ -d "${TOP}/arm-uclinuxfdpiceabi" ]; then
TOOLCHAIN_PATH="${TOP}/arm-uclinuxfdpiceabi"
elif [ -d "${TOP}/build/install" ]; then
TOOLCHAIN_PATH="${TOP}/build/install"
fi
if [ -n "${TOOLCHAIN_PATH}" ] && [ -x "${TOOLCHAIN_PATH}/bin/arm-uclinuxfdpiceabi-gcc" ]; then
echo "Найден toolchain: ${TOOLCHAIN_PATH}/bin/arm-uclinuxfdpiceabi-gcc"
CFLAGS_TOOLSET='-O2'
CFLAGS_TARGET='-Os -mthumb'
SUBARCH=armv7-m
SUBMODE=thumb
if [ "$GLOBAL_MODE" -eq 1 ]; then
export CFLAGS="${CFLAGS_TOOLSET}"
export CFLAGS_FOR_TARGET="${CFLAGS_TARGET}"
export CXXFLAGS_FOR_TARGET="${CFLAGS_TARGET}"
export SUBARCH
export SUBMODE
export PATH="${TOOLCHAIN_PATH}/bin:${PATH}"
else
CFLAGS="${CFLAGS_TOOLSET}"
CFLAGS_FOR_TARGET="${CFLAGS_TARGET}"
CXXFLAGS_FOR_TARGET="${CFLAGS_TARGET}"
PATH="${TOOLCHAIN_PATH}/bin:${PATH}"
fi
else
echo "Ошибка: не найден ${TOOLCHAIN_PATH}/bin/arm-uclinuxfdpiceabi-gcc"
return 1 2>/dev/null || exit 1
fi