Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduced 'version' command to all relevant binaries #969

Merged
merged 2 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions clients/native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ coconut = ["coconut-interface", "credentials", "gateway-requests/coconut", "gate

[dev-dependencies]
serde_json = "1.0" # for the "textsend" example

[build-dependencies]
vergen = { version = "5", default-features = false, features = ["build", "git", "rustc", "cargo"] }
8 changes: 8 additions & 0 deletions clients/native/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0

use vergen::{vergen, Config};

fn main() {
vergen(Config::default()).expect("failed to extract build metadata")
}
1 change: 1 addition & 0 deletions clients/native/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use url::Url;
pub(crate) mod init;
pub(crate) mod run;
pub(crate) mod upgrade;
pub(crate) mod version;

fn parse_validators(raw: &str) -> Vec<Url> {
raw.split(',')
Expand Down
27 changes: 27 additions & 0 deletions clients/native/src/commands/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0

use clap::{App, ArgMatches};

pub fn command_args<'a, 'b>() -> App<'a, 'b> {
App::new("version").about("Displays version and build information of this binary")
}

pub fn execute(_matches: &ArgMatches) {
println!(
"{:<20}{}",
"Build Timestamp:",
env!("VERGEN_BUILD_TIMESTAMP")
);
println!("{:<20}{}", "Build Version:", env!("VERGEN_BUILD_SEMVER"));
println!("{:<20}{}", "Commit SHA:", env!("VERGEN_GIT_SHA"));
println!(
"{:<20}{}",
"Commit Date:",
env!("VERGEN_GIT_COMMIT_TIMESTAMP")
);
println!("{:<20}{}", "Commit Branch:", env!("VERGEN_GIT_BRANCH"));
println!("{:<20}{}", "rustc Version:", env!("VERGEN_RUSTC_SEMVER"));
println!("{:<20}{}", "rustc Channel:", env!("VERGEN_RUSTC_CHANNEL"));
println!("{:<20}{}", "cargo Profile:", env!("VERGEN_CARGO_PROFILE"));
}
2 changes: 2 additions & 0 deletions clients/native/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fn main() {
.subcommand(commands::init::command_args())
.subcommand(commands::run::command_args())
.subcommand(commands::upgrade::command_args())
.subcommand(commands::version::command_args())
.get_matches();

execute(arg_matches);
Expand All @@ -29,6 +30,7 @@ fn execute(matches: ArgMatches) {
("init", Some(m)) => commands::init::execute(m),
("run", Some(m)) => commands::run::execute(m),
("upgrade", Some(m)) => commands::upgrade::execute(m),
("version", Some(m)) => commands::version::execute(m),
_ => println!("{}", usage()),
}
}
Expand Down
3 changes: 3 additions & 0 deletions clients/socks5/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ network-defaults = { path = "../../common/network-defaults" }

[features]
coconut = ["coconut-interface", "credentials", "gateway-requests/coconut", "gateway-client/coconut"]

[build-dependencies]
vergen = { version = "5", default-features = false, features = ["build", "git", "rustc", "cargo"] }
8 changes: 8 additions & 0 deletions clients/socks5/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0

use vergen::{vergen, Config};

fn main() {
vergen(Config::default()).expect("failed to extract build metadata")
}
1 change: 1 addition & 0 deletions clients/socks5/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use url::Url;
pub(crate) mod init;
pub(crate) mod run;
pub(crate) mod upgrade;
pub(crate) mod version;

fn parse_validators(raw: &str) -> Vec<Url> {
raw.split(',')
Expand Down
27 changes: 27 additions & 0 deletions clients/socks5/src/commands/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0

use clap::{App, ArgMatches};

pub fn command_args<'a, 'b>() -> App<'a, 'b> {
App::new("version").about("Displays version and build information of this binary")
}

pub fn execute(_matches: &ArgMatches) {
println!(
"{:<20}{}",
"Build Timestamp:",
env!("VERGEN_BUILD_TIMESTAMP")
);
println!("{:<20}{}", "Build Version:", env!("VERGEN_BUILD_SEMVER"));
println!("{:<20}{}", "Commit SHA:", env!("VERGEN_GIT_SHA"));
println!(
"{:<20}{}",
"Commit Date:",
env!("VERGEN_GIT_COMMIT_TIMESTAMP")
);
println!("{:<20}{}", "Commit Branch:", env!("VERGEN_GIT_BRANCH"));
println!("{:<20}{}", "rustc Version:", env!("VERGEN_RUSTC_SEMVER"));
println!("{:<20}{}", "rustc Channel:", env!("VERGEN_RUSTC_CHANNEL"));
println!("{:<20}{}", "cargo Profile:", env!("VERGEN_CARGO_PROFILE"));
}
2 changes: 2 additions & 0 deletions clients/socks5/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fn main() {
.subcommand(commands::init::command_args())
.subcommand(commands::run::command_args())
.subcommand(commands::upgrade::command_args())
.subcommand(commands::version::command_args())
.get_matches();

execute(arg_matches);
Expand All @@ -29,6 +30,7 @@ fn execute(matches: ArgMatches) {
("init", Some(m)) => commands::init::execute(m),
("run", Some(m)) => commands::run::execute(m),
("upgrade", Some(m)) => commands::upgrade::execute(m),
("version", Some(m)) => commands::version::execute(m),
_ => println!("{}", usage()),
}
}
Expand Down
1 change: 1 addition & 0 deletions gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ coconut = ["coconut-interface", "gateway-requests/coconut", "gateway-client/coco
[build-dependencies]
tokio = { version = "1.4", features = ["rt-multi-thread", "macros"] }
sqlx = { version = "0.5", features = ["runtime-tokio-rustls", "sqlite", "macros", "migrate"] }
vergen = { version = "5", default-features = false, features = ["build", "git", "rustc", "cargo"] }
3 changes: 3 additions & 0 deletions gateway/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use sqlx::{Connection, SqliteConnection};
use std::env;
use vergen::{vergen, Config};

#[tokio::main]
async fn main() {
Expand All @@ -22,4 +23,6 @@ async fn main() {
// for some strange reason we need to add a leading `/` to the windows path even though it's
// not a valid windows path... but hey, it works...
println!("cargo:rustc-env=DATABASE_URL=sqlite:///{}", &database_path);

vergen(Config::default()).expect("failed to extract build metadata")
}
1 change: 1 addition & 0 deletions gateway/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub(crate) mod init;
pub(crate) mod run;
pub(crate) mod sign;
pub(crate) mod upgrade;
pub(crate) mod version;

pub(crate) const ID_ARG_NAME: &str = "id";
pub(crate) const HOST_ARG_NAME: &str = "host";
Expand Down
27 changes: 27 additions & 0 deletions gateway/src/commands/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0

use clap::{App, ArgMatches};

pub fn command_args<'a, 'b>() -> App<'a, 'b> {
App::new("version").about("Displays version and build information of this binary")
}

pub fn execute(_matches: &ArgMatches) {
println!(
"{:<20}{}",
"Build Timestamp:",
env!("VERGEN_BUILD_TIMESTAMP")
);
println!("{:<20}{}", "Build Version:", env!("VERGEN_BUILD_SEMVER"));
println!("{:<20}{}", "Commit SHA:", env!("VERGEN_GIT_SHA"));
println!(
"{:<20}{}",
"Commit Date:",
env!("VERGEN_GIT_COMMIT_TIMESTAMP")
);
println!("{:<20}{}", "Commit Branch:", env!("VERGEN_GIT_BRANCH"));
println!("{:<20}{}", "rustc Version:", env!("VERGEN_RUSTC_SEMVER"));
println!("{:<20}{}", "rustc Channel:", env!("VERGEN_RUSTC_CHANNEL"));
println!("{:<20}{}", "cargo Profile:", env!("VERGEN_CARGO_PROFILE"));
}
2 changes: 2 additions & 0 deletions gateway/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ async fn main() {
.subcommand(commands::run::command_args())
.subcommand(commands::sign::command_args())
.subcommand(commands::upgrade::command_args())
.subcommand(commands::version::command_args())
.get_matches();

execute(arg_matches).await;
Expand All @@ -32,6 +33,7 @@ async fn execute(matches: ArgMatches<'static>) {
("run", Some(m)) => commands::run::execute(m.clone()).await,
("upgrade", Some(m)) => commands::upgrade::execute(m.clone()).await,
("sign", Some(m)) => commands::sign::execute(m),
("version", Some(m)) => commands::version::execute(m),
_ => println!("{}", usage()),
}
}
Expand Down
3 changes: 3 additions & 0 deletions mixnode/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ version-checker = { path="../common/version-checker" }

[dev-dependencies]
serial_test = "0.5"

[build-dependencies]
vergen = { version = "5", default-features = false, features = ["build", "git", "rustc", "cargo"] }
8 changes: 8 additions & 0 deletions mixnode/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0

use vergen::{vergen, Config};

fn main() {
vergen(Config::default()).expect("failed to extract build metadata")
}
1 change: 1 addition & 0 deletions mixnode/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub(crate) mod init;
pub(crate) mod run;
pub(crate) mod sign;
pub(crate) mod upgrade;
pub(crate) mod version;

pub(crate) const ID_ARG_NAME: &str = "id";
pub(crate) const HOST_ARG_NAME: &str = "host";
Expand Down
Loading