@@ -232,6 +232,20 @@ pub fn builder() -> Builder {
232
232
Default :: default ( )
233
233
}
234
234
235
+ fn get_extra_clang_args ( ) -> Vec < String > {
236
+ // Add any extra arguments from the environment to the clang command line.
237
+ let extra_clang_args =
238
+ match get_target_dependent_env_var ( "BINDGEN_EXTRA_CLANG_ARGS" ) {
239
+ None => return vec ! [ ] ,
240
+ Some ( s) => s,
241
+ } ;
242
+ // Try to parse it with shell quoting. If we fail, make it one single big argument.
243
+ if let Some ( strings) = shlex:: split ( & extra_clang_args) {
244
+ return strings;
245
+ }
246
+ extra_clang_args
247
+ }
248
+
235
249
impl Builder {
236
250
/// Generates the command line flags use for creating `Builder`.
237
251
pub fn command_line_flags ( & self ) -> Vec < String > {
@@ -1453,16 +1467,7 @@ impl Builder {
1453
1467
/// Generate the Rust bindings using the options built up thus far.
1454
1468
pub fn generate ( mut self ) -> Result < Bindings , BindgenError > {
1455
1469
// Add any extra arguments from the environment to the clang command line.
1456
- if let Some ( extra_clang_args) =
1457
- get_target_dependent_env_var ( "BINDGEN_EXTRA_CLANG_ARGS" )
1458
- {
1459
- // Try to parse it with shell quoting. If we fail, make it one single big argument.
1460
- if let Some ( strings) = shlex:: split ( & extra_clang_args) {
1461
- self . options . clang_args . extend ( strings) ;
1462
- } else {
1463
- self . options . clang_args . push ( extra_clang_args) ;
1464
- } ;
1465
- }
1470
+ self . options . clang_args . extend ( get_extra_clang_args ( ) ) ;
1466
1471
1467
1472
// Transform input headers to arguments on the clang command line.
1468
1473
self . options . input_header = self . input_headers . pop ( ) ;
@@ -1549,6 +1554,10 @@ impl Builder {
1549
1554
cmd. arg ( a) ;
1550
1555
}
1551
1556
1557
+ for a in get_extra_clang_args ( ) {
1558
+ cmd. arg ( a) ;
1559
+ }
1560
+
1552
1561
let mut child = cmd. spawn ( ) ?;
1553
1562
1554
1563
let mut preprocessed = child. stdout . take ( ) . unwrap ( ) ;
0 commit comments