Files
runner-images/images/linux/scripts/installers/clang.sh
T

61 lines
1.7 KiB
Bash
Raw Normal View History

#!/bin/bash
################################################################################
2020-02-04 17:14:16 +03:00
## File: clang.sh
## Desc: Installs Clang compiler
################################################################################
2020-09-17 17:59:39 +03:00
set -e
# Source the helpers for use with the script
source $HELPER_SCRIPTS/os.sh
2020-02-04 17:14:16 +03:00
function InstallClang {
local version=$1
2020-02-04 17:14:16 +03:00
echo "Installing clang-$version..."
if [[ $version =~ (9|10) ]]; then
2020-02-06 11:21:06 +03:00
./llvm.sh $version
2020-02-22 14:52:47 +00:00
apt-get install -y "clang-format-$version"
2020-03-25 22:31:01 +03:00
else
apt-get install -y "clang-$version" "lldb-$version" "lld-$version" "clang-format-$version"
2020-02-06 11:21:06 +03:00
fi
2020-02-04 17:14:16 +03:00
# Run tests to determine that the software installed as expected
echo "Testing to make sure that script performed as expected, and basic scenarios work"
for cmd in clang-$version clang++-$version; do
if ! command -v $cmd; then
echo "$cmd was not installed"
exit 1
fi
done
}
function SetDefaultClang {
local version=$1
echo "Make Clang ${version} default"
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${version} 100
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${version} 100
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-${version} 100
2020-02-04 17:14:16 +03:00
}
# Download script for automatic installation
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
if isUbuntu16 || isUbuntu18; then
versions=( "6.0" "8" "9" )
default_clang_version="9"
fi
2020-02-04 17:14:16 +03:00
if isUbuntu20 ; then
versions=( "8" "9" "10" )
default_clang_version="10"
fi
for version in ${versions[*]}; do
2020-02-04 17:14:16 +03:00
InstallClang $version
done
SetDefaultClang $default_clang_version
2020-02-04 17:14:16 +03:00
rm llvm.sh