Skip to content

ci: ratchet lint for platform conditionals in shared C/C++ (#847 step 1) #848

Closed

Description

@zackees

Sub-issue of #847.

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.

Activity

  1. zackees commented on Oct 15, 2026

    @zackees
    MemberAuthor

    Claiming. Plan: 1) RED commit: tests + stub, 2) GREEN: ratchet script + baseline, wired into ./lint. One PR.

  2. zackees commented on Oct 15, 2026

    @zackees
    MemberAuthor

    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;
    • the documented public-header exceptions from facade: libobs public headers (record, stays): 33 platform conditionals #878 (export macros etc.), listed explicitly per file.

    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.

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