Repository navigation
Description
Platform #if code inside shared C/C++ files makes CI scoping guesswork. A change to an #ifdef __APPLE__ block in a shared file can't be routed to macOS CI by path, so we either run every platform on every PR or miss real platform changes. Goal: shared code calls a platform facade, and each platform's code lives in platform-named files, so ci/ci_scope.py maps paths to platforms exactly. This is the C/C++ counterpart of the Rust src/platform/ rule, which the Dylint enforces.
Measured (master, 2026-10-15)
Platform conditionals (_WIN32, _MSC_VER, __APPLE__, TARGET_OS_*, __linux__, OS_*, ...) in files whose names don't mark a platform:
| area | files | #ifs |
|---|---|---|
| frontend/ | 60 | 265 |
| plugins/ | 69 | 208 |
| libobs/ | 36 | 94 |
| shared/ | 18 | 51 |
Worst offenders: frontend/OBSApp.cpp (47), frontend/obs-main.cpp (30), frontend/settings/OBSBasicSettings.cpp (29), frontend/widgets/OBSBasic.cpp (20), libobs/obs-video.c (10), libobs/obs.c (8).
Approach
- Frontend: extend the existing facade
frontend/utility/platform.hpp(implemented byplatform-osx.mm,platform-windows.cpp,platform-x11.cpp). Move each platform branch out of the shared file into a facade function with one implementation per platform. Behaviour is unchanged, and the moves are covered by tests where the code is testable (cmocka/Qt offscreen) and by the full native builds (ci-full). - libobs: follow the existing
obs-nix.c/obs-windows.c/obs-cocoa.msplit. The Rust port moves the rest intosrc/platform/. - Ratchet lint: fail any PR that adds a platform conditional to a shared-named file, with today's counts as the baseline. The baseline only goes down.
- Upstream merges: keep each move small and mechanical (one function per facade entry), so merges from upstream OBS stay manageable.
Sub-issues (in order)
- Ratchet lint for platform conditionals in shared C/C++ (baseline file +
ci/test). frontend/OBSApp.cpp→ facade.frontend/obs-main.cpp→ facade.frontend/settings/OBSBasicSettings.cpp→ facade.frontend/widgets/OBSBasic*.cpp→ facade.libobs/obs-video.c,libobs/obs.c,libobs/graphics/graphics.h→ existing per-platform files.- Plugins, by count.
Related: #698 and #700 (platform-scoped CI), #443 (native attestation).
Done when
- No shared-named C/C++ file has platform conditionals beyond the ones documented as unavoidable (for example the headers' export macros).
ci_scope.pydecides macOS/Windows runs from paths alone.
Sub-issues
Collapse Sub-issuesSub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTracker
Activity
22 remaining items
ci: Ratchet platform conditionals in shared C/C++ files (obs-rust#847) (
frontend: Move OBSApp.cpp platform conditionals behind the platform f…
build(cmake): gate the Apple Brotli stop-gap without a host condition…
build(cmake): gate the Apple Brotli stop-gap without a host condition…
build(cmake): gate the Apple Brotli stop-gap without a host condition…
build(cmake): gate the Apple Brotli stop-gap without a host condition…
curl: ask for brotli again where the decoder is pinned (obs-rust#2211) (