You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ci: ratchet lint for platform conditionals in shared C/C++ (#847 step 1) #848
Add ci/platform_ifdef_ratchet.py, ci/test_platform_ifdef_ratchet.py and a committed baseline (ci/platform-ifdef-baseline.json, path to count). The lint counts platform #if/#ifdef/#ifndef/#elif lines in shared-named tracked C/C++/ObjC files under libobs/, frontend/, shared/, plugins/ and fails when a file exceeds its baseline or a new file appears with a platform conditional. Decreases are allowed (hint to lower the baseline; --update rewrites it). Wired into ./lint.
Scope update (policy, from #897): this lint is the C/C++ counterpart of the Rust ban_platform_cfg_outside_boundary Dylint, not just a counter.
Policy
Platform defines (_WIN32, _WIN64, _MSC_VER, __APPLE__, TARGET_OS_*, __linux__, __FreeBSD__, __unix__, OS_*, ...) in #if/#ifdef/#ifndef/#elif are allowed only in blessed locations:
platform-named files (*-windows.*, *-win32.*, *-osx.*, *-cocoa.*, *-nix.*, *-x11.*, *-wayland.*, .m/.mm, ...), matching the tokens ci/ci_scope.py uses so scoping and lint agree;
blessed platform directories (e.g. */platform/<os>/, plugins/win-*, plugins/mac-*, plugins/linux-*), listed in one allowlist in the script;
Anywhere else: zero. Existing offenders are grandfathered by the baseline (path → count), which may only go down; a new file or a higher count fails ./lint. When the baseline is empty, the lint is a plain ban.
Tests must cover: new conditional in a shared file fails; same conditional in a blessed file/dir passes; baseline decrease passes with a hint; #878 header exception passes. Also add a short "Platform boundary (C/C++)" paragraph next to the Rust rule in docs/rust-port/testing-policy.md.
Activity
zackees commentedon Oct 15, 2026
Claiming. Plan: 1) RED commit: tests + stub, 2) GREEN: ratchet script + baseline, wired into ./lint. One PR.
zackees commentedon Oct 15, 2026
Scope update (policy, from #897): this lint is the C/C++ counterpart of the Rust
ban_platform_cfg_outside_boundaryDylint, not just a counter.Policy
Platform defines (
_WIN32,_WIN64,_MSC_VER,__APPLE__,TARGET_OS_*,__linux__,__FreeBSD__,__unix__,OS_*, ...) in#if/#ifdef/#ifndef/#elifare allowed only in blessed locations:*-windows.*,*-win32.*,*-osx.*,*-cocoa.*,*-nix.*,*-x11.*,*-wayland.*,.m/.mm, ...), matching the tokensci/ci_scope.pyuses so scoping and lint agree;*/platform/<os>/,plugins/win-*,plugins/mac-*,plugins/linux-*), listed in one allowlist in the script;Anywhere else: zero. Existing offenders are grandfathered by the baseline (path → count), which may only go down; a new file or a higher count fails
./lint. When the baseline is empty, the lint is a plain ban.Tests must cover: new conditional in a shared file fails; same conditional in a blessed file/dir passes; baseline decrease passes with a hint; #878 header exception passes. Also add a short "Platform boundary (C/C++)" paragraph next to the Rust rule in
docs/rust-port/testing-policy.md.ci: Ratchet platform conditionals in shared C/C++ files (obs-rust#847) (
happy-eyeballs: Move the Winsock/BSD-socket code into platform/<os>/
obs-filters, oss-audio: Move the last platform conditionals out of sh…
text-freetype2: Move the platform defaults behind text-freetype2-plat…
text-freetype2: Move the platform defaults behind text-freetype2-plat…
obs-filters, oss-audio: Move the last platform conditionals out of sh…