Repository navigation
Description
Goal
Keep host-specific (Windows/macOS/Linux) code out of shared C/C++ files and scope CI by path, without moving any upstream file. The checks gain a few rules. The tree stays where it is.
Plan changed (2026-10-16). The first version of this issue moved libobs's host code into
libobs/hosts/<os>/and renamed every crate'ssrc/platform/tosrc/hosts/. That is dropped. We still mergeupstream/master(last on 2026-10-12), and moving upstream files makes every later merge and cherry-pick fight renames. The files those moves touched (obs-nix*.c,util/platform-*,audio-monitoring/*) are also the ones the Rust ports replace. The earlier version is in this issue's edit history.
Repository layout policy
Write this down in docs/rust-port/naming.md, and link to it from AGENTS.md and rust/README.md:
- The upstream tree stays where upstream has it:
libobs/,libobs-*/,frontend/,plugins/,shared/,deps/,cmake/,test/. Don't move or rename C/C++ files to restructure. Bug fixes and ports edit them in place. - All Rust lives in the
rust/Cargo workspace, one crate per ported component, withrust/tools/excluded. Add a table there mapping each C component to its crate (libobs/util↔rust/obs-util,libobs/media-io↔rust/obs-media-io,libobs/graphics↔rust/obs-graphics, the codec helpers ↔rust/obs-codec, ...), so a port always has one obvious home. - When a C component is fully ported: delete its C sources and point its CMake target at the Rust staticlib. Don't keep a moved copy of the C.
- Later, not now: once we stop merging upstream, the remaining C/C++ (mostly
frontend/andplugins/) may move under one root directory in a single mechanical PR. That PR holds only thegit mvplus path updates (CMake, CI, docs), lands in a quiet window, and uses a neutral name, because libobs is C, not C++. That needs its own issue when the time comes.
Rust: keep what exists
- Keep
rust/<crate>/src/platform/with its onecfg_select!inplatform/mod.rs, plussrc/ffi/. Keep thedylints/ban_platform_cfg_outside_boundaryDylint as it is. There is noplatform→hostsrename. - The
unixarm stays. Don't add#[path]includes to share POSIX code. - Out of scope: making the selector exhaustive with no
_fallback. If someone wants it later, the arm list must include FreeBSD, which upstream builds (libobs/cmake/os-freebsd.cmake).
C/C++: tighten the existing ratchet
ci/platform_ifdef_ratchet.py (#847) already fails a PR that adds a host conditional to a shared file in libobs/, frontend/, shared/ or plugins/, against ci/platform-ifdef-baseline.json. Extend it in place, without a new lint:
-
One classifier. The ratchet keeps its own
PLATFORM_TOKENSlist, and that list has already drifted fromci/platform_paths.py. Make the ratchet callplatform_paths.platforms(), so CI scoping and the lint always agree on which OS a file belongs to. -
Right OS, not just any OS. Map each macro family to an OS:
_WIN32,_MSC_VER, ... → windows.__APPLE__,TARGET_OS_*, ... → macos.__linux__,__FreeBSD__, ... → linux.__unix__→ linux + macos.
A conditional in a file classified as another OS's is an error. For example,
#ifdef _WIN32insideobs-cocoa.mfails. Today that file is skipped entirely. -
No multi-OS conditionals in host files.
#if defined(_WIN32) || defined(__APPLE__)in a file that belongs to one OS is an error. -
OS headers follow the same mapping for
#includeand#importlines:<windows.h>,<d3d*.h>,<dxgi*.h>, ... → windows.<CoreFoundation/…>,<AppKit/…>,<mach/…>, ... → macos.<X11/…>,<xcb/…>,<wayland-…>,<pulse/…>,<pipewire/…>,<dbus/…>, ... → linux.<unistd.h>,<pthread.h>,<dlfcn.h>, ... → linux + macos.
Including one in a shared file counts against the same per-file baseline.
-
Strip comments and string literals before matching, and join backslash-continued lines. Then a macro named in a comment is not flagged.
-
Permanent exceptions go in
ci/platform-ifdef-exceptions.toml, one entry per file with a reason. They are only for installed public headers that must keep their conditionals, since public headers and the ABI don't change. Examples areutil/c99defs.hand possiblyutil/threading.handgraphics/graphics.h, after review. The list may only shrink..c/.cppfiles get no permanent exceptions.
Tests go in ci/test_platform_ifdef_ratchet.py, with one RED and one GREEN case per new rule:
_WIN32in a.mfile fails, and__APPLE__inobs-cocoa.mpasses.- A two-family
#ifinobs-nix.cfails. #include <windows.h>inlibobs/obs.cfails, and#include <unistd.h>inlibobs/util/threading-posix.cpasses.- A macro in a comment or a string isn't counted, and
__GNUC__/__x86_64__aren't counted.
CI scoping: existing paths, made permanent
- Keep the token classifier. In
ci/ci_scope.py, thelegacy_platforms()fallback (token matching viaci/platform_paths.py) is not legacy any more. It is how upstream-named paths (win-capture/,mac-*,obs-nix*.c,util/platform-cocoa.m, ...) map to an OS, and they keep their names. Replace the TODO that says to delete it with a note pointing at this policy. - Name ambiguous files explicitly. Where a token guess is wrong or ambiguous, list the path in
ci/platform_paths.py, as_MACOS_TOOalready does forutil/platform-nix.c, instead of renaming the file. - New row:
libobs/cmake/os-<os>.cmakestarts that OS only (today all oflibobs/cmake/is shared). Add tests inci/test_ci_scope.py. - Unchanged:
PLATFORM_RULE(/platform[/-](windows|macos|linux|posix)[/.]) stays as it is for new Rust and shared code laid out that way.
Draining the baseline
Remove the host conditionals already in shared files (obs-video.c, obs.c, obs-module.c, graphics/*, frontend, ...) as part of the work that touches them anyway:
- Preferred: the Rust port of that unit, where the crate's
src/platform/holds the host split. - Otherwise: move the branch into the existing OS-named files behind a small function, e.g.
obs-nix.c/obs-windows.c/obs-cocoa.m, orfrontend/utility/platform*.{hpp,cpp}.
Each PR lowers the baseline with --update. Don't open standalone "move this file" PRs.
Phases (one PR each)
- Docs: the layout policy above, in
naming.md,AGENTS.mdandrust/README.md. - Ratchet: rules 1–6 and their tests, with the baseline regenerated. No source changes.
ci_scope: theos-<os>.cmakerow, the TODO replaced, and explicit entries for ambiguous paths.- Ongoing: baseline reductions ride along with ports and fixes.
Done when
- Phases 1–3 are merged.
- A PR touching only a Windows-classified file (e.g.
libobs/util/platform-windows.c) runs the Windows lanes and no macOS job. A PR touching only core libobs runs Linux only. Check both on real PRs. - No C/C++ file was moved or renamed to get there.
Related: #847 (ifdef ratchet), #897 (path-based platform scoping), #992 / #1013 (path-scoped CI, PLATFORM_RULE), #1009 (platform folder naming), #443 (attested platform lanes), #695 / #697 (cross-compiling Windows and macOS on Linux).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-]libobs: Move all platform code behind libobs/platform/<os>/ (soldr-style boundary) so CI scopes by one path rule[/-][+]libobs + Rust: Move all host code behind host/<os>/ (soldr-style boundary, Dylint + C lint) so CI scopes by one path rule[/+][-]libobs + Rust: Move all host code behind host/<os>/ (soldr-style boundary, Dylint + C lint) so CI scopes by one path rule[/-][+]libobs + Rust: Move all host code behind hosts/<os>/ (exhaustive cfg_select, Dylint + C lint) so CI scopes by one path rule[/+][-]libobs + Rust: Move all host code behind hosts/<os>/ (exhaustive cfg_select, Dylint + C lint) so CI scopes by one path rule[/-][+]libobs + Rust: Move all host code into libobs/hosts/<os>/ and rust/hosts/<os>/ (one exhaustive cfg_select, Dylint + C lint) so CI scopes by one path rule[/+][-]libobs + Rust: Move all host code into libobs/hosts/<os>/ and rust/hosts/<os>/ (one exhaustive cfg_select, Dylint + C lint) so CI scopes by one path rule[/-][+]libobs + Rust: Move all host code into libobs/hosts/<os>/ and each crate's src/hosts/<os>/ (exhaustive cfg_select, Dylint + C lint) so CI scopes by one path rule[/+][-]libobs + Rust: Move all host code into libobs/hosts/<os>/ and each crate's src/hosts/<os>/ (exhaustive cfg_select, Dylint + C lint) so CI scopes by one path rule[/-][+]Host boundary without moving files: tighten the platform ifdef ratchet, keep CI path scoping, record the repo layout policy[/+]zackees commentedon Oct 16, 2026
Claiming: #1051 (phases 1–3).
One PR, one commit per phase; first push today.
ci: Check the host boundary by existing paths, without moving files (o…
libobs: Move core host code behind obs-host/ capability interfaces (o…
build: Cross-compile libobs for Windows and macOS from any host via s…
build: Cross-compile libobs for Windows and macOS from any host via s…
docs: BUILD.md, the native build policy (unity groups, one PCH per gr…
libobs: Move the per-frame video output step decisions into obs-video…
obs-core: Port the per-frame video output step decisions (obs-rust#2181)
obs-core: Port the canvas texture draw and display clear decisions (o…