Skip to content

facade: plugins/frontend-tools: move 10 platform conditionals behind a per-platform layer #855

Closed

Description

@zackees

Inventory of platform conditionals in shared-named files of plugins/frontend-tools/ (10 #ifs in 6 files). Existing pattern: auto-scene-switcher-{win.cpp,osx.mm,nix.cpp}.

file lines macro what the branch does
frontend-tools.c 10, 25, 42 _WIN32 InitCaptions/FreeCaptions declarations and calls (MS SAPI captions are Windows-only)
auto-scene-switcher.cpp 500 !__APPLE__ && !_WIN32 skip on Wayland sessions
scripts.cpp 35 Python_FOUND + _WIN32||__APPLE__ PYTHON_UI feature flag (Python path UI only on Win/mac)
654 __APPLE__ trim Python.framework/Versions suffix from configured Python path
captions.cpp 15, 22 _MSC_VER push/pop warning 4996
captions-mssapi.hpp 12, 19 _MSC_VER push/pop warning 4996

Proposed facade

plugins/frontend-tools/platform.h:

  • frontend_tools_platform_load() / _unload() (calls Init/FreeCaptions on Windows; no-op elsewhere) in platform-windows.cpp and platform-other.cpp (or reuse the auto-scene-switcher-* per-platform files)
  • scene_switcher_platform_supported() (Wayland check) in the auto-scene-switcher-nix.cpp / -osx.mm / -win.cpp trio
  • scripts_platform_python_ui_enabled() and scripts_platform_normalize_python_path(path) (mac implementation in a new scripts-osx.mm)

Likely must stay

  • _MSC_VER pragma pairs in captions.cpp and captions-mssapi.hpp: these files are only compiled on Windows (CMake OS_WINDOWS); rename to captions-windows.cpp / captions-mssapi-windows.hpp so the path marks the platform and the conditionals can be dropped.
  • PYTHON_UI define (scripts.cpp:35) can become a CMake-level definition set from the platform block instead.
  • CMake OS_LINUX... / OS_WINDOWS (CMakeLists.txt:5,77) stay.

Test approach

Behaviour-preserving moves. Verify with: the plugin's native builds on each platform (ci-full label, since these are outside the quick gate), the existing cmocka tests where the moved function is testable, and ./lint. Where a facade function is pure (path/name/constant selection) add a small unit test per platform implementation. The #847 ratchet lint baseline must go down by the count moved.

Part of #847.

Activity

  1. zackees commented on Oct 17, 2026

    @zackees
    MemberAuthor

    Claiming. Same shape as #1248/#1252/#1257/#1263: a conditional-free frontend-tools-host.h (captions load/unload, scene-switcher Wayland check, Python UI flag, macOS Python.framework path trim) with frontend-tools-host-{windows,macos,posix} implementations in per-OS groups; upstream files edited in place, not renamed (#1051), so the Windows-only captions files keep their names. The pure Python-path trim gets a cmocka test (RED then GREEN); baseline goes down by what moves.

  2. added
    claimed
    on Oct 17, 2026
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

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions