diff options
author | Daniel Mueller <deso@posteo.net> | 2018-01-15 09:36:38 -0800 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2018-01-15 09:36:38 -0800 |
commit | f3149d7f2802711791c490b71313aafc55f4809c (patch) | |
tree | cd0247b0d856be8b9e010738646965233aa60c93 /hidapi-sys | |
parent | d8a58488bd56ef9c09e167173124c3519bc7405d (diff) | |
download | nitrocli-f3149d7f2802711791c490b71313aafc55f4809c.tar.gz nitrocli-f3149d7f2802711791c490b71313aafc55f4809c.tar.bz2 |
Update hidapi-sys crate to 0.1.4
This change updates the hidapi-sys crate to version 0.1.4. In this
version the cc crate (the stable and renamed version of the gcc crate)
is used.
Import subrepo hidapi-sys/:hidapi-sys at c01043da72c0cac898660017e4c4115278c14369
Import subrepo cc/:cc at 500c65b03775cecf55bd358e616963bc3222acca
Diffstat (limited to 'hidapi-sys')
-rw-r--r-- | hidapi-sys/Cargo.toml | 4 | ||||
-rw-r--r-- | hidapi-sys/README.md | 10 | ||||
-rw-r--r-- | hidapi-sys/build.rs | 48 |
3 files changed, 42 insertions, 20 deletions
diff --git a/hidapi-sys/Cargo.toml b/hidapi-sys/Cargo.toml index 15b4e9e..3483b34 100644 --- a/hidapi-sys/Cargo.toml +++ b/hidapi-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hidapi-sys" -version = "0.1.2" +version = "0.1.4" build = "build.rs" links = "hidapi" @@ -20,5 +20,5 @@ build = ["static"] libc = "0.2" [build-dependencies] -gcc = "0.3" +cc = "1.0" pkg-config = "0.3" diff --git a/hidapi-sys/README.md b/hidapi-sys/README.md new file mode 100644 index 0000000..89048b1 --- /dev/null +++ b/hidapi-sys/README.md @@ -0,0 +1,10 @@ +hidapi-sys [![WTFPL](http://img.shields.io/badge/license-WTFPL-blue.svg)](http://www.wtfpl.net/txt/copying) +========== +Bindings for hidapi with support for building sources automatically. + +Requirements +------------ +`gcc` and `pkg-config` are required for building source automatically. + +`git` is required unless `HIDAPI_PATH` is exported to an existing checkout of +hidapi sources. diff --git a/hidapi-sys/build.rs b/hidapi-sys/build.rs index d910944..4a392c6 100644 --- a/hidapi-sys/build.rs +++ b/hidapi-sys/build.rs @@ -1,4 +1,4 @@ -extern crate gcc; +extern crate cc; extern crate pkg_config; use std::env; @@ -11,8 +11,8 @@ fn main() { return; } - fetch().unwrap(); - build().unwrap(); + fetch().expect("failed to checkout hidapi sources, internet connection and git are needed"); + build().expect("failed to build hidapi sources"); println!("cargo:rustc-link-search=native={}", output().to_string_lossy()); } @@ -22,10 +22,19 @@ fn output() -> PathBuf { } fn source() -> PathBuf { - output().join("hidapi") + if let Ok(path) = env::var("HIDAPI_PATH") { + path.into() + } + else { + output().join("hidapi") + } } fn fetch() -> io::Result<()> { + if env::var("HIDAPI_PATH").is_ok() { + return Ok(()); + } + Command::new("git") .current_dir(&output()) .arg("clone") @@ -38,44 +47,47 @@ fn fetch() -> io::Result<()> { #[cfg(target_os = "linux")] fn build() -> io::Result<()> { - let mut config = gcc::Build::new(); + let mut build = cc::Build::new(); - config.file(source().join("libusb/hid.c")); - config.include(source().join("hidapi")); + build.file(source().join("libusb/hid.c")); + build.include(source().join("hidapi")); + build.static_flag(true); for path in pkg_config::find_library("libusb-1.0").unwrap().include_paths { - config.include(path.to_str().unwrap()); + build.include(path.to_str().unwrap()); } - config.compile("libhidapi-libusb.a"); + build.compile("libhidapi-libusb.a"); Ok(()) } #[cfg(target_os = "macos")] fn build() -> io::Result<()> { - let mut config = gcc::Build::new(); + let mut build = cc::Build::new(); - config.file(source().join("libusb/hid.c")); - config.include(source().join("hidapi")); + build.file(source().join("libusb/hid.c")); + build.include(source().join("hidapi")); + build.static_flag(true); for path in pkg_config::find_library("libusb-1.0").unwrap().include_paths { - config.include(path.to_str().unwrap()); + build.include(path.to_str().unwrap()); } - config.compile("libhidapi.a"); + build.compile("libhidapi.a"); Ok(()) } #[cfg(target_os = "windows")] fn build() -> io::Result<()> { - let mut config = gcc::Build::new(); + let mut build = cc::Build::new(); - config.file(source().join("windows/hid.c")); - config.include(source().join("hidapi")); + build.file(source().join("windows/hid.c")); + build.include(source().join("hidapi")); + build.static_flag(true); - config.compile("libhidapi.a"); + build.compile("libhidapi.a"); Ok(()) } |