hex/crates/capture-core/build.rs
Kit Langton bb2f56263c
feat(capture-core): shared macOS screen-recording library (#255)
* feat(capture-core): add shared macOS screen capture core

Records displays and windows with ScreenCaptureKit, one MP4 per source,
on one host clock, and writes a versioned capture.json manifest.

- stop() returns at once; finishing runs on the recording's own thread
- each stream keeps running until its detached recording output finishes
  or fails, then stops within 10 s
- a system stream stop is not an output failure; a finished MP4 is kept
- the final video frame is held to the recorded end
- external microphone PCM through a bounded sink, written as a WAV with
  recorded gaps; the core never opens a microphone in that mode
- host input through a bounded queue or an optional event tap, chord-only
  keys, dropped while secure input is on; ~240 Hz cursor sampling
- optional system audio file and low-rate RGBA frame tap

Kept outside the workspace and built only by the capture feature.

* feat(capture-core): regions, output size, screenshots, nanosecond clock

- Source::Region { display, rect }: a display-local rect applied as the
  stream's sourceRect, trimmed to the display, with exclusions
- SourcePlan::long_edge caps a source's longest side in pixels, keeping
  the aspect and never upscaling; sizes come from points and the
  filter's pixel scale
- screenshot(&Source, &Exclusions, long_edge) through SCScreenshotManager
  with the recording's filter construction
- every timestamp is Mach host time in nanoseconds: the manifest records
  "clock": "mach_host_ns" and anchor_ns; stream starts, audio file starts
  and gaps, cursor samples and clicks, and input events carry *_ns
- objc2-av-foundation and objc2-avf-audio use only the features in use, so
  the lockfile gains no registry crates
2026-10-27 20:08:40 -07:00

22 lines
806 B
Rust

use std::process::Command;
/// `screencapturekit` links Swift's runtime, which binaries (tests included) load from these
/// paths.
fn main() {
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("macos") {
return;
}
println!("cargo:rustc-link-arg=-Wl,-rpath,/usr/lib/swift");
if let Ok(output) = Command::new("xcode-select").arg("-p").output()
&& output.status.success()
&& let Ok(developer_dir) = String::from_utf8(output.stdout)
{
for runtime in ["swift-5.5/macosx", "swift/macosx"] {
let swift_runtime = format!(
"{}/Toolchains/XcodeDefault.xctoolchain/usr/lib/{runtime}",
developer_dir.trim()
);
println!("cargo:rustc-link-arg=-Wl,-rpath,{swift_runtime}");
}
}
}