mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-07-06 16:09:31 +00:00
chore: gate logos-delivery transport on cargo feature, not env-dependent cfg
This commit is contained in:
parent
ebae3317d6
commit
39ecdbeb12
@ -4,23 +4,24 @@ use std::process::Command;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("cargo:rerun-if-env-changed=LOGOS_DELIVERY_LIB_DIR");
|
println!("cargo:rerun-if-env-changed=LOGOS_DELIVERY_LIB_DIR");
|
||||||
println!("cargo::rustc-check-cfg=cfg(logos_delivery)");
|
|
||||||
|
|
||||||
if std::env::var_os("CARGO_FEATURE_EMBEDDED_P2P_DELIVERY").is_none() {
|
if std::env::var_os("CARGO_FEATURE_EMBEDDED_P2P_DELIVERY").is_none() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The `embedded_p2p_delivery` feature compiles the FFI module, whose symbols
|
||||||
|
// resolve only against liblogosdelivery. The feature therefore *requires* the
|
||||||
|
// native library; if it can't be located, fail fast with actionable guidance
|
||||||
|
// rather than letting a downstream crate fail later with a confusing
|
||||||
|
// unresolved-import or link error.
|
||||||
let Some(lib_dir) = locate_lib_dir() else {
|
let Some(lib_dir) = locate_lib_dir() else {
|
||||||
// Feature is on but the native library is unavailable (e.g. `cargo
|
panic!(
|
||||||
// check` on a machine without nix). Skip the cfg so the FFI module is
|
"embedded_p2p_delivery feature is enabled but liblogosdelivery could \
|
||||||
// not compiled — this keeps `cargo check` working without producing
|
not be located; enter the dev shell with `nix develop` or set \
|
||||||
// unresolved symbols at link time. `EmbeddedP2pDeliveryService` is
|
LOGOS_DELIVERY_LIB_DIR to the directory containing the library."
|
||||||
// simply absent until the library can be found.
|
);
|
||||||
return;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("cargo:rustc-cfg=logos_delivery");
|
|
||||||
|
|
||||||
let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR not set");
|
let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR not set");
|
||||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
||||||
|
|
||||||
|
|||||||
@ -2,8 +2,8 @@ mod local_broadcaster;
|
|||||||
|
|
||||||
pub use local_broadcaster::LocalBroadcaster;
|
pub use local_broadcaster::LocalBroadcaster;
|
||||||
|
|
||||||
#[cfg(logos_delivery)]
|
#[cfg(feature = "embedded_p2p_delivery")]
|
||||||
pub mod embedded_p2p_delivery;
|
pub mod embedded_p2p_delivery;
|
||||||
|
|
||||||
#[cfg(logos_delivery)]
|
#[cfg(feature = "embedded_p2p_delivery")]
|
||||||
pub use embedded_p2p_delivery::{EmbeddedP2pDeliveryService, P2pConfig};
|
pub use embedded_p2p_delivery::{EmbeddedP2pDeliveryService, P2pConfig};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user