Skip to content

Commit

Permalink
Teach xdbg --version (#1441)
Browse files Browse the repository at this point in the history
Introduce --version.

This also upgrades from 8.x to 9.x of vergen and changes the way version is generated in mls.
  • Loading branch information
mkysel authored Dec 20, 2024
1 parent 33c06af commit 6a0c745
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 12 deletions.
72 changes: 65 additions & 7 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ thiserror = "2.0"
tls_codec = "0.4.1"
tokio = { version = "1.35.1", default-features = false }
uuid = "1.10"
vergen-git2 = "1.0.2"
wasm-timer = "0.2"
web-time = "1.1"
# Changing this version and rustls may potentially break the android build. Use Caution.
Expand Down
4 changes: 2 additions & 2 deletions mls_validation_service/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "mls_validation_service"
version = "0.1.0" # Intentionally decoupled from the Workspace versioning
version = "0.1.4"
build = "build.rs"
license.workspace = true

Expand All @@ -10,7 +10,7 @@ name = "mls-validation-service"
path = "src/main.rs"

[build-dependencies]
vergen = { version = "8.3.2", features = ["git", "git2"] }
vergen-git2 = { workspace = true, features = ["build"] }

[dependencies]
clap = { version = "4.4.6", features = ["derive"] }
Expand Down
13 changes: 10 additions & 3 deletions mls_validation_service/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
use vergen::EmitBuilder;
use std::error::Error;
use vergen_git2::{BuildBuilder, Emitter, Git2Builder};

fn main() {
EmitBuilder::builder().git_sha(true).emit().unwrap();
fn main() -> Result<(), Box<dyn Error>> {
let build = BuildBuilder::all_build()?;
let git = Git2Builder::default().branch(true).sha(true).build()?;
Emitter::default()
.add_instructions(&build)?
.add_instructions(&git)?
.emit()?;
Ok(())
}
3 changes: 3 additions & 0 deletions xmtp_debug/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"
version = "0.1.0"
license.workspace = true

[build-dependencies]
vergen-git2 = { workspace = true, features = ["build"] }

[dependencies]
clap = { version = "4.5.20", features = ["derive"] }
clap-verbosity-flag = "3.0"
Expand Down
12 changes: 12 additions & 0 deletions xmtp_debug/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use std::error::Error;
use vergen_git2::{BuildBuilder, Emitter, Git2Builder};

fn main() -> Result<(), Box<dyn Error>> {
let build = BuildBuilder::all_build()?;
let git = Git2Builder::default().branch(true).sha(true).build()?;
Emitter::default()
.add_instructions(&build)?
.add_instructions(&git)?
.emit()?;
Ok(())
}
3 changes: 3 additions & 0 deletions xmtp_debug/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ pub use types::*;
/// Debug & Generate data on the XMTP Network
#[derive(Parser, Debug)]
pub struct AppOpts {
// Print Version
#[arg(long)]
pub version: bool,
#[command(subcommand)]
pub cmd: Option<Commands>,
#[command(flatten)]
Expand Down
9 changes: 9 additions & 0 deletions xmtp_debug/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ async fn main() -> Result<()> {
let mut logger = logger::Logger::from(&opts.log);
logger.init()?;

if opts.version {
info!("Version: {0}", get_version());
return Ok(());
}

let app = app::App::new(opts)?;
app.run().await?;

Ok(())
}

pub fn get_version() -> String {
format!("{}-{}", env!("CARGO_PKG_VERSION"), env!("VERGEN_GIT_SHA"))
}

0 comments on commit 6a0c745

Please sign in to comment.