build: Split in two separate crates

Keep the FFI bindings apart.
This commit is contained in:
Luca Barbato 2017-01-02 03:25:09 +00:00
parent 1b2e253374
commit d06bb4bbf4
10 changed files with 78 additions and 37 deletions

4
.gitignore vendored
View File

@ -6,6 +6,4 @@
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
target
Cargo.lock
src/ffi/cuda.rs
src/ffi/cuvid.rs
src/ffi/nvenc.rs

View File

@ -2,10 +2,15 @@
name = "nvidia-video-codec"
version = "0.1.0"
authors = ["Luca Barbato <lu_zero@gentoo.org>"]
build = "build.rs"
[build-dependencies.libbindgen]
git = "https://github.com/servo/rust-bindgen"
license = "MIT"
description = "NVIDIA Video Codec bindings"
repository = "https://github.com/rust-av/nvidia-video-codec-rs"
readme = "../README.md"
keywords = ["NVIDIA", "cuvid", "nvenc"]
[dependencies]
nvidia-video-codec-sys = { version = "0.1.0", path = "nvidia-video-codec-sys" }
[workspace]
members = ["nvidia-video-codec-sys"]

3
nvidia-video-codec-sys/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
src/cuda.rs
src/cuvid.rs
src/nvenc.rs

View File

@ -0,0 +1,14 @@
[package]
name = "nvidia-video-codec-sys"
version = "0.1.0"
authors = ["Luca Barbato <lu_zero@gentoo.org>"]
license = "MIT"
description = "FFI bindings to NVIDIA Video Codec"
repository = "https://github.com/rust-av/nvidia-video-codec-rs"
build = "build.rs"
[build-dependencies.libbindgen]
git = "https://github.com/servo/rust-bindgen"
[dependencies]

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016 Luca Barbato
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.

View File

@ -53,18 +53,18 @@ fn main() {
.header(cuda_include.join("cuda.h").to_string_lossy());
// Manually fix the comment so rustdoc won't try to pick them
format_write(cuda_builder, "src/ffi/cuda.rs");
format_write(cuda_builder, "src/cuda.rs");
let cuvid_builder = common_builder()
.clang_arg(format!("-I{}", nvc_include.to_string_lossy()))
.clang_arg(format!("-I{}", cuda_include.to_string_lossy()))
.header(nvc_include.join("nvcuvid.h").to_string_lossy());
format_write(cuvid_builder, "src/ffi/cuvid.rs");
format_write(cuvid_builder, "src/cuvid.rs");
let nvenc_builder = common_builder()
.clang_arg(format!("-I{}", nvc_include.to_string_lossy()))
.header(nvc_include.join("nvEncodeAPI.h").to_string_lossy());
format_write(nvenc_builder, "src/ffi/nvenc.rs");
format_write(nvenc_builder, "src/nvenc.rs");
}

View File

@ -0,0 +1,24 @@
// TODO do w/out the unions?
#![feature(untagged_unions)]
pub mod cuda;
pub mod cuvid;
pub mod nvenc;
#[cfg(test)]
mod tests {
use super::cuda::*;
#[test]
fn init_and_version() {
let ret = unsafe { cuInit(0) };
println!("{:?}", ret);
let ver = unsafe {
let mut ver = 0;
cuDriverGetVersion(&mut ver as *mut i32);
ver
};
println!("Version {}", ver);
}
}

View File

@ -4,7 +4,7 @@ use std::os::raw::c_char;
use ffi::cuda::*;
use ffi::cuda::cudaError_enum::*;
struct CuDevice {
pub struct CuDevice {
device: CUdevice,
}

View File

@ -1,3 +0,0 @@
pub mod cuda;
pub mod cuvid;
pub mod nvenc;

View File

@ -1,24 +1,3 @@
// TODO do w/out the unions?
#![feature(untagged_unions)]
mod ffi;
extern crate nvidia_video_codec_sys as ffi;
pub mod cuda;
#[cfg(test)]
mod tests {
use super::ffi::cuda::*;
#[test]
fn init_and_version() {
let ret = unsafe { cuInit(0) };
println!("{:?}", ret);
let ver = unsafe {
let mut ver = 0;
cuDriverGetVersion(&mut ver as *mut i32);
ver
};
println!("Version {}", ver);
}
}