From 93973902bc98e4ed725a001ed803a1a385818ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Balagu=C3=A9=20Guardia?= <25331181+dbalague@users.noreply.github.com> Date: Wed, 18 Jan 2023 09:42:24 +0100 Subject: [PATCH] added conditional to install on macos --- build.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index f37fe40..6e716ec 100644 --- a/build.rs +++ b/build.rs @@ -5,8 +5,25 @@ use std::path::Path; fn main() { let library = pkg_config::Config::new().probe("flac").unwrap(); let profile = env::var_os("PROFILE").unwrap(); - let from = library.link_paths.get(0).unwrap().join("libFLAC.so"); - let to = Path::new("target").join(profile).join("deps").join("libflac.so"); + + let lib_flac_from = String::from( + if env::consts::OS == "macos"{ + "libFLAC.dylib" + } + else{ + "libFLAC.so" + } + ); + let lib_flac_to = String::from( + if env::consts::OS == "macos"{ + "libFLAC.dylib" + } + else{ + "libflac.so" + } + ); + let from = library.link_paths.get(0).unwrap().join(lib_flac_from); + let to = Path::new("target").join(profile).join("deps").join(lib_flac_to); fs::copy(from, to).unwrap(); println!("cargo:rerun-if-changed=build.rs"); }