aboutsummaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2018-05-20 22:31:34 +0000
committerRobin Krahl <robin.krahl@ireas.org>2018-05-21 00:35:19 +0200
commit9eee4b2475d74cd94c9d72b2520d5568d4564fba (patch)
tree83d44c03edff5b480db40bbd2c2284d21f17b696 /build.rs
parent7fe2032c464ad7a79963823793e94e2c62b770e6 (diff)
downloadnitrokey-sys-rs-9eee4b2475d74cd94c9d72b2520d5568d4564fba.tar.gz
nitrokey-sys-rs-9eee4b2475d74cd94c9d72b2520d5568d4564fba.tar.bz2
Build libnitrokey from source
This patch changes the build script to compile and link libnitrokey from the included source. Also, we have to link against hidapi-libusb as a libnitrokey requirement.
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/build.rs b/build.rs
index 7791134..d31d9aa 100644
--- a/build.rs
+++ b/build.rs
@@ -1,3 +1,24 @@
+extern crate cc;
+
+use std::path::Path;
+
fn main() {
- println!("cargo:rustc-link-lib=nitrokey");
+ let sources = [
+ "DeviceCommunicationExceptions.cpp",
+ "NK_C_API.cc",
+ "NitrokeyManager.cc",
+ "command_id.cc",
+ "device.cc",
+ "log.cc",
+ "misc.cc",
+ ];
+ let library_dir = Path::new("libnitrokey-3.3");
+
+ cc::Build::new()
+ .cpp(true)
+ .include(library_dir.join("libnitrokey"))
+ .files(sources.iter().map(|s| library_dir.join(s)))
+ .compile("libnitrokey.a");
+
+ println!("cargo:rustc-link-lib=hidapi-libusb");
}