Skip to content

Commit 909af7f

Browse files
committed
BINDGEN_EXTRA_CLANG_ARGS for command line mode issue-1723
1 parent 0f64106 commit 909af7f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/lib.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,8 +1435,8 @@ impl Builder {
14351435
self
14361436
}
14371437

1438-
/// Generate the Rust bindings using the options built up thus far.
1439-
pub fn generate(mut self) -> Result<Bindings, ()> {
1438+
/// Generate the Rust bindings options
1439+
pub fn generate_options(&mut self) -> &Self {
14401440
// Add any extra arguments from the environment to the clang command line.
14411441
if let Some(extra_clang_args) =
14421442
get_target_dependent_env_var("BINDGEN_EXTRA_CLANG_ARGS")
@@ -1451,7 +1451,7 @@ impl Builder {
14511451

14521452
// Transform input headers to arguments on the clang command line.
14531453
self.options.input_header = self.input_headers.pop();
1454-
self.options.extra_input_headers = self.input_headers;
1454+
self.options.extra_input_headers = self.input_headers.to_vec();
14551455
self.options.clang_args.extend(
14561456
self.options.extra_input_headers.iter().flat_map(|header| {
14571457
iter::once("-include".into())
@@ -1466,7 +1466,12 @@ impl Builder {
14661466
clang::UnsavedFile::new(&name, &contents)
14671467
}),
14681468
);
1469+
self
1470+
}
14691471

1472+
/// Generate the Rust bindings using the options built up thus far.
1473+
pub fn generate(mut self) -> Result<Bindings, ()> {
1474+
self.generate_options();
14701475
Bindings::generate(self.options)
14711476
}
14721477

@@ -1475,7 +1480,7 @@ impl Builder {
14751480
/// This is useful when debugging bindgen, using C-Reduce, or when filing
14761481
/// issues. The resulting file will be named something like `__bindgen.i` or
14771482
/// `__bindgen.ii`
1478-
pub fn dump_preprocessed_input(&self) -> io::Result<()> {
1483+
pub fn dump_preprocessed_input(&mut self) -> io::Result<()> {
14791484
let clang =
14801485
clang_sys::support::Clang::find(None, &[]).ok_or_else(|| {
14811486
io::Error::new(
@@ -1543,6 +1548,7 @@ impl Builder {
15431548
"__bindgen.i"
15441549
})?;
15451550
io::copy(&mut preprocessed, &mut file)?;
1551+
self.generate_options();
15461552

15471553
if child.wait()?.success() {
15481554
Ok(())

0 commit comments

Comments
 (0)