Skip to content
Permalink
Browse files

Comment out bindgen steps in build.rs files to speed up build

  • Loading branch information...
buybackoff committed Jul 14, 2019
1 parent 1ef2958 commit 5bddc1fd467a844999bcb0826ef0952ceea46291
Showing with 51 additions and 54 deletions.
  1. +18 −19 src/rust/blosc-sys/build.rs
  2. +17 −18 src/rust/lmdb-sys/build.rs
  3. +16 −17 src/rust/sqlite-sys/build.rs
@@ -2,26 +2,8 @@ extern crate cmake;
extern crate bindgen;

use std::env;
use std::path::PathBuf;

fn main() {
let bindings = bindgen::Builder::default()
.header("wrapper.h")
.use_core()
.ctypes_prefix("libc")
.whitelist_function(".*compress.*")
.whitelist_function(".*shuffle.*")
.whitelist_function(".*threads.*")
.whitelist_function(".*version.*")
.generate()
.expect("Unable to generate bindings");

// Write the bindings to the $OUT_DIR/bindings.rs file.
let out_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
bindings
.write_to_file(out_path.join("src/bindings.rs"))
.expect("Couldn't write bindings!");

// TODO deduplicate code, only MinGW line for Windows, check if on MSVC
if cfg!(windows) {
if cfg!(target_env = "gnu") {
@@ -58,7 +40,7 @@ fn main() {
.define("PREFER_EXTERNAL_SNAPPY", "OFF")
.define("PREFER_EXTERNAL_ZLIB", "OFF")
.define("PREFER_EXTERNAL_ZSTD", "OFF")
// .define("CMAKE_BUILD_TYPE", "Release") - cmake-rs does the right this depending on opt-level and debug/release
// .define("CMAKE_BUILD_TYPE", "Release") - cmake-rs does this right depending on opt-level and debug/release
.static_crt(true)
.build();
println!("cargo:rustc-link-search=native={}/lib", dst.display());
@@ -83,4 +65,21 @@ fn main() {
println!("cargo:rustc-link-search=native={}/lib", dst.display());
println!("cargo:rustc-link-lib=static=blosc");
}

// let bindings = bindgen::Builder::default()
// .header("wrapper.h")
// .use_core()
// .ctypes_prefix("libc")
// .whitelist_function(".*compress.*")
// .whitelist_function(".*shuffle.*")
// .whitelist_function(".*threads.*")
// .whitelist_function(".*version.*")
// .generate()
// .expect("Unable to generate bindings");

// // Write the bindings to the $OUT_DIR/bindings.rs file.
// let out_path = std::path::PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
// bindings
// .write_to_file(out_path.join("src/bindings.rs"))
// .expect("Couldn't write bindings!");
}
@@ -1,10 +1,9 @@
extern crate cc;

use std::env;
use std::path::PathBuf;

fn main() {
let mut lmdb: PathBuf = PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap());
let mut lmdb = std::path::PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap());
lmdb.push("lmdb");
lmdb.push("libraries");
lmdb.push("liblmdb");
@@ -17,23 +16,23 @@ fn main() {
.static_crt(true)
.compile("liblmdb.a");

let bindings = bindgen::Builder::default()
.header("wrapper.h")
.generate_comments(true)
.use_core()
.ctypes_prefix("libc")
.whitelist_function("mdb_.*") // it adds recursively all used types so the next line in this case changes nothing for this particular case
.whitelist_type("mdb_.*")
.prepend_enum_name(false)
.constified_enum_module("MDB_cursor_op") // allows access to enum values as MDB_cursor_op.MDB_NEXT
.generate()
.expect("Unable to generate bindings");
// let bindings = bindgen::Builder::default()
// .header("wrapper.h")
// .generate_comments(true)
// .use_core()
// .ctypes_prefix("libc")
// .whitelist_function("mdb_.*") // it adds recursively all used types so the next line in this case changes nothing for this particular case
// .whitelist_type("mdb_.*")
// .prepend_enum_name(false)
// .constified_enum_module("MDB_cursor_op") // allows access to enum values as MDB_cursor_op.MDB_NEXT
// .generate()
// .expect("Unable to generate bindings");

// Write the bindings to src folder to make rls autocomplete work.
let out_path = PathBuf::from("src");
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
// // Write the bindings to src folder to make rls autocomplete work.
// let out_path = std::path::PathBuf::from("src");
// bindings
// .write_to_file(out_path.join("bindings.rs"))
// .expect("Couldn't write bindings!");

// Tell cargo to tell rustc to link the lmdb library.
println!("cargo:rustc-link-lib=static=lmdb");
@@ -1,10 +1,9 @@
extern crate cc;

use std::env;
use std::path::PathBuf;

fn main() {
let mut sqlite: PathBuf = PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap());
let mut sqlite = std::path::PathBuf::from(&env::var("CARGO_MANIFEST_DIR").unwrap());
sqlite.push("sqlite");

cc::Build::new()
@@ -27,22 +26,22 @@ fn main() {
.static_crt(true)
.compile("libsqlite3.a");

let bindings = bindgen::Builder::default()
.header("wrapper.h")
.generate_comments(true)
.use_core()
.ctypes_prefix("libc")
.whitelist_function("sqlite3_.*")
.whitelist_type("sqlite3_.*")
.prepend_enum_name(false)
.generate()
.expect("Unable to generate bindings");
// let bindings = bindgen::Builder::default()
// .header("wrapper.h")
// .generate_comments(true)
// .use_core()
// .ctypes_prefix("libc")
// .whitelist_function("sqlite3_.*")
// .whitelist_type("sqlite3_.*")
// .prepend_enum_name(false)
// .generate()
// .expect("Unable to generate bindings");

// Write the bindings to src folder to make rls autocomplete work.
let out_path = PathBuf::from("src");
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
// // Write the bindings to src folder to make rls autocomplete work.
// let out_path = std::path::PathBuf::from("src");
// bindings
// .write_to_file(out_path.join("bindings.rs"))
// .expect("Couldn't write bindings!");

// Tell cargo to tell rustc to link the lmdb library.
println!("cargo:rustc-link-lib=static=sqlite3");

0 comments on commit 5bddc1f

Please sign in to comment.
You can’t perform that action at this time.