Skip to content

Commit

Permalink
options: Add a --clang-version flag that prints the clang version and…
Browse files Browse the repository at this point in the history
… exits.

Fixes #2138
  • Loading branch information
emilio committed Dec 17, 2021
1 parent bcbd72d commit 3f72b80
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ where
.usage("bindgen [FLAGS] [OPTIONS] <header> -- <clang-args>...")
.args(&[
Arg::with_name("header")
.help("C or C++ header file")
.required(true),
.help("C or C++ header file"),
Arg::with_name("depfile")
.long("depfile")
.takes_value(true)
Expand Down Expand Up @@ -534,11 +533,19 @@ where
Arg::with_name("explicit-padding")
.long("explicit-padding")
.help("Always output explicit padding fields."),
Arg::with_name("clang-version")
.long("clang-version")
.help("Prints the clang version, and exits"),
]) // .args()
.get_matches_from(args);

let mut builder = builder();

if matches.is_present("clang-version") {
println!("{}", crate::clang_version().full);
std::process::exit(0);
}

if let Some(header) = matches.value_of("header") {
builder = builder.header(header);
} else {
Expand Down

0 comments on commit 3f72b80

Please sign in to comment.