Created
September 21, 2024 12:11
-
-
Save zopsicle/224d1b8a2220a06d9de4093f39b4168e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{env, sync::LazyLock}; | |
pub fn LinkCmakeLibrary(currentBinaryDir: &str, name: &str) | |
{ | |
const cmakeBinaryDir: &str = env!("STELLAR_CMAKE_BINARY_DIR"); | |
static cmakeConfig: LazyLock<&'static str> = LazyLock::new(|| { | |
let cargoProfile = env::var("PROFILE").unwrap(); | |
match cargoProfile.as_str() { | |
"debug" => "Debug", | |
"release" => "Release", | |
_ => panic!("Unknown Cargo profile: {cargoProfile}"), | |
} | |
}); | |
let targetFileDir = | |
format!("{cmakeBinaryDir}/{currentBinaryDir}/{}", *cmakeConfig); | |
println!("cargo::rerun-if-changed={targetFileDir}/{name}.lib"); | |
println!("cargo::rustc-link-search=native={targetFileDir}"); | |
println!("cargo::rustc-link-lib=static={name}"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment