Repository navigation
Description
Part of #847.
Inventory of platform conditionals in frontend/obs-main.cpp measured on origin/master. Total: 30.
Conditionals
| Line | Macro | What the branch does |
|---|---|---|
| 21 | __APPLE__ |
include OBSPermissions.hpp |
| 32 | _WIN32 |
include win-version.h |
| 44 | _WIN32 |
include shellapi.h / windows.h |
| 95 | _WIN32 |
localtime_s vs localtime_r in timestamp helper |
| 204 | !_WIN32 |
va_copy of log args for the default handler |
| 211 | _WIN32 |
log handler: IsDebuggerPresent -> OutputDebugString of the line |
| 229 | !_WIN32 && _DEBUG |
echo log to default handler in debug builds |
| 234 | !_WIN32 && !_DEBUG |
echo log to default handler in release builds |
| 242 | _WIN32 && OBS_DEBUGBREAK_ON_ERROR |
__debugbreak() on LOG_ERROR with debugger attached |
| 248 | !_WIN32 |
va_end of args2 |
| 407 | _WIN32 |
open log file by wide path (utf8 -> wcs) |
| 505 | _WIN32 |
Qt high-DPI rounding policy PassThrough |
| 511 | __APPLE__ |
InstallNSApplicationSubclass / InstallNSThreadLocks |
| 522 | !_WIN32 && !__APPLE__ |
turn off the incompatible gtk Qt theme (env override) on Linux/BSD |
| 560 | _WIN32 |
keep the RunOnceMutex returned by CheckIfAlreadyRunning |
| 607 | !_WIN32 && !__APPLE__ && !__FreeBSD__ |
detect ChromeOS cros-containers dir |
| 625 | _WIN32 && OBS_RUST_VERSION |
VerifyAppIdentity after logger ready |
| 631 | __APPLE__ |
VerifyMacApplicationIcon |
| 662 | __APPLE__ |
CheckPermission for audio/video/input-monitoring at startup |
| 677 | _WIN32 |
IsRunningOnWine warning dialog |
| 729 | _WIN32 |
crash message / crash-log copy dialog |
| 753 | _WIN32 |
open crash log file by wide path |
| 765 | _WIN32 |
normalise path separators to backslash |
| 836 | _WIN32 |
Outdated VC++ runtime error strings/helper |
| 886 | __APPLE__ or __linux__ |
BASE_PATH ".." vs "../.." |
| 892 | ENABLE_PORTABLE_CONFIG or _WIN32 |
ALLOW_PORTABLE_MODE define |
| 900 | !_WIN32 |
install SIGINT/SIGTERM handlers |
| 934 | _WIN32 |
abort if MSVC runtime outdated; DLL blocklist / rtwq init |
| 1071 | _WIN32 |
--help via MessageBoxA vs stdout |
| 1112 | _WIN32 |
RtwqShutdown at exit |
Proposed facade operations
Declared in frontend/utility/platform.hpp; implemented in frontend/utility/platform-windows.cpp, platform-osx.mm, platform-x11.cpp (Linux/BSD). Names are proposals; one facade function per logical operation, moves kept small and mechanical so upstream merges stay manageable.
| Facade function | Implementation |
|---|---|
platform_localtime(const time_t*, tm*) |
platform-windows.cpp (localtime_s) / platform-x11.cpp + platform-osx.mm (localtime_r); one entry shared with utility/CrashHandler.cpp |
platform_log_to_debugger(const char*), platform_debugbreak_on_error(), platform_echo_log_to_console(level,msg,args) |
windows: debugger output/debugbreak; osx/x11: default handler echo |
platform_open_text_stream(path, mode) |
windows: wide-path open; others: narrow (log file, crash log, path separator normalisation) |
platform_early_init() (DPI policy, NS subclass/thread locks, Qt style env override, VC runtime check, DLL blocklist) and platform_late_init() (app identity, mac icon) |
per platform |
platform_check_startup_permissions(), platform_is_wine(), platform_detect_chromeos(), platform_crash_report_prompt() |
osx / windows / x11 |
platform_install_signal_handlers() |
x11 + osx; no-op on windows |
platform_show_help(text), platform_shutdown(), constants platform_base_path() / platform_allow_portable_mode() |
per platform |
Likely must stay / caveats
- Include-only conditionals (21/32/44) move into the platform impl files together with the code using them.
ENABLE_PORTABLE_CONFIG,OBS_RUST_VERSION,OBS_DEBUGBREAK_ON_ERROR,_DEBUGare build-feature macros, not platform macros; they stay inside the facade implementation.RunOnceMutex(560) is a Windows-only type; expose an opaquePlatformInstanceGuardfrom the facade.
Test approach
Characterisation tests for the pure pieces (platform_localtime, path separator normalisation, platform_base_path, portable-mode default) as a small Qt-free unit test run on each OS; the rest is covered by native builds (ci-full) and the startup smoke in test-appimage.sh.
RED first (failing characterisation test or facade stub), then GREEN, per docs/rust-port/testing-policy.md. Add the ci-full label since this touches shared frontend code built natively on all platforms.
Done when the listed files have no platform conditionals other than the documented exceptions, and the ratchet baseline (#848) is lowered accordingly.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Oct 24, 2026
Claiming: #865 (frontend/obs-main.cpp.hpp, 26 baseline findings plus 4 in its PCH).
Plan, one PR per slice, each with a Tier 2/Qt test RED first:
do_log/debugbreak/crash handler, lines ~170-220) behind host functions infrontend/utility/platform.hpp, withplatform-{windows,osx,x11}implementations.First PR expected within a day.
test: frontend obs-main macOS header defines nothing on Linux (#865)
frontend: obs-main startup checks behind per-OS host headers (#865)
frontend: obs-main Windows logging hooks in a self-guarded header (ob…
frontend: obs-main PCH includes the macOS, Linux and Unix host headers (
test: frontend obs-main Windows startup and portable mode stay off Li…
frontend: obs-main Windows startup, crash dialog and portable mode be…
frontend: obs-main startup checks behind per-OS host headers (obs-rus…
zackees commentedon Oct 24, 2026
Done in #2167, #2170 and #2176.
frontend/obs-main.cpp.hppand its PCH no longer test platform macros, and both have left the ratchet baseline.frontend/utility/obs-main-{windows,macos,linux,posix}.hppare self-guarded host headers in the obs-main PCH. They cover:BASE_PATHandALLOW_PORTABLE_MODEfrontend/utility/obs-main-host-windows.cpp.hppis in a newfrontend.windows-obs-mainunity group. It holds the crash dialog, the debug privilege, the VC++ runtime check, mitigation policies, early init and RTWorkQ, and the help box.test_frontend_obs_main_hostchecks that the macOS and Windows headers stay off Linux. One behavior change: the ChromeOS check now keys on__linux__.frontend: obs-main Windows startup, crash dialog and portable mode be…