diff options
author | Vincent Breitmoser <look@my.amazin.horse> | 2018-12-05 21:45:11 +0100 |
---|---|---|
committer | Vincent Breitmoser <look@my.amazin.horse> | 2018-12-05 21:53:38 +0100 |
commit | b921aee04c65e607409dd435ca77d1c77303dbfc (patch) | |
tree | bd3e34d9dd0c67431d77d6569878f12f13f2f272 |
version 0.1
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | Cargo.toml | 15 | ||||
-rw-r--r-- | bindgen-wrapper.h | 3 | ||||
-rw-r--r-- | build.rs | 49 | ||||
-rw-r--r-- | src/lib.rs | 8 |
5 files changed, 81 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..626bd18 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/target +**/*.rs.bk + +/target +**/*.rs.bk +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..434b9e7 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "libical-sys" +version = "0.1.0" +authors = ["Vincent Breitmoser <look@my.amazin.horse>"] +description = "Low-level Rust bindings for the libical iCalendar library" +repository = "https://github.com/Valodim/libical-sys" +keywords = ["ical","icalendar", "ics", "libical"] +categories = ["external-ffi-bindings"] +license = "LGPL-3.0" +readme = "README.md" + + +[build-dependencies] +bindgen = "0.43" +pkg-config = "0.3" diff --git a/bindgen-wrapper.h b/bindgen-wrapper.h new file mode 100644 index 0000000..4b48552 --- /dev/null +++ b/bindgen-wrapper.h @@ -0,0 +1,3 @@ +#include <stddef.h> + +#include <libical/ical.h> diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..5372e3a --- /dev/null +++ b/build.rs @@ -0,0 +1,49 @@ +extern crate bindgen; +extern crate pkg_config; + +use std::env; +use std::path::PathBuf; + +fn print_library(lib: &pkg_config::Library) { + for p in &lib.include_paths { + println!("cargo:include={}", p.display()); + } + + for p in &lib.frameworks { + println!("cargo:rustc-link-lib=framework={}", p); + } + + for p in &lib.framework_paths { + println!("cargo:rustc-link-search=framework={}", p.display()); + } + + for p in &lib.libs { + println!("cargo:rustc-link-lib=dylib={}", p); + } + + for p in &lib.link_paths { + println!("cargo:rustc-link-search=native={}", p.display()); + } +} + +fn main() { + let libical = pkg_config::Config::new().atleast_version("3.0.0").probe("libical").unwrap(); + + print_library(&libical); + + let mut builder = bindgen::Builder::default() + .header("bindgen-wrapper.h"); + + for p in libical.include_paths { + builder = builder.clang_arg(format!("-I{}", p.display())); + } + + builder = builder.whitelist_type("ical.+") + .whitelist_var("ical.+") + .whitelist_function("ical.+"); + + let bindings = builder.generate().unwrap(); + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("bindings.rs"); + + bindings.write_to_file(out_path).expect("Couldn't write bindings!"); +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..f0833fb --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,8 @@ +// #![allow(bad_style)] +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + + +include!(concat!(env!("OUT_DIR"), "/bindings.rs")); + |