File tree 7 files changed +38
-3
lines changed
7 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,9 @@ struct BindgenCommand {
156
156
/// Mark FILE as hidden.
157
157
#[ arg( long, value_name = "FILE" ) ]
158
158
blocklist_file : Vec < String > ,
159
+ /// Mark VAR as hidden.
160
+ #[ arg( long, value_name = "VAR" ) ]
161
+ blocklist_var : Vec < String > ,
159
162
/// Avoid generating layout tests for any type.
160
163
#[ arg( long) ]
161
164
no_layout_tests : bool ,
@@ -471,6 +474,7 @@ where
471
474
blocklist_function,
472
475
blocklist_item,
473
476
blocklist_file,
477
+ blocklist_var,
474
478
no_layout_tests,
475
479
no_derive_copy,
476
480
no_derive_debug,
@@ -676,6 +680,10 @@ where
676
680
builder = builder. blocklist_file ( file) ;
677
681
}
678
682
683
+ for var in blocklist_var {
684
+ builder = builder. blocklist_var ( var) ;
685
+ }
686
+
679
687
if builtins {
680
688
builder = builder. emit_builtins ( ) ;
681
689
}
Original file line number Diff line number Diff line change
1
+ // bindgen-flags: --blocklist-var should_be_blocked
2
+
3
+ extern int should_be_blocked;
Original file line number Diff line number Diff line change @@ -668,8 +668,11 @@ impl Item {
668
668
ItemKind :: Function ( ..) => {
669
669
ctx. options ( ) . blocklisted_functions . matches ( & name)
670
670
}
671
- // TODO: Add constant / namespace blocklisting?
672
- ItemKind :: Var ( ..) | ItemKind :: Module ( ..) => false ,
671
+ ItemKind :: Var ( ..) => {
672
+ ctx. options ( ) . blocklisted_vars . matches ( & name)
673
+ }
674
+ // TODO: Add namespace blocklisting?
675
+ ItemKind :: Module ( ..) => false ,
673
676
}
674
677
}
675
678
Original file line number Diff line number Diff line change @@ -440,13 +440,14 @@ impl Builder {
440
440
441
441
impl BindgenOptions {
442
442
fn build ( & mut self ) {
443
- const REGEX_SETS_LEN : usize = 28 ;
443
+ const REGEX_SETS_LEN : usize = 29 ;
444
444
445
445
let regex_sets: [ _ ; REGEX_SETS_LEN ] = [
446
446
& mut self . blocklisted_types ,
447
447
& mut self . blocklisted_functions ,
448
448
& mut self . blocklisted_items ,
449
449
& mut self . blocklisted_files ,
450
+ & mut self . blocklisted_vars ,
450
451
& mut self . opaque_types ,
451
452
& mut self . allowlisted_vars ,
452
453
& mut self . allowlisted_types ,
@@ -483,6 +484,7 @@ impl BindgenOptions {
483
484
"--blocklist-function" ,
484
485
"--blocklist-item" ,
485
486
"--blocklist-file" ,
487
+ "--blocklist-var" ,
486
488
"--opaque-type" ,
487
489
"--allowlist-type" ,
488
490
"--allowlist-function" ,
Original file line number Diff line number Diff line change @@ -222,6 +222,22 @@ options! {
222
222
} ,
223
223
as_args: "--blocklist-file" ,
224
224
} ,
225
+ /// Variables that have been blocklisted and should not appear in the generated code.
226
+ blocklisted_vars: RegexSet {
227
+ methods: {
228
+ regex_option! {
229
+ /// Do not generate any bindings for the given variable.
230
+ ///
231
+ /// This option is not recursive, meaning that it will only block variables whose
232
+ /// names explicitly match the argument of this method.
233
+ pub fn blocklist_var<T : AsRef <str >>( mut self , arg: T ) -> Builder {
234
+ self . options. blocklisted_vars. insert( arg) ;
235
+ self
236
+ }
237
+ }
238
+ } ,
239
+ as_args: "--blocklist-var" ,
240
+ } ,
225
241
/// Types that should be treated as opaque structures in the generated code.
226
242
opaque_types: RegexSet {
227
243
methods: {
Original file line number Diff line number Diff line change @@ -22,13 +22,15 @@ that are transitively included.
22
22
* [ ` bindgen::Builder::blocklist_function ` ] ( https://docs.rs/bindgen/latest/bindgen/struct.Builder.html#method.blocklist_function )
23
23
* [ ` bindgen::Builder::blocklist_item ` ] ( https://docs.rs/bindgen/latest/bindgen/struct.Builder.html#method.blocklist_item )
24
24
* [ ` bindgen::Builder::blocklist_type ` ] ( https://docs.rs/bindgen/latest/bindgen/struct.Builder.html#method.blocklist_type )
25
+ * [ ` bindgen::Builder::blocklist_var ` ] ( https://docs.rs/bindgen/latest/bindgen/struct.Builder.html#method.blocklist_var )
25
26
26
27
### Command Line
27
28
28
29
* ` --blocklist-file <path> `
29
30
* ` --blocklist-function <function> `
30
31
* ` --blocklist-item <item> `
31
32
* ` --blocklist-type <type> `
33
+ * ` --blocklist-var <var> `
32
34
33
35
34
36
### Annotations
You can’t perform that action at this time.
0 commit comments