Merge pull request #1543 from al-cheb/al-cheb/ubuntu20_clang10

[Ubuntu] Add and set clang-10 as the default version for Ubuntu 20
This commit is contained in:
Maxim Lobanov
2020-09-18 09:38:32 +03:00
committed by GitHub
+26 -15
View File
@@ -1,15 +1,18 @@
#!/bin/bash #!/bin/bash
################################################################################ ################################################################################
## File: clang.sh ## File: clang.sh
## Desc: Installs Clang compiler (versions: 6, 8 and 9) ## Desc: Installs Clang compiler
################################################################################ ################################################################################
set -e
# Source the helpers for use with the script
source $HELPER_SCRIPTS/os.sh
function InstallClang { function InstallClang {
version=$1 local version=$1
echo "Installing clang-$version..." echo "Installing clang-$version..."
if [[ $version =~ 9 ]]; then if [[ $version =~ (9|10) ]]; then
./llvm.sh $version ./llvm.sh $version
apt-get install -y "clang-format-$version" apt-get install -y "clang-format-$version"
else else
@@ -26,24 +29,32 @@ function InstallClang {
done 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
}
# Download script for automatic installation # Download script for automatic installation
wget https://apt.llvm.org/llvm.sh wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh chmod +x llvm.sh
versions=( if isUbuntu16 || isUbuntu18; then
"6.0" versions=( "6.0" "8" "9" )
"8" default_clang_version="9"
"9" fi
)
for version in ${versions[*]} if isUbuntu20 ; then
do versions=( "8" "9" "10" )
default_clang_version="10"
fi
for version in ${versions[*]}; do
InstallClang $version InstallClang $version
done done
SetDefaultClang $default_clang_version
rm llvm.sh rm llvm.sh
# Make Clang 9 default
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-9 100
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-9 100
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-9 100