| 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 | # 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. |
| 11 | if [[ -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 |
| 18 | fi |
| 19 | apt-get update -qq |
| 20 | apt-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). |
| 30 | curl -fsSL https://apt.llvm.org/llvm.sh -o /tmp/llvm.sh |
| 31 | bash /tmp/llvm.sh 21 >/dev/null |
| 32 | apt-get install -y -qq --no-install-recommends clang-21 >/dev/null |
| 33 | if [[ "$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 |
| 42 | fi |
| 43 | if ! command -v cargo >/dev/null; then |
| 44 | curl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable >/dev/null |
| 45 | fi |
| 46 | # shellcheck disable=SC1091 |
| 47 | . "${CARGO_HOME:-$HOME/.cargo}/env" |
| 48 | rustup toolchain install stable --profile minimal >/dev/null |
| 49 | if [[ "$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 |
| 52 | fi |
| 53 | rustc --version |
| 54 | clang-21 --version | head -n 1 |