Files
space_game/scripts/setup_llvm_links.sh
2026-01-29 17:06:34 +01:00

59 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# This cript creates default links to a set of llvm binaries
# ex. /usr/bin/clang -> /usr/bin/clang-18
set -e
if [ "$EUID" -ne 0 ]
then echo "This script must be run as root"
exit 1
fi
# Detect clang version
# Command Breakdown:
# Get all installed packages
# | Detect clang version
# | | Sort available versions
# | | | Pick highest version
# | | | | Remove "clang-" to extract the version only
# v v v v v
VER=$(dpkg --list | grep -o "clang-[0-9][0-9]*" | sort -r | head -n 1 | sed "s#clang-##")
#echo Detected Tool-Version: $VER
# Ensure all tools are installed
TOOLS=(
clang
clang++
llvm-windres
llvm-ranlib
llvm-ar
llvm-strip
)
for TOOL in "${TOOLS[@]}"
do
set +e
OUTPUT=$($TOOL-$VER --version 2>&1)
EXIT_CODE=$?
set -e
# on error (ex. no ground truth file) just print nothing
if [ $EXIT_CODE -ne 0 ]
then
echo $TOOL-$VER must be installed!
exit 1
fi
#echo Found $TOOL-$VER
# Get full path
TOOL_PATH=$(which $TOOL-$VER)
# Create links
ln -sf $TOOL_PATH /usr/bin/$TOOL
done