Closed shuaimu closed 7 years ago
btw, my current approach:
let output = Command::new("pkg-config")
.arg("--cflags")
.arg("--libs")
.arg("libraryname")
.output()
.expect("failed to execute pkg-config");
let flags = format!("{}", String::from_utf8_lossy(&output.stdout));
let flags_split = flags.split(" ");
let mut cppbuild = cpp_build::Config::new();
for f in flags_split {
cppbuild.flag(f);
}
cppbuild.build("src/main.rs");
It works, but is there a more elegant way?
There might be a more elegant way to handle this, but rust-cpp
doesn't really help with it. We internally use gcc-rs
to do the actual compiling (https://github.com/alexcrichton/gcc-rs), so if there are other packages building pkg-config
-based files with gcc-rs
you can copy what they do.
I think that providing tools for parsing command lines is out of scope for rust-cpp
. There might be crates for it on crates.io.
Thanks for your reply. I dived into the gcc-rs and rustc for a little while. I agree that it is out of the scope of rust-cpp.
This is probably another silly question. But is there any easy way to use the crate pkg_config to add include search path and link option? Thanks!