1use proc_macro::TokenStream;
2use proc_macro2::TokenStream as TokenStream2;
3use quote::quote;
4
5#[proc_macro]
6pub fn print(input: TokenStream) -> TokenStream {
7 print_impl(input.into()).into()
8}
9
10fn print_impl(input: TokenStream2) -> TokenStream2 {
11 quote! {
12 let info = ::clap_vergen::VergenInfo {
13 build_semver: env!("VERGEN_BUILD_SEMVER").to_string(),
14 build_timestamp: env!("VERGEN_BUILD_TIMESTAMP").to_string(),
15 rustc_channel: env!("VERGEN_RUSTC_CHANNEL").to_string(),
16 rustc_commit_date: env!("VERGEN_RUSTC_COMMIT_DATE").to_string(),
17 rustc_commit_hash: env!("VERGEN_RUSTC_COMMIT_HASH").to_string(),
18 rustc_host_triple: env!("VERGEN_RUSTC_HOST_TRIPLE").to_string(),
19 rustc_llvm_version: env!("VERGEN_RUSTC_LLVM_VERSION").to_string(),
20 rustc_semver: env!("VERGEN_RUSTC_SEMVER").to_string(),
21 cargo_features: env!("VERGEN_CARGO_FEATURES").to_string(),
22 cargo_profile: env!("VERGEN_CARGO_PROFILE").to_string(),
23 cargo_target_triple: env!("VERGEN_CARGO_TARGET_TRIPLE").to_string(),
24 git_branch: env!("VERGEN_GIT_BRANCH").to_string(),
25 git_commit_timestamp: env!("VERGEN_GIT_COMMIT_TIMESTAMP").to_string(),
26 git_semver: env!("VERGEN_GIT_SEMVER").to_string(),
27 git_sha: env!("VERGEN_GIT_SHA").to_string(),
28 };
29 if #input.json {
30 println!("{}", info.to_json());
31 } else {
32 println!("{}", info);
33 }
34 } }