style: switch rustfmt to hard tabs; document tests-separate rule in TODO
- rustfmt.toml: hard_tabs = true; whole tree reformatted (no logic changes) - TODO §0.7: tests live in tests/, never inline #[cfg(test)] in code files (legacy inline tests to be migrated, see Backlog) - TODO: add backlog item for the inline-test migration
This commit is contained in:
parent
d8393e0f39
commit
18a0ffa53d
96 changed files with 6542 additions and 6537 deletions
68
build.rs
68
build.rs
|
|
@ -2,44 +2,44 @@ use std::path::PathBuf;
|
|||
use std::process::Command;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let has_xdp_feature = std::env::var("CARGO_FEATURE_XDP").is_ok();
|
||||
if !has_xdp_feature {
|
||||
return Ok(());
|
||||
}
|
||||
let has_xdp_feature = std::env::var("CARGO_FEATURE_XDP").is_ok();
|
||||
if !has_xdp_feature {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let manifest_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?);
|
||||
let xdp_dir = manifest_dir.join("xdp");
|
||||
let out_dir = PathBuf::from(std::env::var("OUT_DIR")?);
|
||||
let manifest_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?);
|
||||
let xdp_dir = manifest_dir.join("xdp");
|
||||
let out_dir = PathBuf::from(std::env::var("OUT_DIR")?);
|
||||
|
||||
let src = xdp_dir.join("core/universal_filter.c");
|
||||
let dst = out_dir.join("universal_filter.o");
|
||||
let src = xdp_dir.join("core/universal_filter.c");
|
||||
let dst = out_dir.join("universal_filter.o");
|
||||
|
||||
println!("cargo:rerun-if-changed={}", src.display());
|
||||
println!("cargo:rerun-if-changed={}", src.display());
|
||||
|
||||
let host_triple = std::env::var("HOST").unwrap_or_default();
|
||||
let arch = host_triple.split('-').next().unwrap_or(&host_triple);
|
||||
let status = Command::new("clang")
|
||||
.args([
|
||||
"-O2",
|
||||
"-g",
|
||||
"-target",
|
||||
"bpf",
|
||||
"-mcpu=v3",
|
||||
"-c",
|
||||
src.to_str().ok_or("src path is not valid UTF-8")?,
|
||||
"-o",
|
||||
dst.to_str().ok_or("dst path is not valid UTF-8")?,
|
||||
&format!("-I{}", xdp_dir.display()),
|
||||
&format!("-I{}", xdp_dir.join("core").display()),
|
||||
&format!("-I{}", xdp_dir.join("hooks").display()),
|
||||
&format!("-I/usr/include/{}-linux-gnu", arch),
|
||||
])
|
||||
.status()?;
|
||||
let host_triple = std::env::var("HOST").unwrap_or_default();
|
||||
let arch = host_triple.split('-').next().unwrap_or(&host_triple);
|
||||
let status = Command::new("clang")
|
||||
.args([
|
||||
"-O2",
|
||||
"-g",
|
||||
"-target",
|
||||
"bpf",
|
||||
"-mcpu=v3",
|
||||
"-c",
|
||||
src.to_str().ok_or("src path is not valid UTF-8")?,
|
||||
"-o",
|
||||
dst.to_str().ok_or("dst path is not valid UTF-8")?,
|
||||
&format!("-I{}", xdp_dir.display()),
|
||||
&format!("-I{}", xdp_dir.join("core").display()),
|
||||
&format!("-I{}", xdp_dir.join("hooks").display()),
|
||||
&format!("-I/usr/include/{}-linux-gnu", arch),
|
||||
])
|
||||
.status()?;
|
||||
|
||||
if !status.success() {
|
||||
return Err("XDP C compilation failed (see clang errors above)".into());
|
||||
}
|
||||
if !status.success() {
|
||||
return Err("XDP C compilation failed (see clang errors above)".into());
|
||||
}
|
||||
|
||||
println!("cargo:rerun-if-env-changed=CARGO_FEATURE_XDP");
|
||||
Ok(())
|
||||
println!("cargo:rerun-if-env-changed=CARGO_FEATURE_XDP");
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue