| 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. |
| 6 | set -euo pipefail |
| 7 | mode="${1:-linux}" |
| 8 | export DEBIAN_FRONTEND=noninteractive |
| 9 | apt-get update -qq |
| 10 | apt-get install -y -qq --no-install-recommends \ |
| 11 | ca-certificates curl git gnupg lsb-release wget software-properties-common \ |
| 12 | build-essential binutils file python3 unzip xz-utils patch jq \ |
| 13 | clang mold pkg-config libclang-dev \ |
| 14 | libglib2.0-dev libfontconfig-dev libasound2-dev libva-dev \ |
| 15 | libxkbcommon-dev libxkbcommon-x11-dev \ |
| 16 | libx11-dev libxcb1-dev libxext-dev libxfixes-dev libxdamage-dev \ |
| 17 | libxrandr-dev libxcomposite-dev libwayland-dev libpipewire-0.3-dev \ |
| 18 | desktop-file-utils >/dev/null |
| 19 | # webrtc-sys needs clang 21 (check_clang_version in vendor/webrtc-sys/build.rs). |
| 20 | curl -fsSL https://apt.llvm.org/llvm.sh -o /tmp/llvm.sh |
| 21 | bash /tmp/llvm.sh 21 >/dev/null |
| 22 | apt-get install -y -qq --no-install-recommends clang-21 >/dev/null |
| 23 | if [[ "$mode" == windows ]]; then |
| 24 | # cargo-xwin (ureq/native-tls) needs OpenSSL headers to build on the Linux host. |
| 25 | apt-get install -y -qq --no-install-recommends lld-21 llvm-21 clang-tools-21 wine64 libssl-dev >/dev/null |
| 26 | # cargo-xwin calls the plain names. |
| 27 | for tool in clang-cl lld-link llvm-lib llvm-rc llvm-ar llvm-dlltool; do |
| 28 | for candidate in "/usr/lib/llvm-21/bin/$tool" "/usr/bin/$tool-21"; do |
| 29 | [[ -x "$candidate" ]] && ln -sf "$candidate" "/usr/local/bin/$tool" && break |
| 30 | done |
| 31 | done |
| 32 | fi |
| 33 | if ! command -v cargo >/dev/null; then |
| 34 | curl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable >/dev/null |
| 35 | fi |
| 36 | # shellcheck disable=SC1091 |
| 37 | . "${CARGO_HOME:-$HOME/.cargo}/env" |
| 38 | rustup toolchain install stable --profile minimal >/dev/null |
| 39 | if [[ "$mode" == windows ]]; then |
| 40 | rustup target add x86_64-pc-windows-msvc >/dev/null |
| 41 | command -v cargo-xwin >/dev/null || cargo install cargo-xwin --locked >/dev/null |
| 42 | fi |
| 43 | rustc --version |
| 44 | clang-21 --version | head -n 1 |