Remove bindgen buildtime generation

without.crypto
Dan Burkert 10 years ago
parent 2c0c641a82
commit 5b8204bab0
  1. 3
      lmdb-sys/Cargo.toml
  2. 33
      lmdb-sys/build.rs
  3. 2
      lmdb-sys/mdb
  4. 120
      lmdb-sys/src/ffi.rs
  5. 4
      lmdb-sys/src/lib.rs

@ -12,9 +12,6 @@ build = "build.rs"
name = "lmdb-sys"
[build-dependencies.rust-bindgen]
git = "https://github.com/crabtw/rust-bindgen.git"
[build-dependencies]
pkg-config = "*"
gcc = "*"

@ -1,33 +1,30 @@
#![feature(io, os, path)]
#![feature(env, path)]
extern crate "pkg-config" as pkg_config;
extern crate bindgen;
extern crate gcc;
use bindgen::{Bindings, BindgenOptions, LinkType};
use std::default::Default;
use std::old_io::fs;
use std::os;
use std::env;
use std::path::PathBuf;
fn main() {
let mdb = Path::new(os::getenv("CARGO_MANIFEST_DIR").unwrap())
.join_many(&["mdb", "libraries", "liblmdb"]);
let mut lmdb: PathBuf = PathBuf::new(&env::var("CARGO_MANIFEST_DIR").unwrap());
lmdb.push("mdb");
lmdb.push("libraries");
lmdb.push("liblmdb");
let mut mdb: PathBuf = lmdb.clone();
let mut midl: PathBuf = lmdb.clone();
mdb.push("mdb.c");
midl.push("midl.c");
if !pkg_config::find_library("liblmdb").is_ok() {
gcc::compile_library("liblmdb.a",
&Default::default(),
&[mdb.join("mdb.c").as_str().unwrap(),
mdb.join("midl.c").as_str().unwrap()]);
&[(*mdb).to_str().unwrap(),
(*midl).to_str().unwrap()]);
}
let mut bindgen_opts: BindgenOptions = Default::default();
bindgen_opts.clang_args.push(mdb.join("lmdb.h").as_str().unwrap().to_string());
bindgen_opts.links.push(("lmdb".to_string(), LinkType::Default));
bindgen_opts.builtins = true;
let bindings: Bindings = Bindings::generate(&bindgen_opts, None, None).unwrap();
let mut dst = fs::File::create(&Path::new(os::getenv("OUT_DIR").unwrap())
.join("lmdb.rs")).unwrap();
bindings.write(&mut dst).unwrap()
}

@ -1 +1 @@
Subproject commit 462dc097451834477b597447af69c5acc93182b7
Subproject commit 3368d1f5e243225cba4d730fba19ff600798ebe3

@ -0,0 +1,120 @@
/* automatically generated by rust-bindgen and modified by hand */
pub enum MDB_env { }
pub enum MDB_txn { }
pub type MDB_dbi = ::libc::c_uint;
pub enum MDB_cursor { }
#[repr(C)]
#[derive(Copy)]
pub struct MDB_val {
pub mv_size: ::libc::size_t,
pub mv_data: *mut ::libc::c_void,
}
pub type MDB_cmp_func = extern "C" fn(a: *const MDB_val, b: *const MDB_val) -> ::libc::c_int;
pub type MDB_rel_func = extern "C" fn (item: *mut MDB_val, oldptr: *mut ::libc::c_void, newptr: *mut ::libc::c_void, relctx: *mut ::libc::c_void) -> ();
pub const MDB_FIRST: ::libc::c_uint = 0;
pub const MDB_FIRST_DUP: ::libc::c_uint = 1;
pub const MDB_GET_BOTH: ::libc::c_uint = 2;
pub const MDB_GET_BOTH_RANGE: ::libc::c_uint = 3;
pub const MDB_GET_CURRENT: ::libc::c_uint = 4;
pub const MDB_GET_MULTIPLE: ::libc::c_uint = 5;
pub const MDB_LAST: ::libc::c_uint = 6;
pub const MDB_LAST_DUP: ::libc::c_uint = 7;
pub const MDB_NEXT: ::libc::c_uint = 8;
pub const MDB_NEXT_DUP: ::libc::c_uint = 9;
pub const MDB_NEXT_MULTIPLE: ::libc::c_uint = 10;
pub const MDB_NEXT_NODUP: ::libc::c_uint = 11;
pub const MDB_PREV: ::libc::c_uint = 12;
pub const MDB_PREV_DUP: ::libc::c_uint = 13;
pub const MDB_PREV_NODUP: ::libc::c_uint = 14;
pub const MDB_SET: ::libc::c_uint = 15;
pub const MDB_SET_KEY: ::libc::c_uint = 16;
pub const MDB_SET_RANGE: ::libc::c_uint = 17;
pub type MDB_cursor_op = ::libc::c_uint;
#[repr(C)]
#[derive(Copy)]
pub struct MDB_stat {
pub ms_psize: ::libc::c_uint,
pub ms_depth: ::libc::c_uint,
pub ms_branch_pages: ::libc::size_t,
pub ms_leaf_pages: ::libc::size_t,
pub ms_overflow_pages: ::libc::size_t,
pub ms_entries: ::libc::size_t,
}
#[repr(C)]
#[derive(Copy)]
pub struct MDB_envinfo {
pub me_mapaddr: *mut ::libc::c_void,
pub me_mapsize: ::libc::size_t,
pub me_last_pgno: ::libc::size_t,
pub me_last_txnid: ::libc::size_t,
pub me_maxreaders: ::libc::c_uint,
pub me_numreaders: ::libc::c_uint,
}
pub type MDB_assert_func = extern "C" fn(env: *mut MDB_env, msg: *const ::libc::c_char) -> ();
pub type MDB_msg_func = extern "C" fn(msg: *const ::libc::c_char, ctx: *mut ::libc::c_void) -> ::libc::c_int;
extern "C" {
pub fn mdb_version(major: *mut ::libc::c_int, minor: *mut ::libc::c_int, patch: *mut ::libc::c_int) -> *mut ::libc::c_char;
pub fn mdb_strerror(err: ::libc::c_int) -> *mut ::libc::c_char;
pub fn mdb_env_create(env: *mut *mut MDB_env) -> ::libc::c_int;
pub fn mdb_env_open(env: *mut MDB_env, path: *const ::libc::c_char, flags: ::libc::c_uint, mode: ::libc::mode_t) -> ::libc::c_int;
pub fn mdb_env_copy(env: *mut MDB_env, path: *const ::libc::c_char) -> ::libc::c_int;
pub fn mdb_env_copyfd(env: *mut MDB_env, fd: ::libc::c_int) -> ::libc::c_int;
pub fn mdb_env_copy2(env: *mut MDB_env, path: *const ::libc::c_char, flags: ::libc::c_uint) -> ::libc::c_int;
pub fn mdb_env_copyfd2(env: *mut MDB_env, fd: ::libc::c_int, flags: ::libc::c_uint) -> ::libc::c_int;
pub fn mdb_env_stat(env: *mut MDB_env, stat: *mut MDB_stat) -> ::libc::c_int;
pub fn mdb_env_info(env: *mut MDB_env, stat: *mut MDB_envinfo) -> ::libc::c_int;
pub fn mdb_env_sync(env: *mut MDB_env, force: ::libc::c_int) -> ::libc::c_int;
pub fn mdb_env_close(env: *mut MDB_env) -> ();
pub fn mdb_env_set_flags(env: *mut MDB_env, flags: ::libc::c_uint, onoff: ::libc::c_int) -> ::libc::c_int;
pub fn mdb_env_get_flags(env: *mut MDB_env, flags: *mut ::libc::c_uint) -> ::libc::c_int;
pub fn mdb_env_get_path(env: *mut MDB_env, path: *mut *const ::libc::c_char) -> ::libc::c_int;
pub fn mdb_env_get_fd(env: *mut MDB_env, fd: *mut ::libc::c_int) -> ::libc::c_int;
pub fn mdb_env_set_mapsize(env: *mut MDB_env, size: ::libc::size_t) -> ::libc::c_int;
pub fn mdb_env_set_maxreaders(env: *mut MDB_env, readers: ::libc::c_uint) -> ::libc::c_int;
pub fn mdb_env_get_maxreaders(env: *mut MDB_env, readers: *mut ::libc::c_uint) -> ::libc::c_int;
pub fn mdb_env_set_maxdbs(env: *mut MDB_env, dbs: MDB_dbi) -> ::libc::c_int;
pub fn mdb_env_get_maxkeysize(env: *mut MDB_env) -> ::libc::c_int;
pub fn mdb_env_set_userctx(env: *mut MDB_env, ctx: *mut ::libc::c_void) -> ::libc::c_int;
pub fn mdb_env_get_userctx(env: *mut MDB_env) -> *mut ::libc::c_void;
pub fn mdb_env_set_assert(env: *mut MDB_env, func: *mut ::std::option::Option<extern "C" fn() -> ()>) -> ::libc::c_int;
pub fn mdb_txn_begin(env: *mut MDB_env, parent: *mut MDB_txn, flags: ::libc::c_uint, txn: *mut *mut MDB_txn) -> ::libc::c_int;
pub fn mdb_txn_env(txn: *mut MDB_txn) -> *mut MDB_env;
pub fn mdb_txn_id(txn: *mut MDB_txn) -> ::libc::size_t;
pub fn mdb_txn_commit(txn: *mut MDB_txn) -> ::libc::c_int;
pub fn mdb_txn_abort(txn: *mut MDB_txn) -> ();
pub fn mdb_txn_reset(txn: *mut MDB_txn) -> ();
pub fn mdb_txn_renew(txn: *mut MDB_txn) -> ::libc::c_int;
pub fn mdb_dbi_open(txn: *mut MDB_txn, name: *const ::libc::c_char, flags: ::libc::c_uint, dbi: *mut MDB_dbi) -> ::libc::c_int;
pub fn mdb_stat(txn: *mut MDB_txn, dbi: MDB_dbi, stat: *mut MDB_stat) -> ::libc::c_int;
pub fn mdb_dbi_flags(txn: *mut MDB_txn, dbi: MDB_dbi, flags: *mut ::libc::c_uint) -> ::libc::c_int;
pub fn mdb_dbi_close(env: *mut MDB_env, dbi: MDB_dbi) -> ();
pub fn mdb_drop(txn: *mut MDB_txn, dbi: MDB_dbi, del: ::libc::c_int) -> ::libc::c_int;
pub fn mdb_set_compare(txn: *mut MDB_txn, dbi: MDB_dbi, cmp: *mut MDB_cmp_func) -> ::libc::c_int;
pub fn mdb_set_dupsort(txn: *mut MDB_txn, dbi: MDB_dbi, cmp: *mut MDB_cmp_func) -> ::libc::c_int;
pub fn mdb_set_relfunc(txn: *mut MDB_txn, dbi: MDB_dbi, rel: *mut MDB_rel_func) -> ::libc::c_int;
pub fn mdb_set_relctx(txn: *mut MDB_txn, dbi: MDB_dbi, ctx: *mut ::libc::c_void) -> ::libc::c_int;
pub fn mdb_get(txn: *mut MDB_txn, dbi: MDB_dbi, key: *mut MDB_val, data: *mut MDB_val) -> ::libc::c_int;
pub fn mdb_put(txn: *mut MDB_txn, dbi: MDB_dbi, key: *mut MDB_val, data: *mut MDB_val, flags: ::libc::c_uint) -> ::libc::c_int;
pub fn mdb_del(txn: *mut MDB_txn, dbi: MDB_dbi, key: *mut MDB_val, data: *mut MDB_val) -> ::libc::c_int;
pub fn mdb_cursor_open(txn: *mut MDB_txn, dbi: MDB_dbi, cursor: *mut *mut MDB_cursor) -> ::libc::c_int;
pub fn mdb_cursor_close(cursor: *mut MDB_cursor) -> ();
pub fn mdb_cursor_renew(txn: *mut MDB_txn, cursor: *mut MDB_cursor) -> ::libc::c_int;
pub fn mdb_cursor_txn(cursor: *mut MDB_cursor) -> *mut MDB_txn;
pub fn mdb_cursor_dbi(cursor: *mut MDB_cursor) -> MDB_dbi;
pub fn mdb_cursor_get(cursor: *mut MDB_cursor, key: *mut MDB_val, data: *mut MDB_val, op: MDB_cursor_op) -> ::libc::c_int;
pub fn mdb_cursor_put(cursor: *mut MDB_cursor, key: *mut MDB_val, data: *mut MDB_val, flags: ::libc::c_uint) -> ::libc::c_int;
pub fn mdb_cursor_del(cursor: *mut MDB_cursor, flags: ::libc::c_uint) -> ::libc::c_int;
pub fn mdb_cursor_count(cursor: *mut MDB_cursor, countp: *mut ::libc::size_t) -> ::libc::c_int;
pub fn mdb_cmp(txn: *mut MDB_txn, dbi: MDB_dbi, a: *const MDB_val, b: *const MDB_val) -> ::libc::c_int;
pub fn mdb_dcmp(txn: *mut MDB_txn, dbi: MDB_dbi, a: *const MDB_val, b: *const MDB_val) -> ::libc::c_int;
pub fn mdb_reader_list(env: *mut MDB_env, func: *mut MDB_msg_func, ctx: *mut ::libc::c_void) -> ::libc::c_int;
pub fn mdb_reader_check(env: *mut MDB_env, dead: *mut ::libc::c_int) -> ::libc::c_int;
}

@ -14,7 +14,7 @@ extern crate libc;
extern crate bitflags;
pub use constants::*;
pub use ffi::*;
mod ffi;
mod constants;
include!(concat!(env!("OUT_DIR"), "/lmdb.rs"));

Loading…
Cancel
Save