From 0417f9e2e83ec7d30f95464b9fc7d71666d7706c Mon Sep 17 00:00:00 2001 From: "T. Okubo" Date: Thu, 21 Nov 2019 20:00:26 +0900 Subject: [PATCH] Add libvlc-sys crate --- .gitignore | 1 + libvlc-sys/Cargo.toml | 14 ++++++++++++++ libvlc-sys/build.rs | 24 ++++++++++++++++++++++++ libvlc-sys/src/lib.rs | 6 ++++++ libvlc-sys/wrapper.h | 1 + 5 files changed, 46 insertions(+) create mode 100644 libvlc-sys/Cargo.toml create mode 100644 libvlc-sys/build.rs create mode 100644 libvlc-sys/src/lib.rs create mode 100644 libvlc-sys/wrapper.h diff --git a/.gitignore b/.gitignore index 94408df..2ad8632 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ # Generated by Cargo /target/ +/libvlc-sys/target Cargo.lock diff --git a/libvlc-sys/Cargo.toml b/libvlc-sys/Cargo.toml new file mode 100644 index 0000000..e855636 --- /dev/null +++ b/libvlc-sys/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "libvlc-sys" +version = "0.1.0" +authors = ["T. Okubo "] +edition = "2018" +build = "build.rs" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +libc = "0.2" + +[build-dependencies] +bindgen = "0.52" \ No newline at end of file diff --git a/libvlc-sys/build.rs b/libvlc-sys/build.rs new file mode 100644 index 0000000..e62ec93 --- /dev/null +++ b/libvlc-sys/build.rs @@ -0,0 +1,24 @@ +use bindgen; + +use std::env; +use std::path::PathBuf; + +fn main() { + println!("cargo:rustc-link-lib=libvlc"); + println!("cargo:rerun-if-changed=wrapper.h"); + + let bindings = bindgen::Builder::default() + .header("wrapper.h") + // For no_std + .use_core() + // Use libc + .ctypes_prefix("libc") + .parse_callbacks(Box::new(bindgen::CargoCallbacks)) + .generate() + .expect("Unable to generate 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/libvlc-sys/src/lib.rs b/libvlc-sys/src/lib.rs new file mode 100644 index 0000000..da4a48d --- /dev/null +++ b/libvlc-sys/src/lib.rs @@ -0,0 +1,6 @@ +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![no_std] + +include!(concat!(env!("OUT_DIR"), "/bindings.rs")); diff --git a/libvlc-sys/wrapper.h b/libvlc-sys/wrapper.h new file mode 100644 index 0000000..6fd7ccc --- /dev/null +++ b/libvlc-sys/wrapper.h @@ -0,0 +1 @@ +#include