@@ -1302,8 +1302,8 @@ impl Builder {
1302
1302
self
1303
1303
}
1304
1304
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 {
1307
1307
// Add any extra arguments from the environment to the clang command line.
1308
1308
if let Some ( extra_clang_args) =
1309
1309
env:: var ( "BINDGEN_EXTRA_CLANG_ARGS" ) . ok ( )
@@ -1331,31 +1331,27 @@ impl Builder {
1331
1331
clang:: UnsavedFile :: new ( & name, & contents)
1332
1332
} ) ,
1333
1333
) ;
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 )
1336
1339
}
1337
1340
1338
1341
/// Preprocess and dump the input header files to disk.
1339
1342
///
1340
1343
/// This is useful when debugging bindgen, using C-Reduce, or when filing
1341
1344
/// issues. The resulting file will be named something like `__bindgen.i` or
1342
1345
/// `__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 < ( ) > {
1351
1347
let clang =
1352
1348
clang_sys:: support:: Clang :: find ( None , & [ ] ) . ok_or_else ( || {
1353
1349
io:: Error :: new (
1354
1350
io:: ErrorKind :: Other ,
1355
1351
"Cannot find clang executable" ,
1356
1352
)
1357
1353
} ) ?;
1358
-
1354
+ Builder :: generate_options ( self ) ;
1359
1355
// The contents of a wrapper file that includes all the input header
1360
1356
// files.
1361
1357
let mut wrapper_contents = String :: new ( ) ;
@@ -2033,7 +2029,7 @@ impl Bindings {
2033
2029
2034
2030
/// Generate bindings for the given options.
2035
2031
pub ( crate ) fn generate (
2036
- mut options : BindgenOptions ,
2032
+ mut options : & BindgenOptions ,
2037
2033
) -> Result < Bindings , ( ) > {
2038
2034
ensure_libclang_is_loaded ( ) ;
2039
2035
0 commit comments