summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml3
-rw-r--r--build.rs23
-rw-r--r--src/lib.rs2
3 files changed, 27 insertions, 1 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 4e6268c..7c4453c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,3 +10,6 @@ license = "LGPL-3.0"
links = "nitrokey"
build = "build.rs"
readme = "README.md"
+
+[build-dependencies]
+cc = "1.0"
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");
}
diff --git a/src/lib.rs b/src/lib.rs
index 169dac4..2740cc9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -14,6 +14,8 @@ mod tests {
#[test]
fn login_auto() {
unsafe {
+ // logout required due to https://github.com/Nitrokey/libnitrokey/pull/115
+ NK_logout();
assert_eq!(0, NK_login_auto());
}
}