-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
62 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,65 @@ | ||
extern crate pkg_config; | ||
|
||
#[allow(unused_must_use)] | ||
#[allow(clippy::overly_complex_bool_expr)] | ||
#[allow(clippy::nonminimal_bool)] | ||
fn main() { | ||
// let out_dir = env::var("OUT_DIR").unwrap(); | ||
// let out_path = PathBuf::from(&out_dir); | ||
// let include_dir = format!("{}/{}", out_dir, "include"); | ||
|
||
let pc = pkg_config::Config::new(); | ||
|
||
//If libaribb25 is found, then it'll continue. If not found, start build & deployment. | ||
pc.probe("libpcsclite"); | ||
|
||
if pc.target_supported() && cfg!(target_os = "linux") { | ||
println!("cargo:rustc-link-lib=dylib=stdc++"); | ||
if !pc.probe("libaribb25").is_err() { | ||
// Staticaly link against libaribb25.so or aribb25.lib. | ||
println!("cargo:rustc-link-lib=static=aribb25"); | ||
return; | ||
} | ||
//start self build in Linux | ||
} | ||
|
||
fn prep_cmake() -> cmake::Config { | ||
let mut cm = cmake::Config::new("./externals/libaribb25"); | ||
cm.very_verbose(true); | ||
|
||
// Enable AVX2 for x64 | ||
// NEON SIMD is also supported, but not all ARM SoCs support it, so build without it. | ||
if cfg!(target_arch = "x86_64") { | ||
cm.configure_arg("-DUSE_AVX2=ON"); | ||
} | ||
|
||
if cfg!(target_os = "windows") { | ||
if cfg!(target_env = "msvc") { | ||
cm.generator("Visual Studio 17 2022"); | ||
/* | ||
MSVC + libaribb25(debug) = fail | ||
warning LNK4098: defaultlib \'MSVCRTD.../NODEFAULTLIB:library... | ||
*/ | ||
cm.profile("Release"); | ||
} else if cfg!(target_env = "gnu") { | ||
match std::env::var("MSYSTEM") { | ||
Ok(sys_name) if sys_name.to_lowercase().contains("mingw64") => { | ||
cm.generator("Ninja"); | ||
#[cfg(debug_assertions)] | ||
println!("cargo:rustc-link-lib=msvcrtd"); | ||
#[cfg(not(debug_assertions))] | ||
println!("cargo:rustc-link-lib=msvcrt"); | ||
println!("cargo:rustc-link-lib=ucrtbase"); | ||
} | ||
Ok(sys_name) => { | ||
panic!("target_env:={sys_name} not supported.") | ||
} | ||
_ => { | ||
// TODO | ||
cm.generator("MinGW Makefiles"); | ||
#[cfg(debug_assertions)] | ||
println!("cargo:rustc-link-lib=msvcrtd"); | ||
#[cfg(not(debug_assertions))] | ||
println!("cargo:rustc-link-lib=msvcrt"); | ||
println!("cargo:rustc-link-lib=ucrtbase"); | ||
} | ||
if cfg!(windows) { | ||
if cfg!(target_env = "gnullvm") { | ||
unimplemented!("tier3 gnullvm") | ||
} | ||
match (cfg!(target_env = "gnu"), std::env::var("MSYSTEM")) { | ||
(false, _) => { | ||
cm.generator("Visual Studio 17 2022"); | ||
} | ||
(true, Ok(sys_name)) if sys_name.to_lowercase().contains("mingw") => { | ||
cm.generator("Ninja"); | ||
} | ||
(true, Ok(sys_name)) if sys_name.to_lowercase().contains("ucrt") => { | ||
cm.generator("Ninja"); | ||
} | ||
(true, Ok(sys_name)) => { | ||
panic!("target_env:={sys_name} not supported.") | ||
} | ||
} else if cfg!(target_env = "gnullvm") { | ||
match std::env::var("MSYSTEM") { | ||
Ok(sys_name) if sys_name.to_lowercase().contains("ucrt") => { | ||
cm.generator("Ninja"); | ||
println!("cargo:rustc-link-lib=ucrt"); | ||
} | ||
Ok(sys_name) if sys_name.to_lowercase().contains("clang") => { | ||
cm.generator("Ninja"); | ||
println!("cargo:rustc-link-lib=ucrt"); | ||
} | ||
Ok(sys_name) => { | ||
panic!("target_env:={sys_name} not supported.") | ||
} | ||
_ => { | ||
// TODO | ||
cm.generator("MinGW Makefiles"); | ||
println!("cargo:rustc-link-lib=ucrt"); | ||
// println!("cargo:rustc-link-lib=vcruntime140"); | ||
} | ||
(true, _) => { | ||
cm.generator("MinGW Makefiles"); | ||
} | ||
// llvm-mingw | ||
} | ||
println!("cargo:rustc-link-search=native=C:\\Windows\\System32"); | ||
println!("cargo:rustc-link-lib=dylib=winscard"); | ||
} | ||
|
||
let res = cm.build(); | ||
println!("cargo:rustc-link-search=native={}/lib", res.display()); | ||
println!("cargo:rustc-link-search=native={}/lib64", res.display()); | ||
|
||
// Staticaly link against libaribb25.so or aribb25.lib. | ||
println!("cargo:rustc-link-lib=static=aribb25"); | ||
|
||
#[cfg(debug_assertions)] | ||
cm.profile("Debug"); | ||
#[cfg(not(debug_assertions))] | ||
cm.profile("Release"); | ||
|
||
cm | ||
} | ||
|
||
fn main() { | ||
let pc = pkg_config::Config::new(); | ||
if cfg!(windows) { | ||
let res = prep_cmake().build(); | ||
println!("cargo:rustc-link-search=native={}/lib", res.display()); | ||
println!("cargo:rustc-link-lib=dylib=winscard"); | ||
} else if cfg!(target_os = "linux") { | ||
if pc.probe("libpcsclite").is_err() { | ||
panic!() | ||
} | ||
if pc.probe("libaribb25").is_err() { | ||
// Staticaly link against libaribb25.so or aribb25.lib. | ||
} else { | ||
let res = prep_cmake().build(); | ||
println!("cargo:rustc-link-search=native={}/lib", res.display()); | ||
println!("cargo:rustc-link-search=native={}/lib64", res.display()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters