integration-test: DRY clang setup

pull/727/head
Tamir Duberstein 1 year ago
parent dc9f72adf0
commit 0904cd089e
No known key found for this signature in database

@ -116,36 +116,30 @@ fn main() {
target_arch.push(arch); target_arch.push(arch);
}; };
let clang = || {
let mut cmd = Command::new("clang");
cmd.arg("-I")
.arg(&libbpf_headers_dir)
.args(["-g", "-O2", "-target", target, "-c"])
.arg(&target_arch);
cmd
};
for (src, dst) in c_bpf { for (src, dst) in c_bpf {
let src = bpf_dir.join(src); let src = bpf_dir.join(src);
println!("cargo:rerun-if-changed={}", src.to_str().unwrap()); println!("cargo:rerun-if-changed={}", src.to_str().unwrap());
exec( exec(clang().arg(src).arg("-o").arg(dst)).unwrap();
Command::new("clang")
.arg("-I")
.arg(&libbpf_headers_dir)
.args(["-g", "-O2", "-target", target, "-c"])
.arg(&target_arch)
.arg(src)
.arg("-o")
.arg(dst),
)
.unwrap();
} }
for (src, dst) in c_btf { for (src, dst) in c_btf {
let src = bpf_dir.join(src); let src = bpf_dir.join(src);
println!("cargo:rerun-if-changed={}", src.to_str().unwrap()); println!("cargo:rerun-if-changed={}", src.to_str().unwrap());
let mut cmd = Command::new("clang"); let mut cmd = clang();
cmd.arg("-I")
.arg(&libbpf_headers_dir)
.args(["-g", "-target", target, "-c"])
.arg(&target_arch)
.arg(src)
.args(["-o", "-"]);
let mut child = cmd let mut child = cmd
.arg(src)
.args(["-o", "-"])
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.spawn() .spawn()
.unwrap_or_else(|err| panic!("failed to spawn {cmd:?}: {err}")); .unwrap_or_else(|err| panic!("failed to spawn {cmd:?}: {err}"));

Loading…
Cancel
Save