Skip to content

build: Always compile the Rust ports; link them into a test-only libobs, package the C libobs #1065

Closed

Description

@zackees

Goal

Always compile the Rust ports, in one CMake configure. Choose at link time which libobs gets them, and stop treating ENABLE_RUST_LIBOBS ON/OFF as two build configurations.

For now, the packaged artifact is the C libobs. The Rust-linked libobs is built and tested on every build, but nothing ships it.

Today

  • option(ENABLE_RUST_LIBOBS ... OFF) picks sources at configure time:
    • 48 $<$<NOT:$<BOOL:${ENABLE_RUST_LIBOBS}>>:...> generator expressions in libobs/CMakeLists.txt;
    • more in libobs/cmake/os-{windows,macos,linux,freebsd}.cmake;
    • plugins/obs-nvenc (cuda-load.c vs cuda-load-rust.c).
  • Tier 2 configures and builds libobs twice, OFF then ON (rust/tools/linux-validate/validate.sh and rust/tools/tier2-validate/*).
  • The default build (OFF) never compiles the Rust, so a contributor can break the ON build without noticing.

Target

One configure, Rust always built:

Target Contents Built Packaged
libobs-common (OBJECT) every libobs source that has no Rust port always, once (part of both)
libobs common + the original C of each ported unit always yes: the product, for now
libobs-rust linked variant (name TBD, e.g. libobs-with-rust) common + the libobs-rust staticlib always no
  • One list of ported units. The ported C files (util/bmem.c, obs-data.c, util/platform-nix.c, ...) are named in one place, which replaces the scattered generator expressions. The list shrinks as each C file is deleted after its port.
  • Tier 2 runs twice from one build tree. The unchanged cmocka tests are registered twice, linked against libobs and against the Rust-linked variant (e.g. ctest labels c and rust). Shared objects compile once, so this is roughly half of today's OFF + ON time.
  • obs-nvenc gets the same treatment: both loaders are built, and the packaged plugin links the C one.
  • ENABLE_RUST_LIBOBS stays as a deprecated no-op for one release, then is removed.
  • Rust becomes a hard build requirement for every build (Flatpak, AppImage, from-source). Document it in the build docs and docs/ci-tooling.md.
  • obs-c-oracle is unchanged. It serves the Rust-side differential tests (Tier 3), which this does not replace.

Open point: the OBS-Studio-Rust daily beta

.github/workflows/release-rust.yaml and .github/scripts/.build.zsh / .package.zsh currently package an ENABLE_RUST_LIBOBS=ON build as the OBS-Studio-Rust beta. Under "the packaged artifact is the C libobs", that beta would package libobs, the C one. Decide before landing: either the beta keeps a Rust-linked package as its own explicit packaging step, or it ships C until the switch.

Done when

  • A plain configure (no options) builds the Rust staticlib and both libobs link targets on Linux, Windows and macOS.
  • The packaged app and AppImage contain only the C libobs; build-aux/appimage/test-appimage.sh checks it.
  • Tier 2 runs the cmocka suite against both from one build, on all three OSes.
  • No ENABLE_RUST_LIBOBS generator expression is left in libobs/ or plugins/.

Related: #140 (full app with ENABLE_RUST_LIBOBS=ON), #444 (Phase 6 libobs core migration), #1051.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions