diff options
| author | root <root@sg2.noml.ch> | 2025-12-29 22:18:04 +0800 |
|---|---|---|
| committer | root <root@sg2.noml.ch> | 2025-12-29 22:18:04 +0800 |
| commit | 1951b063d7ec6d6e8db8a0b5074c73f887749208 (patch) | |
| tree | 6ece8dfce605fbff6eca6be4bbeb5d7904417bbb /xtask/src/main.rs | |
initial commitmain
Diffstat (limited to 'xtask/src/main.rs')
| -rw-r--r-- | xtask/src/main.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/xtask/src/main.rs b/xtask/src/main.rs new file mode 100644 index 0000000..1009eef --- /dev/null +++ b/xtask/src/main.rs | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | use anyhow::Result; | ||
| 2 | use std::process::Command; | ||
| 3 | |||
| 4 | fn main() -> Result<()> { | ||
| 5 | let args: Vec<String> = std::env::args().collect(); | ||
| 6 | |||
| 7 | if args.len() < 2 { | ||
| 8 | eprintln!("Usage: cargo xtask build-ebpf"); | ||
| 9 | std::process::exit(1); | ||
| 10 | } | ||
| 11 | |||
| 12 | match args[1].as_str() { | ||
| 13 | "build-ebpf" => build_ebpf()?, | ||
| 14 | _ => eprintln!("Unknown command: {}", args[1]), | ||
| 15 | } | ||
| 16 | |||
| 17 | Ok(()) | ||
| 18 | } | ||
| 19 | |||
| 20 | fn build_ebpf() -> Result<()> { | ||
| 21 | let status = Command::new("cargo") | ||
| 22 | .args(&[ | ||
| 23 | "+nightly", | ||
| 24 | "build", | ||
| 25 | "--target=bpfel-unknown-none", | ||
| 26 | "--release", | ||
| 27 | "-Z", | ||
| 28 | "build-std=core", | ||
| 29 | "--manifest-path=packet-detector-ebpf/Cargo.toml", | ||
| 30 | ]) | ||
| 31 | .status()?; | ||
| 32 | |||
| 33 | if !status.success() { | ||
| 34 | anyhow::bail!("Failed to build eBPF program"); | ||
| 35 | } | ||
| 36 | |||
| 37 | Ok(()) | ||
| 38 | } | ||
