@@ -66,7 +66,7 @@ pub fn app() -> App<'static, 'static> {
66
66
// 'static, but we need to build the version string dynamically. We can
67
67
// fake the 'static lifetime with lazy_static.
68
68
lazy_static ! {
69
- static ref LONG_VERSION : String = long_version( None ) ;
69
+ static ref LONG_VERSION : String = long_version( None , true ) ;
70
70
}
71
71
72
72
let mut app = App :: new ( "ripgrep" )
@@ -91,30 +91,36 @@ pub fn app() -> App<'static, 'static> {
91
91
/// If a revision hash is given, then it is used. If one isn't given, then
92
92
/// the RIPGREP_BUILD_GIT_HASH env var is inspected for it. If that isn't set,
93
93
/// then a revision hash is not included in the version string returned.
94
- pub fn long_version ( revision_hash : Option < & str > ) -> String {
94
+ ///
95
+ /// If `cpu` is true, then the version string will include the compiled and
96
+ /// runtime CPU features.
97
+ pub fn long_version ( revision_hash : Option < & str > , cpu : bool ) -> String {
95
98
// Do we have a git hash?
96
99
// (Yes, if ripgrep was built on a machine with `git` installed.)
97
100
let hash = match revision_hash. or ( option_env ! ( "RIPGREP_BUILD_GIT_HASH" ) ) {
98
101
None => String :: new ( ) ,
99
102
Some ( githash) => format ! ( " (rev {})" , githash) ,
100
103
} ;
101
- // Put everything together.
102
- let runtime = runtime_cpu_features ( ) ;
103
- if runtime. is_empty ( ) {
104
- format ! (
105
- "{}{}\n {} (compiled)" ,
106
- crate_version!( ) ,
107
- hash,
108
- compile_cpu_features( ) . join( " " )
109
- )
104
+ if !cpu {
105
+ format ! ( "{}{}" , crate_version!( ) , hash, )
110
106
} else {
111
- format ! (
112
- "{}{}\n {} (compiled)\n {} (runtime)" ,
113
- crate_version!( ) ,
114
- hash,
115
- compile_cpu_features( ) . join( " " ) ,
116
- runtime. join( " " )
117
- )
107
+ let runtime = runtime_cpu_features ( ) ;
108
+ if runtime. is_empty ( ) {
109
+ format ! (
110
+ "{}{}\n {} (compiled)" ,
111
+ crate_version!( ) ,
112
+ hash,
113
+ compile_cpu_features( ) . join( " " )
114
+ )
115
+ } else {
116
+ format ! (
117
+ "{}{}\n {} (compiled)\n {} (runtime)" ,
118
+ crate_version!( ) ,
119
+ hash,
120
+ compile_cpu_features( ) . join( " " ) ,
121
+ runtime. join( " " )
122
+ )
123
+ }
118
124
}
119
125
}
120
126
0 commit comments