#git-version #build-time #binary #cargo-build

macro version_macro

rust cargo build binary with git version and build time

1 unstable release

0.1.0 Nov 30, 2023

#662 in Procedural macros

43 downloads per month

MIT/Apache

4KB
56 lines

example


#[cfg(not(debug_assertions))]
mod version {
    use version_macro::{build_git_branch, build_git_version, build_time};

    pub const BUILD_TIME: &str = build_time!();
    pub const BUILD_GIT_BRANCH: &str = build_git_branch!();
    pub const BUILD_GIT_VERSION: &str = build_git_version!();

    pub fn version() -> String {
        format!(
            "lark build info: [git_branch:{} , build_time:{} , git_version:{}]",
            BUILD_GIT_BRANCH, BUILD_TIME, BUILD_GIT_VERSION
        )
    }
}

#[cfg(debug_assertions)]
mod version {
    pub fn version() -> String {
        format!(
            "lark build info: [git_branch:{} , build_time:{} , git_version:{}]",
            "debug", "debug", "debug"
        )
    }
}


Dependencies

~1MB
~19K SLoC