trying to build for windows

pull/47/head
inv2004 6 years ago
parent 1539d8f3b8
commit c23b3798e8

@ -16,3 +16,4 @@ openssl-sys = "0.9"
[build-dependencies]
pkg-config = "0.3"
vcpkg = "0.2.6"

@ -1,16 +1,14 @@
extern crate pkg_config;
#[cfg(target_env = "msvc")]
extern crate vcpkg;
use std::env;
use std::path::Path;
use std::process::Command;
fn main() {
let mongoc_version = env!("CARGO_PKG_VERSION")
.split('-')
.next()
.expect("Crate version is not valid");
#[cfg(not(target_env = "msvc"))]
fn main_linux(mongoc_version: &str) {
if pkg_config::Config::new()
.atleast_version(mongoc_version)
.statik(true)
@ -98,3 +96,35 @@ fn main() {
println!("cargo:rustc-link-lib=static=mongoc-1.0");
}
}
#[cfg(target_env = "msvc")]
fn main_win(mongoc_version: &str) {
use vcpkg;
if vcpkg::Config::new()
.emit_includes(true)
.probe("mongo-c-driver")
.is_ok()
{
let out_dir_var = env::var("OUT_DIR").expect("No out dir");
let out_dir = format!("{}/{}", out_dir_var, mongoc_version);
// println!("found");
// Output to Cargo
println!("cargo:rustc-link-search=native={}/lib", &out_dir);
println!("cargo:rustc-link-lib=bson");
println!("cargo:rustc-link-lib=mongo-c-driver");
}
}
fn main() {
let mongoc_version = env!("CARGO_PKG_VERSION")
.split('-')
.next()
.expect("Crate version is not valid");
#[cfg(target_env = "msvc")]
main_win(mongoc_version);
#[cfg(not(target_env = "msvc"))]
main_linux(mongoc_version);
}

@ -30,7 +30,7 @@ impl Bsonc {
let inner = unsafe {
bindings::bson_new_from_data(
buffer[..].as_ptr(),
buffer.len() as u64
buffer.len() as u32
)
};

Loading…
Cancel
Save