Skip to content

Commit 06f8a51

Browse files
author
Clement Cheung
committed
Add support for version
1 parent 578e99a commit 06f8a51

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

devcontainer-feature.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44
"name": "llvm",
55
"documentationURL": "https://github.com/devcontainers-community/features-llvm",
66
"description": "Installs llvm on debian based systems",
7-
"options": {},
7+
"options": {
8+
"version": {
9+
"type": "string",
10+
"proposals": [
11+
"latest",
12+
"18",
13+
"17",
14+
"16"
15+
],
16+
"default": "latest",
17+
"description": "LLVM version"
18+
}
19+
},
820
"mounts": [],
921
"installsAfter": [
1022
"ghcr.io/devcontainers/features/common-utils"

install.sh

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
apt update && apt install lsb-release wget software-properties-common gnupg -y -qq
4+
if [ "$VERSION" == "latest" ]; then
5+
VERSION=
6+
fi
7+
MAJOR_VERSION=${VERSION%%.*}
58

6-
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
9+
# Checks if packages are installed and installs them if not
10+
check_packages() {
11+
if ! dpkg -s "$@" > /dev/null 2>&1; then
12+
apt_get_update
13+
apt-get -y install --no-install-recommends "$@"
14+
fi
15+
}
716

8-
ln -s /usr/bin/clang-17 /usr/bin/clang
9-
ln -s /usr/bin/clang++-17 /usr/bin/clang++
10-
ln -s /usr/bin/lld-17 /usr/bin/lld
17+
check_packages lsb-release wget software-properties-common gnupg
18+
19+
cd /tmp
20+
wget https://apt.llvm.org/llvm.sh
21+
chmod +x llvm.sh
22+
./llvm.sh $VERSION
23+
rm llvm.sh
24+
25+
ln -sf /usr/bin/clang-${MAJOR_VERSION} /usr/bin/clang
26+
ln -sf /usr/bin/clang++-${MAJOR_VERSION} /usr/bin/clang++
27+
ln -sf /usr/bin/lld-${MAJOR_VERSION} /usr/bin/lld
28+
ln -sf /usr/bin/ld.lld-${MAJOR_VERSION} /usr/bin/ld.lld

0 commit comments

Comments
 (0)