Skip to content

Commit

Permalink
implmentation of binbat#235
Browse files Browse the repository at this point in the history
use shadow-rs to get PKG_VERSION and COMMIT_HASH
`core::concat` can only accept literals, so use `const_str::concat`
  • Loading branch information
miaomiaowu0428 committed Nov 21, 2024
1 parent c6ebb2f commit c5d07da
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 1 deletion.
144 changes: 144 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ repository.workspace = true

default-run = "live777"

build = "build.rs"
[build-dependencies]
shadow-rs = "0.35.1"

[[bin]]
name = "live777"
path = "src/main.rs"
Expand Down Expand Up @@ -87,9 +91,11 @@ net4mqtt = { path = "libs/net4mqtt" }
signal = { path = "libs/signal" }

clap = { workspace = true, features = ["derive"] }
const-str = "0.5.7"
tokio = { workspace = true, features = ["full"] }
tracing = { workspace = true }
serde = { workspace = true }
shadow-rs = "0.35.1"

toml = "0.8.19"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
Expand Down
3 changes: 3 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() -> shadow_rs::SdResult<()> {
shadow_rs::new()
}
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
use clap::Parser;
use const_str::concat;
use tracing::{debug, info, warn};
use shadow_rs::shadow;

shadow!(build);

mod log;
mod utils;

#[derive(Parser)]
#[command(version)]
#[command(version = concat!("v",build::PKG_VERSION,"-",build::SHORT_COMMIT))]
struct Args {
/// Set config file path
#[arg(short, long)]
Expand Down

0 comments on commit c5d07da

Please sign in to comment.