Skip to content

Commit

Permalink
options: Implement --version manually and print clang version on --ve…
Browse files Browse the repository at this point in the history
…rsion --verbose

Fixes #2138
  • Loading branch information
emilio committed Jun 5, 2022
1 parent aba2c29 commit 566d226
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ where
);

let matches = App::new("bindgen")
.version(option_env!("CARGO_PKG_VERSION").unwrap_or("unknown"))
.about("Generates Rust bindings from C/C++ headers.")
.setting(clap::AppSettings::NoAutoVersion)
.override_usage("bindgen [FLAGS] [OPTIONS] <header> -- <clang-args>...")
.args(&[
Arg::new("header")
.help("C or C++ header file")
.required(true),
.required_unless_present("V"),
Arg::new("depfile")
.long("depfile")
.takes_value(true)
Expand Down Expand Up @@ -545,9 +545,24 @@ where
Arg::new("vtable-generation")
.long("vtable-generation")
.help("Enables generation of vtable functions."),
Arg::new("V")
.long("version")
.help("Prints the version, and exits"),
]) // .args()
.get_matches_from(args);

let verbose = matches.is_present("verbose");
if matches.is_present("V") {
println!(
"bindgen {}",
option_env!("CARGO_PKG_VERSION").unwrap_or("unknown")
);
if verbose {
println!("Clang: {}", crate::clang_version().full);
}
std::process::exit(0);
}

let mut builder = builder();

if let Some(header) = matches.value_of("header") {
Expand Down Expand Up @@ -1015,7 +1030,5 @@ where
builder = builder.vtable_generation(true);
}

let verbose = matches.is_present("verbose");

Ok((builder, output, verbose))
}

0 comments on commit 566d226

Please sign in to comment.