On Tue, Mar 18, 2025 at 09:51:05AM +0100, Dariusz Sosnowski wrote: > > +use std::process::Command; > > + > > +pub fn main() { > > + let mut pkgconfig = Command::new("pkg-config"); > > + > > + match pkgconfig.args(["--libs", "libdpdk"]).output() { > > + Ok(output) => { > > + let stdout = String::from_utf8_lossy(&output.stdout) > > + .trim_end() > > + .to_string(); > > + for token in stdout.split_ascii_whitespace().filter(|s| > > !s.is_empty()) { > > + if token.starts_with("-L") { > > + println!("cargo::rustc-link-search=native={}", > > &token[2..]); > > + } else if token.starts_with("-l") { > > + println!("cargo::rustc-link-lib={}", &token[2..]); > > + } > > + } > > + println!("cargo:rerun-if-changed=build.rs"); > > + } > > + Err(error) => { > > + panic!("failed to read libdpdk package: {:?}", error); > > + } > > + } > > +} > > > What do you think about using pkg_config crate in build scripts? > (https://crates.io/crates/pkg-config) > > This would allow to remove manual command execution and output parsing with > the following: > > fn main() { > pkg_config::probe_library("libdpdk").expect("Unable to find libdpdk"); > } > > Also, what do you think about moving this logic to dpdk crate? > This way dependency resolution would be shared by all examples/applications > which use the dpdk crate.
I just noticed that similar proposal was raised by Harry previously. Sorry for the duplication :)