From 85ab2ac70e639f840703ff60c0534737a4b308f5 Mon Sep 17 00:00:00 2001 From: mtkennerly Date: Thu, 5 Dec 2024 11:39:17 -0500 Subject: [PATCH] Fix Mac build --- Cargo.lock | 1 + Cargo.toml | 6 ++++++ build.rs | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 679e550..80a24a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2988,6 +2988,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", + "system-deps 7.0.3", "test-case", "tokio", "typed-path", diff --git a/Cargo.toml b/Cargo.toml index a404ed0..8f689e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,6 +47,9 @@ windows = { version = "0.58.0", features = ["Win32_System_Console", "Win32_Syste [target.'cfg(windows)'.build-dependencies] winres = "0.1.12" +[target.'cfg(target_os = "macos")'.build-dependencies] +system-deps = "7" + [dev-dependencies] pretty_assertions = "1.4.1" test-case = "3.3.1" @@ -79,3 +82,6 @@ pkg-fmt = "tgz" [package.metadata.binstall.overrides.x86_64-apple-darwin] pkg-url = "{ repo }/releases/download/v{ version }/{ name }-v{ version }-mac{ archive-suffix }" pkg-fmt = "tgz" + +[package.metadata.system-deps] +"gstreamer-1.0" = "1.14" diff --git a/build.rs b/build.rs index 98e6197..b0c8ff2 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,7 @@ +#[cfg(docsrs)] +fn main() {} + +#[cfg(not(docsrs))] fn main() { println!("cargo:rerun-if-env-changed=MADAMIRU_VERSION"); println!("cargo:rerun-if-changed=assets/windows/manifest.xml"); @@ -9,4 +13,22 @@ fn main() { res.set_manifest_file("assets/windows/manifest.xml"); res.compile().unwrap(); } + + // https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1516 + #[cfg(target_os = "macos")] + match system_deps::Config::new().probe() { + Ok(deps) => { + let usr = std::path::Path::new("/usr/lib"); + let usr_local = std::path::Path::new("/usr/local/lib"); + for dep in deps.all_link_paths() { + if dep != &usr && dep != &usr_local { + println!("cargo:rustc-link-arg=-Wl,-rpath,{:?}", dep.as_os_str()); + } + } + } + Err(s) => { + println!("cargo:warning={s}"); + std::process::exit(1); + } + } }