baoyachi / shadow-rs

A build-time information stored in your rust project.(binary,lib,cdylib,dylib)
https://docs.rs/shadow-rs
MIT License
444 stars 40 forks source link

make CLAP_* optional or make it is just the `&str` but not `shadow_rs::*` #133

Closed Dirreke closed 1 year ago

Dirreke commented 1 year ago

I want to use this crate for target wasm. However, some dependencies like libgit2 can not be compiled for it.

Therefore, I want to use shadow-rs only in buld-denpendencies but not in denpendencies. However, the const CLAP_* in the shadow.rs, which be created by build.rs, use the shadow-rs to format, and I can not deny it by add it in deny.

So can it make CLAP_* optional or make it is just the &str but not shadow_rs::* ? Thanks!

baoyachi commented 1 year ago

@Dirreke The first question is that the 'git2' crate depends on 'libgit2', and 'git2' is optional. https://github.com/baoyachi/shadow-rs/blob/cea1b1a2cfaaff415e3113855cb30196d6f4ff2d/Cargo.toml#L29-L37

It is possible to make 'git2' in shadow-rs optional. Please refer to the configuration.

shadow-rs = { version = "0.21.0", default-features = false }
baoyachi commented 1 year ago

@Dirreke The second question is that shadow-rs supports blacklist filtering, where certain const values will not be generated by using the 'new_deny' method. See:https://docs.rs/shadow-rs/latest/shadow_rs/fn.new_deny.html

use std::collections::BTreeSet;

fn main() -> shadow_rs::SdResult<()> {
   let mut deny = BTreeSet::new();
   deny.insert(shadow_rs::CARGO_TREE);
   shadow_rs::new_deny(deny)
}
Dirreke commented 1 year ago

@baoyachi Yeah, you are right. I can use features git2 in build-denpendencies and no git2 in denpencies. By this, I can get all info. Thanks

baoyachi commented 1 year ago

@Dirreke Feel happy for you, please feel free to contact me if you have any questions.