Add libvlc-sys crate

2-bindgen
T. Okubo 2019-11-21 20:00:26 +09:00
parent 97898ed074
commit 0417f9e2e8
5 changed files with 46 additions and 0 deletions

1
.gitignore vendored
View File

@ -9,4 +9,5 @@
# Generated by Cargo
/target/
/libvlc-sys/target
Cargo.lock

View File

@ -0,0 +1,14 @@
[package]
name = "libvlc-sys"
version = "0.1.0"
authors = ["T. Okubo <t.okubo.rx78+devel@gmail.com>"]
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"

View File

@ -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!");
}

View File

@ -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"));

View File

@ -0,0 +1 @@
#include <vlc/vlc.h>