chore: gate embed p2p transport on cargo feature (#157)

* chore: gate logos-delivery transport on cargo feature, not env-dependent cfg

* chore: fix clippy
This commit is contained in:
kaichao 2026-07-03 01:13:53 +08:00 committed by GitHub
parent 098612ba8b
commit 943ba2973f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 10 deletions

View File

@ -4,23 +4,22 @@ use std::process::Command;
fn main() {
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() {
return;
}
let Some(lib_dir) = locate_lib_dir() else {
// Feature is on but the native library is unavailable (e.g. `cargo
// check` on a machine without nix). Skip the cfg so the FFI module is
// not compiled — this keeps `cargo check` working without producing
// unresolved symbols at link time. `EmbeddedP2pDeliveryService` is
// simply absent until the library can be found.
println!(
"cargo:warning=embedded_p2p_delivery feature is enabled but \
liblogosdelivery could not be located; `cargo check`/`clippy` will \
pass, but building or testing will fail at link. Enter the dev shell \
with `nix develop` or set LOGOS_DELIVERY_LIB_DIR to the directory \
containing the library."
);
return;
};
println!("cargo:rustc-cfg=logos_delivery");
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();

View File

@ -2,8 +2,8 @@ mod local_broadcaster;
pub use local_broadcaster::LocalBroadcaster;
#[cfg(logos_delivery)]
#[cfg(feature = "embedded_p2p_delivery")]
pub mod embedded_p2p_delivery;
#[cfg(logos_delivery)]
#[cfg(feature = "embedded_p2p_delivery")]
pub use embedded_p2p_delivery::{EmbeddedP2pDeliveryService, P2pConfig};