BlueGit

ict rusty-teams

Files

rusty-teams / packaging / kvt / ci-setup.sh

ci-setup.sh

ci-setup.sh 2.6 KiB Download Raw
1#!/usr/bin/env bash
2# KVT fork: tools for the BlueGit CI jobs in blue-ci-cd.yml, on an Ubuntu image.
3# ci-setup.sh linux Linux build (as .github/actions/setup-linux): headers, clang 21, mold
4# ci-setup.sh windows the above plus the cross-build bits: lld/llvm 21, wine, cargo-xwin
5# Rust comes from rustup (stable) into $CARGO_HOME, which the jobs cache.
6set -euo pipefail
7mode="${1:-linux}"
8export DEBIAN_FRONTEND=noninteractive
9# Keep Cargo and rustup in the workspace so ci-cache.sh can pack them.
10# BlueGit cache only copies files, not directories; the job stores a tarball.
11if [[ -n "${CI:-}" ]]; then
12 export CARGO_HOME="${CARGO_HOME:-$PWD/cargo-home}"
13 export RUSTUP_HOME="${RUSTUP_HOME:-$PWD/rustup-home}"
14 export PATH="$CARGO_HOME/bin:$PATH"
15 if [[ "$mode" == windows ]]; then
16 export XWIN_CACHE_DIR="${XWIN_CACHE_DIR:-$PWD/xwin-cache}"
17 fi
18fi
19apt-get update -qq
20apt-get install -y -qq --no-install-recommends \
21 ca-certificates curl git gnupg lsb-release wget software-properties-common \
22 build-essential binutils file python3 unzip xz-utils patch jq \
23 clang mold pkg-config libclang-dev \
24 libglib2.0-dev libfontconfig-dev libasound2-dev libva-dev \
25 libxkbcommon-dev libxkbcommon-x11-dev \
26 libx11-dev libxcb1-dev libxext-dev libxfixes-dev libxdamage-dev \
27 libxrandr-dev libxcomposite-dev libwayland-dev libpipewire-0.3-dev \
28 desktop-file-utils >/dev/null
29# webrtc-sys needs clang 21 (check_clang_version in vendor/webrtc-sys/build.rs).
30curl -fsSL https://apt.llvm.org/llvm.sh -o /tmp/llvm.sh
31bash /tmp/llvm.sh 21 >/dev/null
32apt-get install -y -qq --no-install-recommends clang-21 >/dev/null
33if [[ "$mode" == windows ]]; then
34 # cargo-xwin (ureq/native-tls) needs OpenSSL headers to build on the Linux host.
35 apt-get install -y -qq --no-install-recommends lld-21 llvm-21 clang-tools-21 wine64 libssl-dev >/dev/null
36 # cargo-xwin calls the plain names.
37 for tool in clang-cl lld-link llvm-lib llvm-rc llvm-ar llvm-dlltool; do
38 for candidate in "/usr/lib/llvm-21/bin/$tool" "/usr/bin/$tool-21"; do
39 [[ -x "$candidate" ]] && ln -sf "$candidate" "/usr/local/bin/$tool" && break
40 done
41 done
42fi
43if ! command -v cargo >/dev/null; then
44 curl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable >/dev/null
45fi
46# shellcheck disable=SC1091
47. "${CARGO_HOME:-$HOME/.cargo}/env"
48rustup toolchain install stable --profile minimal >/dev/null
49if [[ "$mode" == windows ]]; then
50 rustup target add x86_64-pc-windows-msvc >/dev/null
51 command -v cargo-xwin >/dev/null || cargo install cargo-xwin --locked >/dev/null
52fi
53rustc --version
54clang-21 --version | head -n 1