Compare commits

..

No commits in common. 'main' and 'static' have entirely different histories.
main ... static

@ -1,31 +1,3 @@
# 0.14.2
* Disable zstd if package is not found
# 0.14.1
* Disable snappy if package is not found
# 0.14.0
* Bump mongoc to 1.22.0
# 0.13.6
* Memory leak fix in Bscon::new by (by austinjones)
# 0.13.5
* Hard version lock on sys dependency
# 0.13.4
* Tweak linking options, use snappy if available
# 0.13.3
* Upgrade libmongoc to 1.17.4
* Another static linking fix
# 0.13.2
* Fix probe of libbson so static linking actually works
# 0.13.1
* Statically link libmongoc
# 0.13.0 # 0.13.0
* Bump bson dependency to 1.2 * Bump bson dependency to 1.2
* Upgrade libmongoc to 1.17.4 * Upgrade libmongoc to 1.17.4

@ -1,6 +1,6 @@
[package] [package]
name = "mongo_driver" name = "mongo_driver"
version = "0.14.2" version = "0.13.0"
authors = ["Thijs Cadier <thijs@appsignal.com>"] authors = ["Thijs Cadier <thijs@appsignal.com>"]
description = "Mongo Rust driver built on top of the Mongo C driver" description = "Mongo Rust driver built on top of the Mongo C driver"
readme = "README.md" readme = "README.md"
@ -12,6 +12,7 @@ license = "MIT/Apache-2.0"
edition = "2018" edition = "2018"
[badges] [badges]
travis-ci = { repository = "thijsc/mongo-rust-driver" }
is-it-maintained-issue-resolution = { repository = "thijsc/mongo-rust-driver" } is-it-maintained-issue-resolution = { repository = "thijsc/mongo-rust-driver" }
is-it-maintained-open-issues = { repository = "thijsc/mongo-rust-driver" } is-it-maintained-open-issues = { repository = "thijsc/mongo-rust-driver" }
@ -24,7 +25,7 @@ serde_derive = "1.0"
[dependencies.mongoc-sys] [dependencies.mongoc-sys]
path = "mongoc-sys" path = "mongoc-sys"
version = "=1.22.0-2" version = "1.17.4"
[dev-dependencies] [dev-dependencies]
chrono = "^0.4" chrono = "^0.4"

@ -1,5 +1,6 @@
# Mongo Rust Driver # Mongo Rust Driver
[![Build Status](https://travis-ci.org/thijsc/mongo-rust-driver.svg)](https://travis-ci.org/thijsc/mongo-rust-driver)
[![Crate](http://meritbadge.herokuapp.com/mongo_driver)](https://crates.io/crates/mongo_driver) [![Crate](http://meritbadge.herokuapp.com/mongo_driver)](https://crates.io/crates/mongo_driver)
Mongo Rust driver built on top of the [Mongo C driver](https://github.com/mongodb/mongo-c-driver). Mongo Rust driver built on top of the [Mongo C driver](https://github.com/mongodb/mongo-c-driver).

@ -1,6 +1,6 @@
[package] [package]
name = "mongoc-sys" name = "mongoc-sys"
version = "1.22.0-2" version = "1.17.4"
description = "Sys package with installer and bindings for mongoc" description = "Sys package with installer and bindings for mongoc"
authors = ["Thijs Cadier <thijs@appsignal.com>"] authors = ["Thijs Cadier <thijs@appsignal.com>"]
build = "build.rs" build = "build.rs"

@ -10,94 +10,85 @@ fn main() {
.next() .next()
.expect("Crate version is not valid"); .expect("Crate version is not valid");
let out_dir_var = env::var("OUT_DIR").expect("No out dir"); pkg_config::Config::new().probe("zlib").expect("Cannot find zlib");
let out_dir = Path::new(&out_dir_var);
let driver_src_path = out_dir.join(format!("mongo-c-driver-{}", mongoc_version));
let libmongoc_path = out_dir.join("usr/local/lib/libmongoc-static-1.0.a"); if pkg_config::Config::new()
if !libmongoc_path.exists() { .atleast_version(mongoc_version)
// Download and extract driver archive .statik(true)
let url = format!( .probe("libmongoc-1.0")
"https://github.com/mongodb/mongo-c-driver/releases/download/{}/mongo-c-driver-{}.tar.gz", .is_err()
mongoc_version, {
mongoc_version let out_dir_var = env::var("OUT_DIR").expect("No out dir");
); let out_dir = Path::new(&out_dir_var);
assert!( let driver_src_path = out_dir.join(format!("mongo-c-driver-{}", mongoc_version));
Command::new("curl").arg("-O") // Save to disk
.current_dir(out_dir)
.arg("-L") // Follow redirects
.arg(url)
.status()
.expect("Could not run curl")
.success()
);
let archive_name = format!("mongo-c-driver-{}.tar.gz", mongoc_version); let libmongoc_path = out_dir.join("usr/local/lib/libmongoc-static-1.0.a");
assert!( if !libmongoc_path.exists() {
Command::new("tar") // Download and extract driver archive
.current_dir(out_dir) let url = format!(
.arg("xzf") "https://github.com/mongodb/mongo-c-driver/releases/download/{}/mongo-c-driver-{}.tar.gz",
.arg(&archive_name) mongoc_version,
.status() mongoc_version
.expect("Could not run tar") );
.success() assert!(
); Command::new("curl").arg("-O") // Save to disk
.current_dir(out_dir)
.arg("-L") // Follow redirects
.arg(url)
.status()
.expect("Could not run curl")
.success()
);
// Set up cmake command let archive_name = format!("mongo-c-driver-{}.tar.gz", mongoc_version);
let mut cmake = Command::new("cmake"); assert!(
cmake.current_dir(&driver_src_path); Command::new("tar")
.current_dir(out_dir)
.arg("xzf")
.arg(&archive_name)
.status()
.expect("Could not run tar")
.success()
);
let pkg = pkg_config::Config::new(); // Set up cmake command
pkg.probe("zlib").expect("Cannot find zlib"); let mut cmake = Command::new("cmake");
#[cfg(target_os = "linux")] pkg.probe("icu-i18n").expect("Cannot find icu"); cmake.current_dir(&driver_src_path);
match pkg.probe("snappy") {
Ok(_) => {
cmake.arg("-DENABLE_SNAPPY=ON");
},
Err(e) => {
println!("Snappy not found: {}", e);
cmake.arg("-DENABLE_SNAPPY=OFF");
}
}
match pkg.probe("zstd") {
Ok(_) => {
cmake.arg("-DENABLE_ZSTD=ON");
},
Err(e) => {
println!("Zstd not found: {}", e);
cmake.arg("-DENABLE_ZSTD=OFF");
}
}
cmake.arg("-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF"); cmake.arg("-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF");
cmake.arg("-DENABLE_SSL=OPENSSL"); cmake.arg("-DENABLE_SSL=OPENSSL");
cmake.arg("-DENABLE_SASL=OFF"); cmake.arg("-DENABLE_SASL=OFF");
cmake.arg("-DENABLE_STATIC=ON"); cmake.arg("-DENABLE_STATIC=ON");
cmake.arg("-DENABLE_BSON=ON"); cmake.arg("-DENABLE_BSON=ON");
cmake.arg("-DENABLE_ENABLE_EXAMPLES=OFF"); cmake.arg("-DENABLE_ENABLE_EXAMPLES=OFF");
cmake.arg("-DENABLE_TESTS=OFF"); cmake.arg("-DENABLE_TESTS=OFF");
cmake.arg("-DENABLE_SHM_COUNTERS=OFF"); cmake.arg("-DENABLE_SHM_COUNTERS=OFF");
cmake.arg("-DWITH_PIC=ON"); cmake.arg("-DWITH_PIC=ON");
cmake.arg("-DWITH_SNAPPY=OFF");
cmake.arg("-DWITH_ZLIB=ON");
cmake.arg("-DENABLE_EXTRA_ALIGNMENT=OFF");
// Run in current dir // Run in current dir
cmake.arg("."); cmake.arg(".");
// Run cmake command // Run cmake command
assert!(cmake.status().expect("Could not run cmake").success()); assert!(cmake.status().expect("Could not run cmake").success());
// Set up make install command // Set up make install command
let mut make = Command::new("make"); let mut make = Command::new("make");
make.current_dir(&driver_src_path); make.current_dir(&driver_src_path);
make.arg(format!("DESTDIR={}", out_dir.to_string_lossy())); make.arg(format!("DESTDIR={}", out_dir.to_string_lossy()));
make.arg("install"); make.arg("install");
// Run make command // Run make command
assert!(make.status().expect("Could not run make install").success()); assert!(make.status().expect("Could not run make install").success());
} }
// Output to Cargo // Output to Cargo
println!("cargo:rustc-link-search=native={}/usr/local/lib", &out_dir.to_string_lossy()); println!("cargo:rustc-link-search=native={}/usr/local/lib", &out_dir.to_string_lossy());
println!("cargo:rustc-link-lib=static=bson-static-1.0"); println!("cargo:rustc-link-lib=static=bson-static-1.0");
println!("cargo:rustc-link-lib=static=mongoc-static-1.0"); println!("cargo:rustc-link-lib=static=mongoc-static-1.0");
println!("cargo:rustc-link-lib=resolv"); println!("cargo:rustc-link-lib=resolv");
#[cfg(target_os = "linux")] println!("cargo:rustc-link-lib=icuuc");
}
} }

@ -16,12 +16,7 @@ pub struct Bsonc {
impl Bsonc { impl Bsonc {
pub fn new() -> Bsonc { pub fn new() -> Bsonc {
let inner: *const bindings::bson_t = unsafe { bindings::bson_new() }; Bsonc::from_ptr(unsafe { bindings::bson_new() })
assert!(!inner.is_null());
Bsonc {
inner: inner as *mut bindings::bson_t,
destroy_inner_on_drop: true,
}
} }
/// Create a bsonc from a raw pointer. Does not run cleanup /// Create a bsonc from a raw pointer. Does not run cleanup
@ -116,13 +111,6 @@ impl Drop for Bsonc {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#[test]
fn test_bsonc_new() {
for _ in 0..100 {
let _ = super::Bsonc::new();
}
}
#[test] #[test]
fn test_bsonc_from_and_as_document() { fn test_bsonc_from_and_as_document() {
let document = doc! { "key": "value" }; let document = doc! { "key": "value" };

@ -45,7 +45,8 @@ pub struct Database<'a> {
} }
impl<'a> Database<'a> { impl<'a> Database<'a> {
pub(crate) fn new( #[doc(ignore)]
pub fn new(
created_by: CreatedBy<'a>, created_by: CreatedBy<'a>,
inner: *mut bindings::mongoc_database_t inner: *mut bindings::mongoc_database_t
) -> Database<'a> { ) -> Database<'a> {

Loading…
Cancel
Save