Skip to content

Commit

Permalink
build: add script to install clang
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaok committed Jan 12, 2024
1 parent bbbde6f commit c307b61
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ jobs:
path: artifacts
- name: Install dependencies
run: |
./install-clang.sh 17
.github/scripts/setup-self-hosted.sh
sudo apt-get update
Expand Down
43 changes: 43 additions & 0 deletions install-clang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
set -e

function install-clang-for-debian() {
local -r codename="$1"
local -r clang_version="$2"

if ! which sudo >/dev/null; then
apt-get update
apt-get install -y sudo
fi

sudo apt-get update
sudo apt-get install -y \
ca-certificates \
gnupg \
wget
wget -O- https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor |
sudo tee /usr/share/keyrings/.llvm.gpg.tmp >/dev/null
sudo mv /usr/share/keyrings/.llvm.gpg.tmp /usr/share/keyrings/llvm.gpg
sudo tee /etc/apt/sources.list.d/llvm.list <<EOF
deb [signed-by=/usr/share/keyrings/llvm.gpg] http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-${clang_version} main
EOF

sudo apt-get update
sudo apt-get install -y "clang-${clang_version}" "libc++-${clang_version}-dev"
}

function main() {
local -r clang_version="$1"
source /etc/os-release
case "${ID}" in
debian | ubuntu)
install-clang-for-debian "${VERSION_CODENAME}" "${clang_version}"
;;
*)
echo "unsupported os" >&2
exit 1
;;
esac
}

main "$@"

0 comments on commit c307b61

Please sign in to comment.