Skip to content

Commit f1c8bcc

Browse files
committed
issue 1723 [WIP]
1 parent 815eee9 commit f1c8bcc

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/lib.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,8 +1302,8 @@ impl Builder {
13021302
self
13031303
}
13041304

1305-
/// Generate the Rust bindings using the options built up thus far.
1306-
pub fn generate(mut self) -> Result<Bindings, ()> {
1305+
/// Generate the Rust bindings options
1306+
pub fn generate_options(&mut self) -> &mut Self {
13071307
// Add any extra arguments from the environment to the clang command line.
13081308
if let Some(extra_clang_args) =
13091309
env::var("BINDGEN_EXTRA_CLANG_ARGS").ok()
@@ -1331,31 +1331,27 @@ impl Builder {
13311331
clang::UnsavedFile::new(&name, &contents)
13321332
}),
13331333
);
1334-
1335-
Bindings::generate(self.options)
1334+
self
1335+
}
1336+
/// Generate the Rust bindings using the options built up thus far.
1337+
pub fn generate(mut self) -> Result<Bindings, ()> {
1338+
Bindings::generate(&Builder::generate_options(&mut self).options)
13361339
}
13371340

13381341
/// Preprocess and dump the input header files to disk.
13391342
///
13401343
/// This is useful when debugging bindgen, using C-Reduce, or when filing
13411344
/// issues. The resulting file will be named something like `__bindgen.i` or
13421345
/// `__bindgen.ii`
1343-
pub fn dump_preprocessed_input(&self) -> io::Result<()> {
1344-
fn check_is_cpp(name_file: &str) -> bool {
1345-
name_file.ends_with(".hpp") ||
1346-
name_file.ends_with(".hxx") ||
1347-
name_file.ends_with(".hh") ||
1348-
name_file.ends_with(".h++")
1349-
}
1350-
1346+
pub fn dump_preprocessed_input(&mut self) -> io::Result<()> {
13511347
let clang =
13521348
clang_sys::support::Clang::find(None, &[]).ok_or_else(|| {
13531349
io::Error::new(
13541350
io::ErrorKind::Other,
13551351
"Cannot find clang executable",
13561352
)
13571353
})?;
1358-
1354+
Builder::generate_options(self);
13591355
// The contents of a wrapper file that includes all the input header
13601356
// files.
13611357
let mut wrapper_contents = String::new();
@@ -2033,7 +2029,7 @@ impl Bindings {
20332029

20342030
/// Generate bindings for the given options.
20352031
pub(crate) fn generate(
2036-
mut options: BindgenOptions,
2032+
mut options: &BindgenOptions,
20372033
) -> Result<Bindings, ()> {
20382034
ensure_libclang_is_loaded();
20392035

0 commit comments

Comments
 (0)