Skip to content

Commit ef5385b

Browse files
committed
Clap *does* support the end of options marker!
1 parent d31c756 commit ef5385b

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

src/lib.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,6 @@ pub fn builder() -> Builder {
128128
pub fn builder_from_flags<I>(args: I) -> Result<Builder, io::Error>
129129
where I: Iterator<Item=String>
130130
{
131-
// clap doesn't support the end of options marker, --
132-
// https://github.com/kbknapp/clap-rs/issues/735
133-
let mut terminated = false;
134-
let (bindgen_args, clang_args): (Vec<_>, Vec<_>) = args.partition(|arg| {
135-
if terminated { // clang arg
136-
false
137-
} else if arg == "--" {
138-
terminated = true; // end of bindgen args, start of clang args
139-
false
140-
} else { // bindgen arg
141-
true
142-
}
143-
});
144-
145131
let matches = App::new("bindgen")
146132
.version(env!("CARGO_PKG_VERSION"))
147133
.about("Generates Rust bindings from C/C++ headers.")
@@ -170,6 +156,8 @@ pub fn builder_from_flags<I>(args: I) -> Result<Builder, io::Error>
170156
.help("Use the given prefix before raw types instead of ::std::os::raw.")
171157
.value_name("prefix")
172158
.takes_value(true),
159+
Arg::with_name("clang-args")
160+
.multiple(true),
173161
Arg::with_name("dummy-uses")
174162
.long("dummy-uses")
175163
.help("For testing purposes, generate a C/C++ file containing dummy uses of all types defined in the input header.")
@@ -246,7 +234,7 @@ pub fn builder_from_flags<I>(args: I) -> Result<Builder, io::Error>
246234
.takes_value(true)
247235
.multiple(true),
248236
]) // .args()
249-
.get_matches_from(bindgen_args);
237+
.get_matches_from(args);
250238

251239
let mut builder = builder();
252240

@@ -258,7 +246,7 @@ pub fn builder_from_flags<I>(args: I) -> Result<Builder, io::Error>
258246

259247
if let Some(bitfields) = matches.values_of("bitfield-enum") {
260248
for regex in bitfields {
261-
builder = builder.bitfield_enum(bitfields);
249+
builder = builder.bitfield_enum(regex);
262250
}
263251
}
264252

@@ -352,8 +340,10 @@ pub fn builder_from_flags<I>(args: I) -> Result<Builder, io::Error>
352340
}
353341
}
354342

355-
for arg in clang_args.into_iter().skip(1) {
356-
builder = builder.clang_arg(arg);
343+
if let Some(args) = matches.values_of("clang-args") {
344+
for arg in args {
345+
builder = builder.clang_arg(arg);
346+
}
357347
}
358348

359349
// FIXME: hrrrmmm

0 commit comments

Comments
 (0)