28 lines
617 B
Rust
28 lines
617 B
Rust
|
use clap;
|
||
|
use failure::Error;
|
||
|
|
||
|
const NAME: &'static str = env!("CARGO_PKG_NAME");
|
||
|
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
||
|
|
||
|
macro_rules! get_cfg {
|
||
|
($i:ident : $($s:expr),+) => (
|
||
|
let $i = || { $( if cfg!($i=$s) { return $s; } );+ "unknown"};
|
||
|
)
|
||
|
}
|
||
|
|
||
|
pub fn init(_: &clap::ArgMatches) -> Result<(), Error> {
|
||
|
get_cfg!(target_os: "windows", "macos", "ios", "linux", "android", "freebsd", "openbsd", "netbsd");
|
||
|
|
||
|
get_cfg!(target_arch: "x86", "x86_64", "mips", "powerpc", "powerpc64", "arm", "aarch64");
|
||
|
|
||
|
println!(
|
||
|
"{} {} for {} on {}",
|
||
|
NAME,
|
||
|
VERSION,
|
||
|
target_os(),
|
||
|
target_arch()
|
||
|
);
|
||
|
|
||
|
Ok(())
|
||
|
}
|