From c4a0004e8b16613dc8a1f9916af71af70a7c2df0 Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Wed, 17 Feb 2021 02:09:32 +0000 Subject: [PATCH] Replace build.rs with link attributes (#205) --- build.rs | 14 -------------- src/windows.rs | 1 + 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 build.rs diff --git a/build.rs b/build.rs deleted file mode 100644 index 95f4b90..0000000 --- a/build.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![deny(warnings)] - -use std::env; - -fn main() { - let target = env::var("TARGET").expect("TARGET was not set"); - if target.contains("windows") { - // for BCryptGenRandom - println!("cargo:rustc-link-lib=bcrypt"); - } else if target.contains("apple-ios") { - // for SecRandomCopyBytes and kSecRandomDefault - println!("cargo:rustc-link-lib=framework=Security"); - } -} diff --git a/src/windows.rs b/src/windows.rs index 56b3d07..643badd 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -11,6 +11,7 @@ use core::{ffi::c_void, num::NonZeroU32, ptr}; const BCRYPT_USE_SYSTEM_PREFERRED_RNG: u32 = 0x00000002; +#[link(name = "bcrypt")] extern "system" { fn BCryptGenRandom( hAlgorithm: *mut c_void,