Skip to content

Commit

Permalink
Merge pull request #15 from bpandreotti/master
Browse files Browse the repository at this point in the history
Remove `proc_macro_hack` dependency
  • Loading branch information
de-vri-es authored Dec 13, 2021
2 parents e46c2f3 + 42286e2 commit 4d8786e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 40 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ edition = "2018"
readme = "README.md"

[dependencies]
proc-macro-hack = "0.5"
git-version-macro = { version = "=0.3.5", path = "git-version-macro" }

[workspace]
Expand Down
1 change: 0 additions & 1 deletion git-version-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ proc-macro = true
[dependencies]
quote = "1.0"
proc-macro2 = "1.0"
proc-macro-hack = "0.5"
syn = "1.0"
36 changes: 34 additions & 2 deletions git-version-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ extern crate proc_macro;

use proc_macro::TokenStream;
use proc_macro2::{Span, TokenStream as TokenStream2};
use proc_macro_hack::proc_macro_hack;
use quote::{quote, ToTokens};
use std::path::{Path, PathBuf};
use syn::{
Expand Down Expand Up @@ -109,7 +108,40 @@ impl Parse for Args {
}
}

#[proc_macro_hack]
/// Get the git version for the source code.
///
/// The following (named) arguments can be given:
///
/// - `args`: The arguments to call `git describe` with.
/// Default: `args = ["--always", "--dirty=-modified"]`
///
/// - `prefix`, `suffix`:
/// The git version will be prefixed/suffexed by these strings.
///
/// - `cargo_prefix`, `cargo_suffix`:
/// If either is given, Cargo's version (given by the CARGO_PKG_VERSION
/// environment variable) will be used if git fails instead of giving an
/// error. It will be prefixed/suffixed by the given strings.
///
/// - `fallback`:
/// If all else fails, this string will be given instead of reporting an
/// error.
///
/// # Examples
///
/// ```ignore
/// const VERSION: &str = git_version!();
/// ```
///
/// ```ignore
/// const VERSION: &str = git_version!(args = ["--abbrev=40", "--always"]);
/// ```
///
/// ```
/// # use git_version::git_version;
/// const VERSION: &str = git_version!(prefix = "git:", cargo_prefix = "cargo:", fallback = "unknown");
/// ```
#[proc_macro]
pub fn git_version(input: TokenStream) -> TokenStream {
let args = parse_macro_input!(input as Args);

Expand Down
36 changes: 0 additions & 36 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,6 @@
//! These macros do not depend on libgit, but simply uses the `git` binary directly.
//! So you must have `git` installed somewhere in your `PATH`.

use proc_macro_hack::proc_macro_hack;

/// Get the git version for the source code.
///
/// The following (named) arguments can be given:
///
/// - `args`: The arguments to call `git describe` with.
/// Default: `args = ["--always", "--dirty=-modified"]`
///
/// - `prefix`, `suffix`:
/// The git version will be prefixed/suffexed by these strings.
///
/// - `cargo_prefix`, `cargo_suffix`:
/// If either is given, Cargo's version (given by the CARGO_PKG_VERSION
/// environment variable) will be used if git fails instead of giving an
/// error. It will be prefixed/suffixed by the given strings.
///
/// - `fallback`:
/// If all else fails, this string will be given instead of reporting an
/// error.
///
/// # Examples
///
/// ```ignore
/// const VERSION: &str = git_version!();
/// ```
///
/// ```ignore
/// const VERSION: &str = git_version!(args = ["--abbrev=40", "--always"]);
/// ```
///
/// ```
/// # use git_version::git_version;
/// const VERSION: &str = git_version!(prefix = "git:", cargo_prefix = "cargo:", fallback = "unknown");
/// ```
#[proc_macro_hack]
pub use git_version_macro::git_version;

/// Run `git describe` at compile time with custom flags.
Expand Down

0 comments on commit 4d8786e

Please sign in to comment.