From 99bdb566ac2fde9c2670bb2d0adae3391a134431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Am=C3=A9d=C3=A9e=20d=27Aboville?= Date: Sun, 26 Jan 2020 18:20:07 -0500 Subject: [PATCH] Initial commit. --- .gitignore | 2 ++ Cargo.toml | 11 +++++++++++ LICENSE.md | 7 +++++++ README.md | 17 +++++++++++++++++ build.rs | 21 +++++++++++++++++++++ src/lib.rs | 13 +++++++++++++ wrapper.h | 1 + 7 files changed, 72 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 build.rs create mode 100644 src/lib.rs create mode 100644 wrapper.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96ef6c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..5328cc5 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "k4a-sys" +version = "0.1.0" +authors = ["Amédée d'Aboville "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +description = "The Azure K4A API bindgen-ed to Rust." + +[build-dependencies] +bindgen = "0.52.0" diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..810e7b9 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,7 @@ +Copyright 2020 Amédée d'Aboville. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..14c4858 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +k4a-sys +------- +A Bingden Wrapper for the Azure Kinect Sensor SDK. + +Linux only at this instant but I'll add Windows support soon. + +Dependencies +------- +You need `libk4a` installed, for example by running + +``` +apt install k4a-dev +``` + +It might be possible to compile libk4a from source in the future, +but it looks time consuming at the moment. + diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..4d86798 --- /dev/null +++ b/build.rs @@ -0,0 +1,21 @@ +extern crate bindgen; + +use std::env; +use std::path::PathBuf; + +fn main() { + println!("cargo:rustc-link-lib=k4a"); + println!("cargo:rerun-if-changed=wrapper.h"); + + let bindings = bindgen::Builder::default() + .header("wrapper.h") + .parse_callbacks(Box::new(bindgen::CargoCallbacks)) + .generate() + .expect("Unable to generate bindings"); + + // Write the bindings to the $OUT_DIR/bindings.rs file. + 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/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..4a01ab7 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,13 @@ +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +include!(concat!(env!("OUT_DIR"), "/bindings.rs")); + +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +} diff --git a/wrapper.h b/wrapper.h new file mode 100644 index 0000000..f181122 --- /dev/null +++ b/wrapper.h @@ -0,0 +1 @@ +#include