Skip to content

Commit

Permalink
Merge pull request #7 from Hanaasagi/fix-cross-build
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanaasagi authored Jul 29, 2023
2 parents 37b6982 + cdc4179 commit f746dd3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Get os native machine id without root permission.
[target.'cfg(windows)'.dependencies]
winreg = "0.11"

[target.'cfg(windows)'.build-dependencies]
# [target.'cfg(windows)'.build-dependencies]
[build-dependencies]
cc = "1.0"
bindgen = "0.59"
12 changes: 8 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use std::env;
fn main() {
#[cfg(target_os = "windows")]
{
let target_os = env::var("CARGO_CFG_TARGET_OS");
if target_os.is_ok() && target_os.unwrap() == "windows" {
use cc::Build;
println!("cargo:rustc-link-lib=Kernel32");
Build::new().file("src/win.cpp").compile("machine-uid");
// println!("cargo:rustc-link-lib=Kernel.a");
Build::new()
.file("src/win.cpp")
.cpp_link_stdlib("stdc++")
.compile("machine-uid");
}
}

0 comments on commit f746dd3

Please sign in to comment.