From ecd1a3165eaecedaa4c8abac6507193c78d226fd Mon Sep 17 00:00:00 2001 From: Miguel Date: Mon, 27 May 2024 14:31:39 -0400 Subject: [PATCH] cli: make aya deps platform specific --- Cargo.lock | 11 ----------- core/cli/Cargo.toml | 7 ++++--- core/cli/src/commands/admin.rs | 8 +++++--- core/cli/src/commands/mod.rs | 2 +- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dfa19a1d5..f9ead9d7f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6169,23 +6169,12 @@ dependencies = [ "workspace-hack 0.1.0", ] -[[package]] -name = "lightning-ebpf-common" -version = "0.0.0" -dependencies = [ - "aya", -] - [[package]] name = "lightning-ebpf-service" version = "0.0.0" dependencies = [ "anyhow", - "aya", - "aya-log", "bytes", - "libc", - "lightning-ebpf-common", "log", "notify", "once_cell", diff --git a/core/cli/Cargo.toml b/core/cli/Cargo.toml index 206ee8d28..194ddb7e1 100644 --- a/core/cli/Cargo.toml +++ b/core/cli/Cargo.toml @@ -14,8 +14,6 @@ lightning-final-bindings = { path = "../final-bindings" } lightning-utils = { path = "../utils" } lightning-tui = { path = "../../etc/tui" } -aya = { git = "https://github.com/aya-rs/aya", rev = "e5d107d", features = ["async_tokio"], optional = true } -aya-log = { git = "https://github.com/aya-rs/aya", rev = "e5d107d", optional = true } fleek-crypto.workspace = true resolved-pathbuf.workspace = true tokio.workspace = true @@ -61,9 +59,12 @@ fleek-blake3 = "1.5" default = [] # Opt-in for compiling services directly inside the node. services = ["lightning-final-bindings/services"] -ebpf = ["aya", "aya-log", "lightning-ebpf-service/server"] dev = ["lightning-tui/logger", "tui-logger"] +[target.'cfg(linux)'.dependencies] +aya = { git = "https://github.com/aya-rs/aya", rev = "e5d107d", features = ["async_tokio"], optional = true } +aya-log = { git = "https://github.com/aya-rs/aya", rev = "e5d107d", optional = true } + [[bin]] name = "lightning-node" path = "src/main.rs" diff --git a/core/cli/src/commands/admin.rs b/core/cli/src/commands/admin.rs index afe418cb9..c521dfb2a 100644 --- a/core/cli/src/commands/admin.rs +++ b/core/cli/src/commands/admin.rs @@ -11,9 +11,9 @@ use tracing::debug; #[cfg(feature = "tui-dev")] use tracing::log::LevelFilter; -#[cfg(feature = "ebpf")] +#[cfg(target_os = "linux")] use crate::commands::ebpf; -#[cfg(feature = "ebpf")] +#[cfg(target_os = "linux")] use crate::commands::ebpf::EbpfCmd; pub static BIND_PATH: OnceCell = OnceCell::new(); @@ -23,7 +23,7 @@ pub static PATH_CONFIG: OnceCell = OnceCell::new(); pub enum AdminSubCmd { /// Start the Admin TUI. Tui(TuiCmd), - #[cfg(feature = "ebpf")] + #[cfg(target_os = "linux")] #[clap(subcommand)] /// Start the eBPF Control Application. Ebpf(EbpfCmd), @@ -74,6 +74,8 @@ pub async fn exec(cmd: AdminSubCmd) -> Result<()> { File::create(config.packet_filter.as_path())?; } + // Todo: maybe we could allow users to configure these values via CLI + // and remove these globals? PATH_CONFIG.set(config).expect("Not to be initialized yet"); BIND_PATH .set( diff --git a/core/cli/src/commands/mod.rs b/core/cli/src/commands/mod.rs index ff115f2f5..8ec4c802a 100644 --- a/core/cli/src/commands/mod.rs +++ b/core/cli/src/commands/mod.rs @@ -1,6 +1,6 @@ pub mod admin; pub mod dev; -#[cfg(feature = "ebpf")] +#[cfg(target_os = "linux")] pub mod ebpf; pub mod keys; pub mod opt;