build: Split in two separate crates
Keep the FFI bindings apart.
This commit is contained in:
parent
1b2e253374
commit
d06bb4bbf4
4
.gitignore
vendored
4
.gitignore
vendored
@ -6,6 +6,4 @@
|
|||||||
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
|
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
|
||||||
target
|
target
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
src/ffi/cuda.rs
|
|
||||||
src/ffi/cuvid.rs
|
|
||||||
src/ffi/nvenc.rs
|
|
||||||
|
15
Cargo.toml
15
Cargo.toml
@ -2,10 +2,15 @@
|
|||||||
name = "nvidia-video-codec"
|
name = "nvidia-video-codec"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Luca Barbato <lu_zero@gentoo.org>"]
|
authors = ["Luca Barbato <lu_zero@gentoo.org>"]
|
||||||
|
license = "MIT"
|
||||||
build = "build.rs"
|
description = "NVIDIA Video Codec bindings"
|
||||||
|
repository = "https://github.com/rust-av/nvidia-video-codec-rs"
|
||||||
[build-dependencies.libbindgen]
|
readme = "../README.md"
|
||||||
git = "https://github.com/servo/rust-bindgen"
|
keywords = ["NVIDIA", "cuvid", "nvenc"]
|
||||||
|
|
||||||
[dependencies]
|
[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
3
nvidia-video-codec-sys/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
src/cuda.rs
|
||||||
|
src/cuvid.rs
|
||||||
|
src/nvenc.rs
|
14
nvidia-video-codec-sys/Cargo.toml
Normal file
14
nvidia-video-codec-sys/Cargo.toml
Normal 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]
|
21
nvidia-video-codec-sys/LICENSE
Normal file
21
nvidia-video-codec-sys/LICENSE
Normal 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.
|
@ -53,18 +53,18 @@ fn main() {
|
|||||||
.header(cuda_include.join("cuda.h").to_string_lossy());
|
.header(cuda_include.join("cuda.h").to_string_lossy());
|
||||||
|
|
||||||
// Manually fix the comment so rustdoc won't try to pick them
|
// 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()
|
let cuvid_builder = common_builder()
|
||||||
.clang_arg(format!("-I{}", nvc_include.to_string_lossy()))
|
.clang_arg(format!("-I{}", nvc_include.to_string_lossy()))
|
||||||
.clang_arg(format!("-I{}", cuda_include.to_string_lossy()))
|
.clang_arg(format!("-I{}", cuda_include.to_string_lossy()))
|
||||||
.header(nvc_include.join("nvcuvid.h").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()
|
let nvenc_builder = common_builder()
|
||||||
.clang_arg(format!("-I{}", nvc_include.to_string_lossy()))
|
.clang_arg(format!("-I{}", nvc_include.to_string_lossy()))
|
||||||
.header(nvc_include.join("nvEncodeAPI.h").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");
|
||||||
}
|
}
|
24
nvidia-video-codec-sys/src/lib.rs
Normal file
24
nvidia-video-codec-sys/src/lib.rs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ use std::os::raw::c_char;
|
|||||||
use ffi::cuda::*;
|
use ffi::cuda::*;
|
||||||
use ffi::cuda::cudaError_enum::*;
|
use ffi::cuda::cudaError_enum::*;
|
||||||
|
|
||||||
struct CuDevice {
|
pub struct CuDevice {
|
||||||
device: CUdevice,
|
device: CUdevice,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
pub mod cuda;
|
|
||||||
pub mod cuvid;
|
|
||||||
pub mod nvenc;
|
|
23
src/lib.rs
23
src/lib.rs
@ -1,24 +1,3 @@
|
|||||||
// TODO do w/out the unions?
|
extern crate nvidia_video_codec_sys as ffi;
|
||||||
#![feature(untagged_unions)]
|
|
||||||
|
|
||||||
mod ffi;
|
|
||||||
|
|
||||||
pub mod cuda;
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user