mirror of
https://github.com/actions/runner-images.git
synced 2025-12-13 12:48:18 +00:00
* Add LLVM libc++ info * combine clang, clang-format into LLVM components * fix formatting Co-authored-by: Sergey Dolin <v-sedoli@micorosoft.com>
52 lines
1.6 KiB
Bash
52 lines
1.6 KiB
Bash
#!/bin/bash -e
|
|
################################################################################
|
|
## File: clang.sh
|
|
## Desc: Installs Clang compiler
|
|
################################################################################
|
|
|
|
# Source the helpers for use with the script
|
|
source $HELPER_SCRIPTS/os.sh
|
|
source $HELPER_SCRIPTS/install.sh
|
|
|
|
function InstallClang {
|
|
local version=$1
|
|
|
|
echo "Installing clang-$version..."
|
|
if [[ $version =~ 9 ]] && isUbuntu16 || [[ $version =~ 12 ]]; then
|
|
./llvm.sh $version
|
|
apt-get install -y "clang-format-$version"
|
|
llvm_repo=$(grep '^deb.*apt.llvm.org\/' /etc/apt/sources.list)
|
|
echo "llvm $llvm_repo" >> $HELPER_SCRIPTS/apt-sources.txt
|
|
else
|
|
apt-get install -y "clang-$version" "lldb-$version" "lld-$version" "clang-format-$version"
|
|
fi
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
# Download script for automatic installation
|
|
download_with_retries https://apt.llvm.org/llvm.sh
|
|
chmod +x llvm.sh
|
|
|
|
versions=$(get_toolset_value '.clang.versions[]')
|
|
default_clang_version=$(get_toolset_value '.clang.default_version')
|
|
|
|
for version in ${versions[*]}; do
|
|
if [[ $version != $default_clang_version ]]; then
|
|
InstallClang $version
|
|
fi
|
|
done
|
|
InstallClang $default_clang_version
|
|
|
|
SetDefaultClang $default_clang_version
|
|
rm llvm.sh
|
|
|
|
invoke_tests "Tools" "clang"
|