Support building on Windows
The current build.rs requires pkg_config to be present. On Windows, there isn't normally pkg_config unless running inside of an environment like msys. My project doesn't run in msys, so I modified build.rs to just emit rustc-link-lib on Windows, and then handled setting the link search paths as appropriate from my project's build scripts.
If possible, I'd like to upstream the changes to libslirp-sys's build script (merge requests don't appear to be open, or I would've filed one directly). The diff looks like this:
--- a/build.rs
+++ b/build.rs
@@ -1,5 +1,12 @@
extern crate pkg_config;
fn main() {
- pkg_config::find_library("slirp").unwrap();
+ #[cfg(target_os = "windows")]
+ {
+ println!("cargo:rustc-link-lib=libslirp");
+ }
+ #[cfg(not(target_os = "windows"))]
+ {
+ pkg_config::find_library("slirp").unwrap();
+ }
}
Does that seem like a reasonable approach?