pull/38/merge
Zhang Cheng 7 years ago committed by GitHub
commit 2f30d8f075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

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

@ -28,10 +28,7 @@ impl Bsonc {
try!(bson::encode_document(&mut buffer, document));
let inner = unsafe {
bindings::bson_new_from_data(
buffer[..].as_ptr(),
buffer.len() as u64
)
bindings::bson_new_from_data(buffer[..].as_ptr(), (buffer.len() as u32).into())
};
// Inner will be null if there was an error converting the data.

Loading…
Cancel
Save