refactor: Make eBPF build optional in packet-gateway build script

- Change eBPF build from required to optional with graceful fallback
- Add match statement to handle build success, failure, and missing cargo-build-bpf cases
- Add cargo warnings when eBPF build fails or cargo-build-bpf is not installed
- Remove panic on build failure to allow compilation without eBPF toolchain
This commit is contained in:
nutcas3
2026-04-26 01:24:17 +03:00
parent 3b2edc5ccf
commit 10ac6bb861
+14 -5
View File
@@ -1,13 +1,22 @@
use std::process::Command;
fn main() {
// Build the eBPF program
// Try to build the eBPF program, but skip if cargo-build-bpf is not installed
let status = Command::new("cargo")
.args(&["build-bpf", "--release"])
.status()
.expect("Failed to execute cargo build-bpf");
.status();
if !status.success() {
panic!("Failed to build eBPF program");
match status {
Ok(status) if status.success() => {
// eBPF build succeeded
}
Ok(_) => {
// eBPF build failed, but continue without it
println!("cargo:warning=Failed to build eBPF program, continuing without it");
}
Err(_) => {
// cargo-build-bpf not installed, skip eBPF build
println!("cargo:warning=cargo-build-bpf not installed, skipping eBPF build");
}
}
}