File tree Expand file tree Collapse file tree 4 files changed +23
-2
lines changed
Expand file tree Collapse file tree 4 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 22name = " qcc"
33version = " 0.1.0"
44edition = " 2021"
5+ build = " build.rs"
Original file line number Diff line number Diff line change 1+ use std:: process:: Command ;
2+ use std:: str;
3+
4+ fn main ( ) {
5+ let revision = Command :: new ( "git" )
6+ . args ( & [ "rev-parse" , "--short" , "HEAD" ] )
7+ . output ( )
8+ . expect ( "failed to run git" ) ;
9+
10+ if revision. status . success ( ) {
11+ let hash = str:: from_utf8 ( & revision. stdout ) . unwrap ( ) . trim ( ) ;
12+ println ! ( "cargo:rustc-env=GIT_HASH={}" , hash) ;
13+ } else {
14+ println ! ( "cargo:rustc-env=GIT_HASH=unknown" ) ;
15+ }
16+ }
Original file line number Diff line number Diff line change @@ -14,8 +14,9 @@ pub struct Config {
1414}
1515
1616impl Config {
17+ #[ inline]
1718 fn version ( ) -> & ' static str {
18- env ! ( "CARGO_PKG_VERSION" ) // + add latest commit hash
19+ concat ! ( env!( "CARGO_PKG_VERSION" ) , "+" , env! ( "GIT_HASH" ) )
1920 }
2021
2122 pub ( crate ) fn new ( ) -> Self {
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ pub(crate) fn usage() {
4141 {:14}\t {:<20}
4242 {:14}\t {:<20}
4343 {:14}\t {:<20}
44+ {:14}\t {:<20}
4445" ,
4546 "--help" ,
4647 "show this page" ,
@@ -61,7 +62,9 @@ pub(crate) fn usage() {
6162 "-d,--debug" ,
6263 "run compiler in debug-mode" ,
6364 "-o" ,
64- "compiled output"
65+ "compiled output" ,
66+ "-v,--version" ,
67+ "compiler version"
6568 ) ;
6669}
6770
You can’t perform that action at this time.
0 commit comments