Merge pull request #47 from inv2004/master

mongo-sys msvc support
pull/56/head
Thijs Cadier 6 years ago committed by GitHub
commit 95430f2997
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,29 @@
services:
- mongodb
environment:
RUST_BACKTRACE: 1
OPENSSL_DIR: C:\Tools\vcpkg\packages\openssl-windows_x64-windows
BSON_LIB: C:\Tools\vcpkg\packages\libbson_x64-windows\lib
MONGO_LIB: C:\Tools\vcpkg\packages\mongo-c-driver_x64-windows\lib
SKIP_SSL_CONNECTION_TESTS: true
matrix:
- TARGET: x86_64-pc-windows-msvc
install:
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
- rustup-init.exe -y --default-host %TARGET%
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin;C:\Tools\vcpkg\installed\x64-windows\bin
- rustc -vV
- cargo -vV
- cd C:\Tools\vcpkg
- git pull -q
- .\bootstrap-vcpkg.bat
- vcpkg install openssl:x64-windows
- vcpkg install mongo-c-driver:x64-windows
- cd %APPVEYOR_BUILD_FOLDER%
build: false
test_script:
- cargo build
- cargo test

@ -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;
#[cfg(not(target_env = "msvc"))]
fn lin(mongoc_version: &str) {
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");
if pkg_config::Config::new()
.atleast_version(mongoc_version)
.statik(true)
@ -98,3 +96,47 @@ fn main() {
println!("cargo:rustc-link-lib=static=mongoc-1.0");
}
}
#[cfg(target_env = "msvc")]
fn win(_mongoc_version: &str) {
use vcpkg;
let mongo_lib = "mongoc-1.0";
let bson_lib = "bson-1.0";
if vcpkg::Config::new()
.emit_includes(true)
.probe("mongo-c-driver")
.is_ok()
{
// Output to Cargo
println!("cargo:rustc-link-lib={}", bson_lib);
println!("cargo:rustc-link-lib={}", mongo_lib);
} else {
if let Ok(bson_dir_lib) = env::var("MONGO_LIB") {
if let Ok(mongo_dir_lib) = env::var("BSON_LIB") {
println!("cargo:rustc-link-search=native={}", bson_dir_lib);
println!("cargo:rustc-link-lib=dylib={}", bson_lib);
println!("cargo:rustc-link-search=native={}", mongo_dir_lib);
println!("cargo:rustc-link-lib=dylib={}", mongo_lib);
} else {
panic!("please define BSON_LIB to {}.lib, \n for example set BSON_LIB=C:\\vcpkg\\packages\\libbson_x64-windows\\lib", bson_lib);
}
} else {
panic!("please define MONGO_LIB to {}.lib, \n for example set MONGO_LIB=C:\\vcpkg\\packages\\mongo-c-driver_x64-windows\\lib", mongo_lib);
}
}
}
fn main() {
let mongoc_version = env!("CARGO_PKG_VERSION")
.split('-')
.next()
.expect("Crate version is not valid");
#[cfg(target_env = "msvc")]
win(mongoc_version);
#[cfg(not(target_env = "msvc"))]
lin(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 libc::c_ulong
)
};

@ -33,6 +33,7 @@ fn test_aggregate() {
assert_eq!(Ok(5), total.get_i32("total"));
}
#[cfg_attr(target_os = "windows", ignore)]
#[test]
fn test_command() {
let uri = Uri::new("mongodb://localhost:27017/").unwrap();

@ -88,6 +88,7 @@ fn test_tailing_cursor() {
assert_eq!(25, guard.join().expect("Thread failed"));
}
#[cfg_attr(target_os = "windows", ignore)]
#[test]
fn test_batch_cursor() {
let uri = Uri::new("mongodb://localhost:27017/").unwrap();

@ -1,5 +1,6 @@
use mongo_driver::client::{ClientPool,Uri};
#[cfg_attr(target_os = "windows", ignore)]
#[test]
fn test_command() {
let uri = Uri::new("mongodb://localhost:27017/").unwrap();

Loading…
Cancel
Save