Merge pull request #35 from Matrix-Zhang/master

mongosys use local libmongoc first, update bson dependency
pull/38/merge
Thijs Cadier 7 years ago committed by GitHub
commit b90a142d1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,7 +21,7 @@ name = "tests"
[dependencies] [dependencies]
libc = "^0.2" libc = "^0.2"
log = "^0.3" log = "^0.3"
bson = "^0.9" bson = "^0.10"
[dependencies.mongoc-sys] [dependencies.mongoc-sys]
path = "mongoc-sys" path = "mongoc-sys"

@ -13,3 +13,6 @@ exclude = ["mongo-c-driver-*"]
[dependencies] [dependencies]
libc = "0.2" libc = "0.2"
openssl-sys = "0.9" openssl-sys = "0.9"
[build-dependencies]
pkg-config = "0.3"

@ -1,3 +1,5 @@
extern crate pkg_config;
use std::env; use std::env;
use std::path::Path; use std::path::Path;
use std::process::Command; use std::process::Command;
@ -5,6 +7,12 @@ use std::process::Command;
static VERSION: &'static str = "1.8.0"; // Should be the same major version as in the manifest static VERSION: &'static str = "1.8.0"; // Should be the same major version as in the manifest
fn main() { fn main() {
if pkg_config::Config::new()
.atleast_version(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, VERSION); let out_dir = format!("{}/{}", out_dir_var, VERSION);
let driver_src_path = format!("mongo-c-driver-{}", VERSION); let driver_src_path = format!("mongo-c-driver-{}", VERSION);
@ -17,22 +25,24 @@ fn main() {
VERSION, VERSION,
VERSION VERSION
); );
assert!(Command::new("curl").arg("-O") // Save to disk assert!(
Command::new("curl").arg("-O") // Save to disk
.arg("-L") // Follow redirects .arg("-L") // Follow redirects
.arg(url) .arg(url)
.status() .status()
.expect("Could not run curl") .expect("Could not run curl")
.success()); .success()
let archive_name = format!(
"mongo-c-driver-{}.tar.gz",
VERSION
); );
assert!(Command::new("tar").arg("xzf")
let archive_name = format!("mongo-c-driver-{}.tar.gz", VERSION);
assert!(
Command::new("tar")
.arg("xzf")
.arg(&archive_name) .arg(&archive_name)
.status() .status()
.expect("Could not run tar") .expect("Could not run tar")
.success()); .success()
);
// Configure and install // Configure and install
let mut command = Command::new("sh"); let mut command = Command::new("sh");
@ -60,22 +70,27 @@ fn main() {
} }
assert!(command.status().expect("Could not run configure").success()); assert!(command.status().expect("Could not run configure").success());
assert!(Command::new("make"). assert!(
current_dir(&driver_src_path). Command::new("make")
env("CFLAGS", "-DMONGOC_TRACE"). .current_dir(&driver_src_path)
status(). .env("CFLAGS", "-DMONGOC_TRACE")
expect("Could not run make"). .status()
success()); .expect("Could not run make")
assert!(Command::new("make"). .success()
arg("install"). );
current_dir(&driver_src_path). assert!(
status(). Command::new("make")
expect("Could not run make install"). .arg("install")
success()); .current_dir(&driver_src_path)
.status()
.expect("Could not run make install")
.success()
);
} }
// Output to Cargo // Output to Cargo
println!("cargo:rustc-link-search=native={}/lib", &out_dir); println!("cargo:rustc-link-search=native={}/lib", &out_dir);
println!("cargo:rustc-link-lib=static=bson-1.0"); println!("cargo:rustc-link-lib=static=bson-1.0");
println!("cargo:rustc-link-lib=static=mongoc-1.0"); println!("cargo:rustc-link-lib=static=mongoc-1.0");
}
} }

Loading…
Cancel
Save