Skip to content

libobs: Unity groups with one precompiled header each (BUILD.md) - #1147

Merged
zackees merged 2 commits into
masterfrom
build/libobs-groups
Oct 17, 2026
Merged

zackees merged 2 commits into
masterfrom
build/libobs-groups

Conversation

@zackees

@zackees zackees commented Oct 17, 2026

Copy link
Copy Markdown
Member

Converts libobs to the BUILD.md build. libobs is the first component; the others follow in this order: libobs-*, shared/, plugins/, frontend/.

Commits

  1. Pure git mv, 134 files, all R100.
    • foo.c becomes foo.c.h, and foo.m becomes foo.m.h.
    • The obs-host no-ops become obs-host/noop/<cap>.hpp.
    • obfuscate.c keeps its name: it is an interface source that plugins compile too.
  2. Everything else:
    • Unity groups. libobs/build/libobs.<name>+.h.c and +.h.m, with shared precompiled headers <family>.pch.h.
    • One include per file. Every implementation file includes exactly its group's header and nothing else. The header holds that file's old includes, the feature macros that came before them, and their platform conditionals.
    • Where families split. Groups get different headers where their dependencies differ:
      • FFmpeg;
      • util-only files, which the C oracle compiles on their own;
      • the Rust-ported files;
      • each platform;
      • optional features: PulseAudio, Wayland, GIO, portal shortcuts;
      • macros that must come first: _FILE_OFFSET_BITS and _GNU_SOURCE;
      • lean vs full <windows.h>;
      • the crash handler, which gets OBS_VERSION on the command line.
    • No-op capabilities are headers that each host file includes at its end. They are not group members.
    • cmake/common/groups.cmake. Grouped targets always build with unity and PCH on.
      • Per language, the most shared header is precompiled.
      • Groups of another family include their header textually. So do groups with their own compile options, such as -fobjc-arc.
      • The C tests that compile one libobs file get that file with its owner's include directories and definitions.
    • Lint. ci/test_build_groups.py (part of ./lint) enforces group membership and the one-include rule.
    • BUILD.md is updated, including why C-family files end in .h: clang-format formats a .hpp as C++, where private and new are keywords.
    • Paths are updated in the C tests' CMake (paths only), the C oracle, ci/, validate.sh and the ratchet baseline. The C oracle now sets _DEFAULT_SOURCE on Unix, as gnu17 does.

Verified locally, on this tree or on the same libobs changes

  • cmake/cross macOS arm64 and Windows x64: clean, on this tree.
  • ./lint: clean, on this tree. clang-format covers the .c.h files.
  • Linux: the grouped libobs and the 51 C tests that compile libobs files built clean, and 50 of them pass. test_video_io failed once under load 50+, then passed 3 out of 3 runs on its own.
  • Rust tiers: pass.
  • The C oracle: builds, and its tests pass.
  • Not run locally: a full ./unittest Tier 2, which is left to PR CI. Its earlier run found two problems, both fixed here: GIO in the Wayland header, and dstr-libc in the core header.

The full Windows/macOS run is dispatched separately, because PR CI does not build those apps.

foo.c -> foo.c.h, foo.m -> foo.m.h, in place; the obs-host no-op
capabilities obs-host/noop/<cap>.c -> <cap>.hpp (headers each host file
includes). git mv only, no content change: the unity groups and their
precompiled headers follow. util/windows/obfuscate.c stays: it is
OBS::obfuscate's interface source, compiled into plugins too.
libobs/build/ holds the groups (libobs.<name>+.h.c/.h.m) and their shared
precompiled headers (<family>.pch.h). Every implementation file includes
exactly its group's header and nothing else: its includes, the feature
macros that precede them and their platform conditionals moved there.
Families split where dependencies differ: FFmpeg (media), util/ alone
(the C oracle compiles those files on their own), the Rust-ported files,
each platform, optional features (PulseAudio, Wayland, GIO, portal
shortcuts), macros that must come first (_FILE_OFFSET_BITS, _GNU_SOURCE),
lean vs full <windows.h>, and the crash handler (OBS_VERSION on the
command line). The obs-host no-op capabilities are headers each host file
includes at its end.

cmake/common/groups.cmake: grouped targets always build unity + PCH; per
language the most shared header is precompiled, other families and groups
with their own compile options (-fobjc-arc) include theirs textually. A
target compiling an implementation file directly (the C tests) gets it in
its language with the owner's include directories and definitions.

ci/test_build_groups.py (in ./lint) enforces the groups and the
one-include rule. BUILD.md describes it: C-family files end in .h and
C++-family in .hpp, since clang-format formats a .hpp as C++. Paths
updated in the C tests' CMake, the C oracle (now _DEFAULT_SOURCE on Unix,
as gnu17 has, since a family header brings threading.h to all its files),
ci/ tooling, validate.sh and the ratchet baseline.
@zackees
zackees merged commit c441e83 into master Oct 17, 2026
33 of 34 checks passed
@zackees
zackees deleted the build/libobs-groups branch October 26, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant