Skip to content

Commit

Permalink
Merge pull request #533 from stefnotch/ver-gon
Browse files Browse the repository at this point in the history
Only enable vergen on docsrs
  • Loading branch information
zesterer authored Oct 9, 2023
2 parents dcdeb81 + a7ecae4 commit 7131ca4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ regex = ["dep:regex-automata"]
# Enable serde serialization support
serde = ["dep:serde"]

# Enable dependencies only needed for generation of documentation on docs.rs
docsrs = ["dep:vergen"]

# An alias of all features that work with the stable compiler.
# Do not use this feature, its removal is not considered a breaking change and its behaviour may change.
# If you're working on chumsky and you're adding a feature that does not require nightly support, please add it to this list.
Expand Down Expand Up @@ -94,7 +97,7 @@ lasso = "0.7"
slotmap = "1.0"

[build-dependencies]
vergen = { version = "=8.1.1", features = ["git", "gitoxide"] }
vergen = { version = "=8.1.1", optional = true, features = ["git", "gitoxide"] }

[target.'cfg(unix)'.dev-dependencies]
pprof = { version = "0.11", features = ["flamegraph", "criterion"] }
Expand Down
12 changes: 12 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
use std::error::Error;
#[cfg(feature = "docsrs")]
use vergen::EmitBuilder;

fn main() -> Result<(), Box<dyn Error>> {
emit_git_metadata()?;
Ok(())
}

#[cfg(feature = "docsrs")]
fn emit_git_metadata() -> Result<(), Box<dyn Error>> {
// Emit the instructions
EmitBuilder::builder().all_git().emit()?;
Ok(())
}

#[cfg(not(feature = "docsrs"))]
fn emit_git_metadata() -> Result<(), Box<dyn Error>> {
Ok(())
}
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
extern crate alloc;
extern crate core;

#[cfg(feature = "docsrs")]
macro_rules! blob_url_prefix {
() => {
concat!(
Expand All @@ -34,6 +35,16 @@ macro_rules! blob_url_prefix {
};
}

#[cfg(not(feature = "docsrs"))]
macro_rules! blob_url_prefix {
() => {
concat!(
"https://github.com/zesterer/chumsky/blob/",
env!("CARGO_PKG_VERSION")
)
};
}

macro_rules! go_extra {
( $O :ty ) => {
#[inline(always)]
Expand Down

0 comments on commit 7131ca4

Please sign in to comment.