name: record-daemon on: push: branches: - main pull_request: branches: - main env: CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 jobs: # Type-checks the daemon on Linux: formatting, and clippy over every target, which compiles # the cfg(target_os = "linux") paths without linking them. Linking is the Windows job's. check: name: Check and lint (Linux) runs-on: ubuntu-latest defaults: run: working-directory: record-daemon steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: components: rustfmt, clippy - name: Check format run: cargo fmt --check - name: Install system build dependencies # pkg-config finds libobs for its build script; nothing is linked here, so the distro's # version is enough even though the Windows build links a newer obs.lib. run: | sudo apt-get update sudo apt-get install -y pkg-config libglib2.0-dev libobs-dev libc6-dev clang libwayland-dev - name: Lint run: cargo clippy --all-targets --all-features # The daemon ships on Windows and links Windows' obs.lib, so that is the build worth checking. # It cross-compiles from the Linux runner: obs.lib rides with the libobs crate, and cargo-xwin # brings the MSVC runtime and the Windows SDK. Tests need a machine that can run the exe, so # they stay local: `cargo test` in record-daemon on Windows. build: name: Build (Windows x64) runs-on: ubuntu-latest defaults: run: working-directory: record-daemon steps: - name: Checkout repository uses: actions/checkout@v6 - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: targets: x86_64-pc-windows-msvc - name: Install the cross linker run: | sudo apt-get update sudo apt-get install -y clang lld llvm - name: Install cargo-xwin run: cargo install cargo-xwin --locked - name: Build # libobs-wrapper's build script asks for X11 and Wayland through #[cfg], which it # resolves against the machine running the script rather than the target: a Linux # host cross-building for Windows asks the linker for two libraries that cannot # exist there. Empty archives on the search path answer it without adding anything # to the exe. env: RUSTFLAGS: -Dwarnings -L native=/tmp/xwin-stubs run: | mkdir -p /tmp/xwin-stubs printf 'void stub(void) {}\n' > /tmp/xwin-stub.c clang --target=x86_64-pc-windows-msvc -c /tmp/xwin-stub.c -o /tmp/xwin-stub.obj libtool=$(command -v llvm-lib || ls /usr/lib/llvm-*/bin/llvm-lib | head -1) for lib in X11 wayland-client; do "$libtool" /out:/tmp/xwin-stubs/$lib.lib /tmp/xwin-stub.obj done cargo xwin build --target x86_64-pc-windows-msvc