Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: static linking #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ libc = "0.2"

[features]
no_wrapper = []
static = []
leo60228 marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 9 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[cfg(feature = "static")]
fn main() {
println!("cargo:rustc-link-lib=static=v4l2");
println!("cargo:rustc-link-lib=static=v4lconvert");
println!("cargo:rustc-link-lib=static=jpeg");
leo60228 marked this conversation as resolved.
Show resolved Hide resolved
}

#[cfg(not(feature = "static"))]
fn main() {}
3 changes: 2 additions & 1 deletion src/v4l2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ mod ll {
pub use self::v4l2_munmap as munmap;
pub use self::v4l2_open as open;

#[link(name = "v4l2")]
#[cfg_attr(feature = "static", link(name = "v4l2", kind = "static"))]
#[cfg_attr(not(feature = "static"), link(name = "v4l2"))]
extern "C" {
pub fn v4l2_open(file: *const c_char, flags: c_int, arg: c_int) -> RawFd;
pub fn v4l2_close(fd: RawFd) -> c_int;
Expand Down