forked from rapidsai/devcontainers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·82 lines (69 loc) · 2.43 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#! /usr/bin/env bash
set -e
# Ensure we're in this feature's directory during build
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
# install global/common scripts
. ./common/install.sh;
LLVM_VERSION="${VERSION:-}";
check_packages \
git \
gpg \
wget \
apt-utils \
lsb-release \
gettext-base \
bash-completion \
ca-certificates \
apt-transport-https \
software-properties-common \
;
if [[ -z "$LLVM_VERSION" \
|| "$LLVM_VERSION" == "latest" \
|| "$LLVM_VERSION" == "dev" \
|| "$LLVM_VERSION" == "pre" \
|| "$LLVM_VERSION" == "prerelease" \
]]; then
LLVM_VERSION="latest";
find_version_from_git_tags \
LLVM_VERSION \
https://github.com/llvm/llvm-project \
"tags/llvmorg-" "." "-init" "true";
LLVM_VERSION="$(echo $LLVM_VERSION | grep -oP '[0-9]+')";
fi
echo "Installing llvm-${LLVM_VERSION} compilers and tools";
declare -a bins=();
declare -a pkgs=();
IFS=" " read -r -a pkgs <<< "${PACKAGES:-all}";
./llvm.sh "${LLVM_VERSION}" "${pkgs[@]}";
if [[ "${pkgs[*]}" == "all" ]]; then
bins=("clang" "clangd" "clang++" "clang-format" "clang-tidy" "lldb" "llvm-config" "llvm-cov" "FileCheck" "UnicodeNameMappingGenerator");
else
IFS=" " read -r -a bins <<< "${PACKAGES}";
declare -A pkgs_map=();
for ((i=0; i < ${#pkgs[@]}; i+=1)); do
pkgs_map["${pkgs[i]}"]=1;
done
if test -v pkgs_map["llvm-tools"] \
|| test -v pkgs_map["llvm-${LLVM_VERSION}-tools"]; then
bins+=("FileCheck" "UnicodeNameMappingGenerator");
fi
fi
# Remove existing, install, and set default clang/llvm alternatives
for ((i=0; i < ${#bins[@]}; i+=1)); do
x=${bins[$i]};
if type "${x}-${LLVM_VERSION}" >/dev/null 2>&1; then
(update-alternatives --install /usr/bin/"${x}" "${x}" "$(which "${x}-${LLVM_VERSION}")" 30);
(update-alternatives --set "${x}" "$(which "${x}-${LLVM_VERSION}")");
fi
done
export LLVM_VERSION="${LLVM_VERSION}";
# export envvars in bashrc files
append_to_etc_bashrc "$(cat .bashrc | envsubst)";
append_to_all_bashrcs "$(cat .bashrc | envsubst)";
# export envvars in /etc/profile.d
add_etc_profile_d_script llvm "$(cat .bashrc | envsubst)";
# Clean up
# rm -rf /tmp/*;
rm -rf /var/tmp/*;
rm -rf /var/cache/apt/*;
rm -rf /var/lib/apt/lists/*;