-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from iawia002/version-info
Customize the version information output for CLI
- Loading branch information
Showing
6 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use std::process::Command; | ||
|
||
fn main() { | ||
set_commit_info_for_rustc(); | ||
} | ||
|
||
fn set_commit_info_for_rustc() { | ||
let output = match Command::new("git") | ||
.arg("log") | ||
.arg("-1") | ||
.arg("--date=short") | ||
.arg("--format=%H %h %cd") | ||
.output() | ||
{ | ||
// Something like: 1d3b80a2765e46a51290819b82f772dff09c2c49 1d3b80a 2023-12-21 | ||
Ok(output) if output.status.success() => String::from_utf8(output.stdout).unwrap(), | ||
_ => return, | ||
}; | ||
let mut parts = output.split_whitespace().skip(1); | ||
println!( | ||
"cargo:rustc-env=WACKER_VERSION_INFO={} ({} {})", | ||
env!("CARGO_PKG_VERSION"), | ||
parts.next().unwrap(), | ||
parts.next().unwrap() | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use std::process::Command; | ||
|
||
fn main() { | ||
set_commit_info_for_rustc(); | ||
} | ||
|
||
fn set_commit_info_for_rustc() { | ||
let output = match Command::new("git") | ||
.arg("log") | ||
.arg("-1") | ||
.arg("--date=short") | ||
.arg("--format=%H %h %cd") | ||
.output() | ||
{ | ||
// Something like: 1d3b80a2765e46a51290819b82f772dff09c2c49 1d3b80a 2023-12-21 | ||
Ok(output) if output.status.success() => String::from_utf8(output.stdout).unwrap(), | ||
_ => return, | ||
}; | ||
let mut parts = output.split_whitespace().skip(1); | ||
println!( | ||
"cargo:rustc-env=WACKER_VERSION_INFO={} ({} {})", | ||
env!("CARGO_PKG_VERSION"), | ||
parts.next().unwrap(), | ||
parts.next().unwrap() | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
use anyhow::Result; | ||
|
||
fn main() -> Result<()> { | ||
tonic_build::compile_protos("proto/module.proto")?; | ||
Ok(()) | ||
} |