@@ -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
+ vec ! [ 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 > {
@@ -1465,16 +1479,7 @@ impl Builder {
1465
1479
/// Generate the Rust bindings using the options built up thus far.
1466
1480
pub fn generate ( mut self ) -> Result < Bindings , BindgenError > {
1467
1481
// Add any extra arguments from the environment to the clang command line.
1468
- if let Some ( extra_clang_args) =
1469
- get_target_dependent_env_var ( "BINDGEN_EXTRA_CLANG_ARGS" )
1470
- {
1471
- // Try to parse it with shell quoting. If we fail, make it one single big argument.
1472
- if let Some ( strings) = shlex:: split ( & extra_clang_args) {
1473
- self . options . clang_args . extend ( strings) ;
1474
- } else {
1475
- self . options . clang_args . push ( extra_clang_args) ;
1476
- } ;
1477
- }
1482
+ self . options . clang_args . extend ( get_extra_clang_args ( ) ) ;
1478
1483
1479
1484
// Transform input headers to arguments on the clang command line.
1480
1485
self . options . input_header = self . input_headers . pop ( ) ;
@@ -1561,6 +1566,10 @@ impl Builder {
1561
1566
cmd. arg ( a) ;
1562
1567
}
1563
1568
1569
+ for a in get_extra_clang_args ( ) {
1570
+ cmd. arg ( a) ;
1571
+ }
1572
+
1564
1573
let mut child = cmd. spawn ( ) ?;
1565
1574
1566
1575
let mut preprocessed = child. stdout . take ( ) . unwrap ( ) ;
0 commit comments