@@ -214,29 +214,33 @@ impl Builder {
214
214
} )
215
215
. count ( ) ;
216
216
217
- if self . options . derive_debug == false {
217
+ if !self . options . layout_tests {
218
+ output_vector. push ( "--no-layout-tests" . into ( ) ) ;
219
+ }
220
+
221
+ if !self . options . derive_debug {
218
222
output_vector. push ( "--no-derive-debug" . into ( ) ) ;
219
223
}
220
224
221
- if self . options . derive_default == false {
225
+ if ! self . options . derive_default {
222
226
output_vector. push ( "--no-derive-default" . into ( ) ) ;
223
227
} else {
224
228
output_vector. push ( "--with-derive-default" . into ( ) ) ;
225
229
}
226
230
227
- if self . options . generate_comments == false {
231
+ if ! self . options . generate_comments {
228
232
output_vector. push ( "--no-doc-comments" . into ( ) ) ;
229
233
}
230
234
231
- if self . options . whitelist_recursively == false {
235
+ if ! self . options . whitelist_recursively {
232
236
output_vector. push ( "--no-recursive-whitelist" . into ( ) ) ;
233
237
}
234
238
235
- if self . options . objc_extern_crate == true {
239
+ if self . options . objc_extern_crate {
236
240
output_vector. push ( "--objc-extern-crate" . into ( ) ) ;
237
241
}
238
242
239
- if self . options . builtins == true {
243
+ if self . options . builtins {
240
244
output_vector. push ( "--builtins" . into ( ) ) ;
241
245
}
242
246
@@ -259,21 +263,21 @@ impl Builder {
259
263
output_vector. push ( dummy. clone ( ) ) ;
260
264
}
261
265
262
- if self . options . emit_ast == true {
266
+ if self . options . emit_ast {
263
267
output_vector. push ( "--emit-clang-ast" . into ( ) ) ;
264
268
}
265
269
266
- if self . options . emit_ir == true {
270
+ if self . options . emit_ir {
267
271
output_vector. push ( "--emit-ir" . into ( ) ) ;
268
272
}
269
273
if let Some ( ref graph) = self . options . emit_ir_graphviz {
270
274
output_vector. push ( "--emit-ir-graphviz" . into ( ) ) ;
271
275
output_vector. push ( graph. clone ( ) )
272
276
}
273
- if self . options . enable_cxx_namespaces == true {
277
+ if self . options . enable_cxx_namespaces {
274
278
output_vector. push ( "--enable-cxx-namespaces" . into ( ) ) ;
275
279
}
276
- if self . options . disable_name_namespacing == true {
280
+ if self . options . disable_name_namespacing {
277
281
output_vector. push ( "--disable-name-namespacing" . into ( ) ) ;
278
282
}
279
283
@@ -286,36 +290,36 @@ impl Builder {
286
290
} )
287
291
. count ( ) ;
288
292
289
- if self . options . codegen_config . functions == false {
293
+ if ! self . options . codegen_config . functions {
290
294
output_vector. push ( "--ignore-functions" . into ( ) ) ;
291
295
}
292
296
293
297
output_vector. push ( "--generate" . into ( ) ) ;
294
298
295
299
//Temporary placeholder for below 4 options
296
300
let mut options: Vec < String > = Vec :: new ( ) ;
297
- if self . options . codegen_config . functions == true {
301
+ if self . options . codegen_config . functions {
298
302
options. push ( "function" . into ( ) ) ;
299
303
}
300
- if self . options . codegen_config . types == true {
304
+ if self . options . codegen_config . types {
301
305
options. push ( "types" . into ( ) ) ;
302
306
}
303
- if self . options . codegen_config . vars == true {
307
+ if self . options . codegen_config . vars {
304
308
options. push ( "vars" . into ( ) ) ;
305
309
}
306
- if self . options . codegen_config . methods == true {
310
+ if self . options . codegen_config . methods {
307
311
options. push ( "methods" . into ( ) ) ;
308
312
}
309
- if self . options . codegen_config . constructors == true {
313
+ if self . options . codegen_config . constructors {
310
314
options. push ( "constructors" . into ( ) ) ;
311
315
}
312
- if self . options . codegen_config . destructors == true {
316
+ if self . options . codegen_config . destructors {
313
317
options. push ( "destructors" . into ( ) ) ;
314
318
}
315
319
316
320
output_vector. push ( options. join ( "," ) ) ;
317
321
318
- if self . options . codegen_config . methods == false {
322
+ if ! self . options . codegen_config . methods {
319
323
output_vector. push ( "--ignore-methods" . into ( ) ) ;
320
324
}
321
325
@@ -328,15 +332,15 @@ impl Builder {
328
332
} )
329
333
. count ( ) ;
330
334
331
- if self . options . convert_floats == false {
335
+ if ! self . options . convert_floats {
332
336
output_vector. push ( "--no-convert-floats" . into ( ) ) ;
333
337
}
334
338
335
- if self . options . prepend_enum_name == false {
339
+ if ! self . options . prepend_enum_name {
336
340
output_vector. push ( "--no-prepend-enum-name" . into ( ) ) ;
337
341
}
338
342
339
- if self . options . unstable_rust == false {
343
+ if ! self . options . unstable_rust {
340
344
output_vector. push ( "--no-unstable-rust" . into ( ) ) ;
341
345
}
342
346
@@ -368,11 +372,11 @@ impl Builder {
368
372
} )
369
373
. count ( ) ;
370
374
371
- if self . options . use_core == true {
375
+ if self . options . use_core {
372
376
output_vector. push ( "--use-core" . into ( ) ) ;
373
377
}
374
378
375
- if self . options . conservative_inline_namespaces == true {
379
+ if self . options . conservative_inline_namespaces {
376
380
output_vector. push ( "--conservative-inline-namespaces" . into ( ) ) ;
377
381
}
378
382
@@ -582,6 +586,12 @@ impl Builder {
582
586
self
583
587
}
584
588
589
+ /// Set whether layout tests should be generated.
590
+ pub fn layout_tests ( mut self , doit : bool ) -> Self {
591
+ self . options . layout_tests = doit;
592
+ self
593
+ }
594
+
585
595
/// Set whether `Debug` should be derived by default.
586
596
pub fn derive_debug ( mut self , doit : bool ) -> Self {
587
597
self . options . derive_debug = doit;
@@ -785,11 +795,14 @@ pub struct BindgenOptions {
785
795
/// True if we should avoid mangling names with namespaces.
786
796
pub disable_name_namespacing : bool ,
787
797
788
- /// True if we shold derive Debug trait implementations for C/C++ structures
798
+ /// True if we should generate layout tests for generated structures.
799
+ pub layout_tests : bool ,
800
+
801
+ /// True if we should derive Debug trait implementations for C/C++ structures
789
802
/// and types.
790
803
pub derive_debug : bool ,
791
804
792
- /// True if we shold derive Default trait implementations for C/C++ structures
805
+ /// True if we should derive Default trait implementations for C/C++ structures
793
806
/// and types.
794
807
pub derive_default : bool ,
795
808
@@ -901,6 +914,7 @@ impl Default for BindgenOptions {
901
914
emit_ast : false ,
902
915
emit_ir : false ,
903
916
emit_ir_graphviz : None ,
917
+ layout_tests : true ,
904
918
derive_debug : true ,
905
919
derive_default : false ,
906
920
enable_cxx_namespaces : false ,
@@ -1237,4 +1251,4 @@ fn commandline_flag_unit_test_function() {
1237
1251
1238
1252
assert ! ( test_cases. iter( ) . all( |ref x| command_line_flags. contains( x) ) ) ;
1239
1253
1240
- }
1254
+ }
0 commit comments