Skip to content

Commit 1b05d08

Browse files
emiliokulp
authored andcommitted
options: Implement --version manually and print clang version on --version --verbose
Fixes rust-lang#2138
1 parent c27578f commit 1b05d08

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/options.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ where
2323
);
2424

2525
let matches = App::new("bindgen")
26-
.version(option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"))
2726
.about("Generates Rust bindings from C/C++ headers.")
2827
.override_usage("bindgen [FLAGS] [OPTIONS] <header> -- <clang-args>...")
2928
.args(&[
@@ -545,9 +544,22 @@ where
545544
Arg::new("vtable-generation")
546545
.long("vtable-generation")
547546
.help("Enables generation of vtable functions."),
547+
Arg::new("V")
548+
.long("version")
549+
.help("Prints the version, and exits"),
548550
]) // .args()
549551
.get_matches_from(args);
550552

553+
let verbose = matches.is_present("verbose");
554+
555+
if matches.is_present("V") {
556+
println!("bindgen {}", option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"));
557+
if verbose {
558+
println!("Clang version: {}", crate::clang_version().full);
559+
}
560+
std::process::exit(0);
561+
}
562+
551563
let mut builder = builder();
552564

553565
if let Some(header) = matches.value_of("header") {
@@ -1015,7 +1027,5 @@ where
10151027
builder = builder.vtable_generation(true);
10161028
}
10171029

1018-
let verbose = matches.is_present("verbose");
1019-
10201030
Ok((builder, output, verbose))
10211031
}

0 commit comments

Comments
 (0)