use vcpkg to probe ligmongoc-1.0 under windows

pull/38/head
Matrix 7 years ago
parent f8c1665e01
commit a738a9622e

@ -16,3 +16,6 @@ openssl-sys = "0.9"
[build-dependencies] [build-dependencies]
pkg-config = "0.3" pkg-config = "0.3"
[target.'cfg(target_env = "msvc")'.build-dependencies]
vcpkg = "0.2"

@ -1,9 +1,34 @@
extern crate pkg_config; extern crate pkg_config;
#[cfg(target_env = "msvc")]
extern crate vcpkg;
use std::env; use std::env;
use std::path::Path; use std::path::Path;
use std::process::Command; use std::process::Command;
#[cfg(target_env = "msvc")]
fn probe_libmongoc_pkg_config(_: &str) -> bool {
false
}
#[cfg(target_env = "msvc")]
fn probe_libmongoc_vcpkg() -> bool {
vcpkg::probe_package("libmongoc-1.0").is_ok()
}
#[cfg(not(target_env = "msvc"))]
fn probe_libmongoc_pkg_config(version: &str) -> bool {
pkg_config::Config::new()
.atleast_version(version)
.statik(true)
.probe("libmongoc-1.0")
.is_ok()
}
#[cfg(not(target_env = "msvc"))]
fn probe_libmongoc_vcpkg() -> bool {
false
}
fn main() { fn main() {
let mongoc_version = env!("CARGO_PKG_VERSION") let mongoc_version = env!("CARGO_PKG_VERSION")
@ -11,12 +36,7 @@ fn main() {
.next() .next()
.expect("Crate version is not valid"); .expect("Crate version is not valid");
if pkg_config::Config::new() if !probe_libmongoc_pkg_config(mongoc_version) && !probe_libmongoc_vcpkg() {
.atleast_version(mongoc_version)
.statik(true)
.probe("libmongoc-1.0")
.is_err()
{
let out_dir_var = env::var("OUT_DIR").expect("No out dir"); let out_dir_var = env::var("OUT_DIR").expect("No out dir");
let out_dir = format!("{}/{}", out_dir_var, mongoc_version); let out_dir = format!("{}/{}", out_dir_var, mongoc_version);
let driver_src_path = format!("mongo-c-driver-{}", mongoc_version); let driver_src_path = format!("mongo-c-driver-{}", mongoc_version);

Loading…
Cancel
Save