From e3d89f01f646bb50271bf1929f3260f72464fb62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 24 Oct 2019 22:38:36 +0200 Subject: [PATCH] olm: Add inital bindgen generated olm-sys bindings. --- nio-olm/nio-olm-sys/Cargo.toml | 14 ++++++++++++++ nio-olm/nio-olm-sys/build.rs | 21 +++++++++++++++++++++ nio-olm/nio-olm-sys/src/lib.rs | 5 +++++ nio-olm/nio-olm-sys/src/wrapper.h | 1 + 4 files changed, 41 insertions(+) create mode 100644 nio-olm/nio-olm-sys/Cargo.toml create mode 100644 nio-olm/nio-olm-sys/build.rs create mode 100644 nio-olm/nio-olm-sys/src/lib.rs create mode 100644 nio-olm/nio-olm-sys/src/wrapper.h diff --git a/nio-olm/nio-olm-sys/Cargo.toml b/nio-olm/nio-olm-sys/Cargo.toml new file mode 100644 index 00000000..558b8326 --- /dev/null +++ b/nio-olm/nio-olm-sys/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "nio-olm-sys" +version = "3.1.4-beta" +authors = ["Damir Jelić "] +description = "Low level bindings for the Olm C library" +license = "ISC" +edition = "2018" +build = "build.rs" + +[build-dependencies] +bindgen = "0.51.1" + +[dependencies] +libc = "0.2.65" diff --git a/nio-olm/nio-olm-sys/build.rs b/nio-olm/nio-olm-sys/build.rs new file mode 100644 index 00000000..063966f6 --- /dev/null +++ b/nio-olm/nio-olm-sys/build.rs @@ -0,0 +1,21 @@ +use bindgen::Bindings; +use std::env; +use std::path::PathBuf; + +fn build(file: &str) -> Result { + println!("cargo:rustc-link-lib=olm"); + + bindgen::Builder::default() + .rustfmt_bindings(true) + .header(file) + .generate() +} + +fn main() { + let bindings = build("src/wrapper.h").expect("Unable to build bindings"); + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + + bindings + .write_to_file(out_path.join("bindings.rs")) + .expect("Couldn't write bindings!"); +} diff --git a/nio-olm/nio-olm-sys/src/lib.rs b/nio-olm/nio-olm-sys/src/lib.rs new file mode 100644 index 00000000..a38a13a8 --- /dev/null +++ b/nio-olm/nio-olm-sys/src/lib.rs @@ -0,0 +1,5 @@ +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +include!(concat!(env!("OUT_DIR"), "/bindings.rs")); diff --git a/nio-olm/nio-olm-sys/src/wrapper.h b/nio-olm/nio-olm-sys/src/wrapper.h new file mode 100644 index 00000000..ea193d26 --- /dev/null +++ b/nio-olm/nio-olm-sys/src/wrapper.h @@ -0,0 +1 @@ +#include