add and set clang-10 as the default for Ubuntu 20

This commit is contained in:
Aleksandr Chebotov
2020-09-03 11:32:09 +03:00
parent 1dae8d00db
commit 7d791a5e06

View File

@@ -1,17 +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
################################################################################ ################################################################################
# Source the helpers for use with the script # Source the helpers for use with the script
source $HELPER_SCRIPTS/document.sh source $HELPER_SCRIPTS/document.sh
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
@@ -29,27 +30,35 @@ function InstallClang {
# Document what was added to the image # Document what was added to the image
echo "Documenting clang-$version..." echo "Documenting clang-$version..."
DocumentInstalledItem "Clang $version ($(clang-$version --version | head -n 1 | cut -d ' ' -f 3 | cut -d '-' -f 1))" DocumentInstalledItem "Clang $version ($(clang-$version --version | head -n 1 | cut -d '-' -f 1 | awk '{print $NF}'))"
}
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