Files
openclaw/apps/linux/src-tauri/build.rs
Peter Steinberger 992a86a28f fix(linux): make the companion's Rust test suite runnable and run it (#114260)
Three defects that compounded into a test suite nobody could run and nobody
was running.

The suite has been red on main since 2026-07-20. `connect_frame_matches_gateway_schema`
asserts a TLS-pinned connection advertises no capabilities, but #111933 wrote
that assertion while caps held only inline-widgets, and #111920 made
`agent-kind` unconditional the same day. No textual conflict, so both landed
and the assertion has been wrong ever since. Pinning only withdraws inline
widgets, so assert exactly that.

`cargo test` could not run on macOS at all: tauri-plugin-notifications links a
Swift static library, nothing adds an rpath for the Swift runtime, and every
test binary aborted at load with `Library not loaded:
@rpath/libswift_Concurrency.dylib`. Emit the rpath from build.rs.

Neither surfaced because linux-app.yml never ran `cargo test` - it only checked
formatting and built bundles. Run the suite on Linux, and upgrade the macOS job
from `check` to `test` so link-time breakage like the rpath is caught at all;
`check` never links, so it cannot see this class of failure.
2026-07-26 23:43:32 -04:00

36 lines
1.3 KiB
Rust

fn main() {
link_macos_swift_runtime();
// Command metadata generates capability permissions independently of the
// target's invoke handler, so keep the Linux-only command permission known.
const COMMANDS: &[&str] = &[
"bootstrap",
"build_info",
"canvas_a2ui_action",
"check_for_updates",
"connect_discovered_gateway",
"discover_gateways",
"gateway_action",
"install_cli",
"open_release_page",
"relaunch",
"updater_ready",
];
tauri_build::try_build(
tauri_build::Attributes::new()
.app_manifest(tauri_build::AppManifest::new().commands(COMMANDS)),
)
.expect("Tauri build configuration should be valid");
}
/// tauri-plugin-notifications links a Swift static library into us, but nothing
/// adds an rpath for the Swift runtime it pulls in. Bundled apps get one from
/// the bundler; plain `cargo run` and `cargo test` binaries do not, so they die
/// at load with `Library not loaded: @rpath/libswift_Concurrency.dylib`. Point
/// them at the OS runtime so the test suite is runnable on macOS.
fn link_macos_swift_runtime() {
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("macos") {
return;
}
println!("cargo:rustc-link-arg=-Wl,-rpath,/usr/lib/swift");
}