29 lines
1.0 KiB
Rust
Raw Normal View History

2026-06-23 13:52:29 -07:00
fn main() {
println!("cargo:rerun-if-env-changed=LOGOS_DELIVERY_LIB_DIR");
println!("cargo::rustc-check-cfg=cfg(logos_delivery)");
2026-06-23 17:31:07 -07:00
let feature_enabled = std::env::var("CARGO_FEATURE_EMBEDDED_P2P_DELIVERY").is_ok();
2026-06-23 13:52:29 -07:00
let lib_dir = std::env::var("LOGOS_DELIVERY_LIB_DIR");
let lib_dir = match lib_dir {
Ok(dir) => dir,
Err(_) if !feature_enabled => return,
Err(_) => {
// Feature is on but no library path — enable compilation, skip linking.
println!("cargo:rustc-cfg=logos_delivery");
return;
}
};
println!("cargo:rustc-cfg=logos_delivery");
println!("cargo:rustc-link-search=native={lib_dir}");
println!("cargo:rustc-link-lib=dylib=logosdelivery");
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
match target_os.as_str() {
"macos" | "linux" => println!("cargo:rustc-link-arg=-Wl,-rpath,{lib_dir}"),
other => panic!("unsupported OS for logos-delivery transport: {other}"),
}
}