Skip to content

build(libobs): per-unit compile options and headers in ported-source-sets (#3236) - #3293

Merged
zackees merged 2 commits into
masterfrom
build/3236-per-unit-port-metadata
Oct 31, 2026
Merged

zackees merged 2 commits into
masterfrom
build/3236-per-unit-port-metadata

Conversation

@zackees

@zackees zackees commented Oct 31, 2026

Copy link
Copy Markdown
Member

Refs #3236, #3232

A libobs port now edits only its own libobs/build/ported-source-sets/<unit>.json, and no longer touches libobs/CMakeLists.txt or cmake/os-*.cmake.

Schema (BUILD.md)

{
  "LIBOBS_<...>PORTED_SOURCES": ["build/libobs.ported-<unit>+.h.c"],
  "compile_options": {"gnu": ["..."], "msvc": ["..."]},
  "headers": ["<unit>.h"]
}
  • compile_options: added to each of the unit's groups, one list per compiler family. gnu means C_COMPILER_ID GNU, Clang or AppleClang, which covers C and Objective-C. msvc means MSVC. They are source properties of libobs/, the same as the old blocks.
  • headers: listed on libobs-objects wherever one of the unit's sets is built.
  • libobs_add_ported_sources(<SET>) in sources.cmake replaces the obs_libobs_add_c_sources(${SET}) call and the "have Rust ports" comment for each set in os-linux and os-freebsd. Those files keep one line per optional set, and a port no longer edits them.
  • obs-build and rust/tools/ported_sources.py skip the new fields. obs-build never applied per-source flags (the C oracle sets its own), so its behavior is the same as before.

Migrated

  • drift: -ffp-contract=off, moved from CMakeLists
  • audio-controls: /wd4056 /wd4756, moved from CMakeLists
  • nsgif: new unit with the 4 groups. gnu -Wno-conversion -Wno-sign-conversion from CMakeLists, msvc /wd4244 /wd4267 from os-windows
  • data: new unit. -Wno-deprecated-declarations and /wd4996 from CMakeLists
  • macos-cocoa: new unit. -fobjc-arc from os-macos (the unported cocoa group keeps its line there)
  • pulse-stream-flags, pulse-monitor-format, pulse-monitor-steps, nix-hotkey-state: new units with their headers. The header lists come out of both os-linux and os-freebsd, and LIBOBS_PULSE_PORTED_SOURCES and LIBOBS_WAYLAND_PORTED_SOURCES are now empty
  • nix-wayland-keys: its header moves into the unit

Still central, on purpose

  • Target-wide settings: the /wd4702 uthash pin, the -Wconversion ratchet and host definitions.
  • The OBS_PUBLIC_HEADERS install list.
  • The windows interface-library headers.
  • One libobs_add_ported_sources line per optional set (PULSE, NIX_GIO, WAYLAND, WAYLAND_GIO). These are per set, not per port.

Tests

  • RED: on master, ci/test_port_unit_metadata.py fails with 5 failures and 1 error. CMakeLists, os-windows and os-macos name ported groups; os-linux and os-freebsd list ported headers and comments; the unit fields are missing; sources.cmake does not apply them.
  • GREEN: that test passes. So do test_ported_sources, test_sorted_shared_lists, test_libobs_source_set_fragments, test_conversion_measure, test_tier2_wayland_lane, test_build_groups and test_ci_scope (94 tests). ./lint is OK.
  • test_ported_sources no longer uses the hand-written PORTED_ON_EVERY_HOST list. It derives the objects from LIBOBS_PORTED_SOURCES (set file plus units) with a floor of 90. A new test, test_no_ported_c_links_into_production, checks that no ported implementation file is a member of a production group on any host.
  • soldr cargo test -p obs-build --lib: 4 passed. That includes the new unit_fields_are_skipped_and_members_kept. Test cost: under 1 ms, no threads.
  • Linux configure: rust/tools/linux-validate/run.py in Docker with OBS_BUILD_C_REFERENCE=ON, Pulse and Wayland on. Configure and build succeeded. ninja -t commands libobs-c-reference shows:
    • -ffp-contract=off on libobs.ported-audio-resampler-drift+.h.c (... -Werror -ffp-contract=off -MD ...)
    • -Wno-conversion -Wno-sign-conversion on nsgif-gif
    • -Wno-deprecated-declarations on ported-data
    • no MSVC flags on GCC
  • Tier 2 was not finished. 303 ctest cases passed with 0 failures, then I stopped the run (about 15 minutes in) to rebase onto build(libobs): one source-set file per set in source-sets.d (#3235) #3280. PR CI runs the full Tier 2.

The MSVC and macOS results come from PR CI and the cross lanes; I have not run them locally.

…3236) (RED)

ci/test_port_unit_metadata.py fails on master: libobs/CMakeLists.txt,
os-windows.cmake and os-macos.cmake name ported groups in per-group
set_property blocks, os-linux/os-freebsd list ported headers with
'have Rust ports' comments, and unit files have no compile_options or
headers fields that sources.cmake applies.

Refs #3236, #3232
…sets (#3236)

A port now edits only libobs/build/ported-source-sets/<unit>.json.
Optional fields beside the set keys:
- compile_options {gnu, msvc}: appended to each of the unit's groups
- headers: listed on libobs-objects wherever the unit's set is built

cmake/sources.cmake applies them; libobs_add_ported_sources(<SET>)
replaces the per-set obs_libobs_add_c_sources calls and comments in
os-linux/os-freebsd. obs-build and ported_sources.py skip the fields.

Migrated: drift -ffp-contract=off, audio-controls /wd4056 /wd4756,
nsgif conversion pins (gnu + msvc from os-windows), ported-data
deprecation pins, ported-macos-cocoa -fobjc-arc, the pulse
stream-flags/monitor-format/monitor-steps and nix-hotkey-state units
(new unit files with their headers) and nix-wayland-keys's header.

ci/test_ported_sources.py derives its every-host objects from
LIBOBS_PORTED_SOURCES (set + units) and checks that no ported
implementation file is in a production group.

Refs #3236, #3232

@zackees zackees left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coordinator review: I checked that the move loses nothing. Every per-unit option removed from libobs/CMakeLists.txt and cmake/os-*.cmake reappears in its unit's JSON:

  • audio-controls: /wd4056 /wd4756
  • audio-resampler-drift: -ffp-contract=off
  • data: -Wno-deprecated-declarations and /wd4996
  • macos-cocoa: -fobjc-arc
  • nsgif: -Wno-conversion -Wno-sign-conversion and /wd4244 /wd4267

The removed header listings moved to headers. pulseaudio-wrapper.h stays in os-linux.cmake/os-freebsd.cmake, as before.

One small widening: the old blocks used COMPILE_LANG_AND_ID:C,..., and gnu is now C_COMPILER_ID, which also matches Objective-C TUs. For these units that changes nothing, since the C-only units have no .m. If a future unit mixes C and Objective-C, -ffp-contract=off and the like would reach the .m files too, so it's worth a sentence in BUILD.md's schema note. No blocking findings.

@zackees
zackees added this pull request to the merge queue Oct 31, 2026
@obs-rust-project-manager obs-rust-project-manager Bot moved this to In merge queue in obs-rust Multiview Oct 31, 2026
Merged via the queue into master with commit 50dad86 Oct 31, 2026
42 checks passed
@zackees
zackees deleted the build/3236-per-unit-port-metadata branch October 31, 2026 22:53
@obs-rust-project-manager obs-rust-project-manager Bot moved this from In merge queue to Done in obs-rust Multiview Nov 1, 2026
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