comfy_git_version_macro/lib.rs
1extern crate proc_macro;
2
3use proc_macro::{Literal, TokenStream, TokenTree};
4
5mod utils;
6use self::utils::describe_cwd;
7
8/// Get the git version for the source code.
9///
10/// # Examples
11///
12/// ```ignore
13/// const VERSION: &str = git_version!();
14#[proc_macro]
15pub fn git_version(_input: TokenStream) -> TokenStream {
16 let version = describe_cwd().unwrap();
17
18 TokenTree::Literal(Literal::string(&version)).into()
19}