From 8270a0ca766ea834032daeb67c7f32a1947ab3bd Mon Sep 17 00:00:00 2001 From: Jeff Waugh Date: Tue, 15 Nov 2016 14:37:20 +1100 Subject: [PATCH 1/3] Transition to libbindgen sub-crate - The root crate is the `bindgen` binary - Rust-ify the test suite, no more subprocesses! - Update Travis config to test both crates --- .gitignore | 4 - .travis.yml | 7 +- CONTRIBUTING.md | 48 ++--- Cargo.toml | 42 +---- Makefile | 34 ---- libbindgen/Cargo.toml | 54 ++++++ build.rs => libbindgen/build.rs | 0 {src => libbindgen/src}/chooser.rs | 0 {src => libbindgen/src}/clang.rs | 0 {src => libbindgen/src}/clangll.rs | 0 {src => libbindgen/src}/codegen/helpers.rs | 0 {src => libbindgen/src}/codegen/mod.rs | 0 {src => libbindgen/src}/ir/annotations.rs | 0 {src => libbindgen/src}/ir/comp.rs | 0 {src => libbindgen/src}/ir/context.rs | 0 {src => libbindgen/src}/ir/enum_ty.rs | 0 {src => libbindgen/src}/ir/function.rs | 0 {src => libbindgen/src}/ir/int.rs | 0 {src => libbindgen/src}/ir/item.rs | 0 {src => libbindgen/src}/ir/item_kind.rs | 0 {src => libbindgen/src}/ir/layout.rs | 0 {src => libbindgen/src}/ir/mod.rs | 0 {src => libbindgen/src}/ir/module.rs | 0 {src => libbindgen/src}/ir/ty.rs | 0 {src => libbindgen/src}/ir/type_collector.rs | 0 {src => libbindgen/src}/ir/var.rs | 0 {src => libbindgen/src}/lib.rs | 3 - {src => libbindgen/src}/parse.rs | 0 {src => libbindgen/src}/regex_set.rs | 0 {src => libbindgen/src}/uses.rs | 0 .../tests}/expectations/Cargo.toml | 0 .../tests}/expectations/src/lib.rs | 0 .../tests}/expectations/tests/accessors.rs | 0 .../expectations/tests/annotation_hide.rs | 0 .../tests}/expectations/tests/anon_enum.rs | 0 .../expectations/tests/anon_enum_whitelist.rs | 0 .../tests}/expectations/tests/anon_union.rs | 0 .../tests}/expectations/tests/arg_keyword.rs | 0 .../expectations/tests/base-to-derived.rs | 0 .../expectations/tests/bitfield-enum-basic.rs | 0 .../tests}/expectations/tests/blocks.rs | 0 .../tests}/expectations/tests/class.rs | 0 .../tests}/expectations/tests/class_nested.rs | 0 .../expectations/tests/class_no_members.rs | 0 .../tests}/expectations/tests/class_static.rs | 0 .../expectations/tests/class_static_const.rs | 0 .../tests}/expectations/tests/class_use_as.rs | 0 .../expectations/tests/class_with_dtor.rs | 0 .../tests/class_with_inner_struct.rs | 0 .../expectations/tests/class_with_typedef.rs | 0 .../tests}/expectations/tests/complex.rs | 0 .../expectations/tests/complex_global.rs | 0 .../expectations/tests/const_enum_unnamed.rs | 0 .../tests}/expectations/tests/const_ptr.rs | 0 .../expectations/tests/const_resolved_ty.rs | 0 .../tests}/expectations/tests/const_tparam.rs | 0 .../expectations/tests/convert-floats.rs | 0 .../tests}/expectations/tests/crtp.rs | 0 .../tests/decl_extern_int_twice.rs | 0 .../expectations/tests/decl_ptr_to_array.rs | 0 .../tests/duplicated_constants_in_ns.rs | 0 .../tests}/expectations/tests/elaborated.rs | 0 .../tests/empty_template_param_name.rs | 0 .../tests}/expectations/tests/enum.rs | 0 .../tests}/expectations/tests/enum_alias.rs | 0 .../tests/enum_and_vtable_mangling.rs | 0 .../tests}/expectations/tests/enum_dupe.rs | 0 .../expectations/tests/enum_explicit_type.rs | 0 .../expectations/tests/enum_negative.rs | 0 .../tests}/expectations/tests/enum_packed.rs | 0 .../tests}/expectations/tests/extern.rs | 0 .../tests}/expectations/tests/float128.rs | 0 .../forward-inherit-struct-with-fields.rs | 0 .../tests/forward-inherit-struct.rs | 0 .../tests/forward_declared_struct.rs | 0 .../tests}/expectations/tests/func_proto.rs | 0 .../tests}/expectations/tests/func_ptr.rs | 0 .../expectations/tests/func_ptr_in_struct.rs | 0 .../expectations/tests/func_with_array_arg.rs | 0 .../tests/func_with_func_ptr_arg.rs | 0 .../expectations/tests/in_class_typedef.rs | 0 .../expectations/tests/inherit-namespaced.rs | 0 .../expectations/tests/inherit_named.rs | 0 .../expectations/tests/inherit_typedef.rs | 0 .../tests}/expectations/tests/inner_const.rs | 0 .../expectations/tests/inner_template_self.rs | 0 .../tests}/expectations/tests/int128_t.rs | 0 .../expectations/tests/jsval_layout_opaque.rs | 0 .../tests}/expectations/tests/keywords.rs | 0 .../expectations/tests/macro-expr-basic.rs | 0 .../tests}/expectations/tests/macro-redef.rs | 0 .../multiple-inherit-empty-correct-layout.rs | 0 .../tests}/expectations/tests/mutable.rs | 0 .../tests}/expectations/tests/namespace.rs | 0 .../tests}/expectations/tests/nested.rs | 0 .../expectations/tests/nested_vtable.rs | 0 .../tests}/expectations/tests/no-std.rs | 0 .../tests}/expectations/tests/no_copy.rs | 0 .../expectations/tests/nsStyleAutoArray.rs | 0 .../expectations/tests/only_bitfields.rs | 0 .../expectations/tests/opaque_in_struct.rs | 0 .../expectations/tests/opaque_pointer.rs | 0 .../expectations/tests/opaque_typedef.rs | 0 .../expectations/tests/overflowed_enum.rs | 0 .../tests}/expectations/tests/overloading.rs | 0 .../tests}/expectations/tests/private.rs | 0 .../expectations/tests/redeclaration.rs | 0 .../expectations/tests/ref_argument_array.rs | 0 .../tests/replace_template_alias.rs | 0 .../expectations/tests/replaces_double.rs | 0 .../expectations/tests/size_t_template.rs | 0 ...ruct_containing_forward_declared_struct.rs | 0 .../tests/struct_with_anon_struct.rs | 0 .../tests/struct_with_anon_struct_array.rs | 0 .../tests/struct_with_anon_struct_pointer.rs | 0 .../tests/struct_with_anon_union.rs | 0 .../tests/struct_with_anon_unnamed_struct.rs | 0 .../tests/struct_with_anon_unnamed_union.rs | 0 .../tests/struct_with_bitfields.rs | 0 .../tests/struct_with_derive_debug.rs | 0 .../expectations/tests/struct_with_nesting.rs | 0 .../expectations/tests/struct_with_packing.rs | 0 .../expectations/tests/struct_with_struct.rs | 0 .../tests/struct_with_typedef_template_arg.rs | 0 .../tests}/expectations/tests/template.rs | 0 .../expectations/tests/template_alias.rs | 0 .../tests/template_alias_basic.rs | 0 .../tests/template_alias_namespace.rs | 0 .../template_typedef_transitive_param.rs | 0 .../expectations/tests/template_typedefs.rs | 0 .../expectations/tests/type_alias_empty.rs | 0 .../tests}/expectations/tests/typeref.rs | 0 .../tests}/expectations/tests/union_dtor.rs | 0 .../tests}/expectations/tests/union_fields.rs | 0 .../expectations/tests/union_template.rs | 0 .../tests/union_with_anon_struct.rs | 0 .../tests/union_with_anon_struct_bitfield.rs | 0 .../tests/union_with_anon_union.rs | 0 .../tests/union_with_anon_unnamed_struct.rs | 0 .../tests/union_with_anon_unnamed_union.rs | 0 .../tests/union_with_big_member.rs | 0 .../expectations/tests/union_with_nesting.rs | 0 .../tests}/expectations/tests/unknown_attr.rs | 0 .../tests}/expectations/tests/use-core.rs | 0 .../tests}/expectations/tests/using.rs | 0 .../tests}/expectations/tests/vector.rs | 0 .../tests}/expectations/tests/virtual_dtor.rs | 0 .../expectations/tests/virtual_overloaded.rs | 0 .../tests/vtable_recursive_sig.rs | 0 .../expectations/tests/weird_bitfields.rs | 0 .../expectations/tests/what_is_going_on.rs | 0 .../expectations/tests/whitelist_basic.rs | 0 .../expectations/tests/whitelist_vars.rs | 0 .../tests}/headers/accessors.hpp | 0 .../tests}/headers/annotation_hide.hpp | 0 .../tests}/headers/anon_enum.hpp | 0 .../tests}/headers/anon_enum_whitelist.h | 0 .../tests}/headers/anon_union.hpp | 0 .../tests}/headers/arg_keyword.hpp | 0 .../tests}/headers/base-to-derived.hpp | 0 .../tests}/headers/bitfield-enum-basic.h | 0 {tests => libbindgen/tests}/headers/blocks.h | 0 {tests => libbindgen/tests}/headers/class.hpp | 0 .../tests}/headers/class_nested.hpp | 0 .../tests}/headers/class_no_members.hpp | 0 .../tests}/headers/class_static.hpp | 0 .../tests}/headers/class_static_const.hpp | 0 .../tests}/headers/class_use_as.hpp | 0 .../tests}/headers/class_with_dtor.hpp | 0 .../headers/class_with_inner_struct.hpp | 0 .../tests}/headers/class_with_typedef.hpp | 0 {tests => libbindgen/tests}/headers/complex.h | 0 .../tests}/headers/complex_global.h | 0 .../tests}/headers/const_enum_unnamed.hpp | 0 .../tests}/headers/const_ptr.hpp | 0 .../tests}/headers/const_resolved_ty.h | 0 .../tests}/headers/const_tparam.hpp | 0 .../tests}/headers/convert-floats.h | 0 {tests => libbindgen/tests}/headers/crtp.hpp | 0 .../tests}/headers/decl_extern_int_twice.h | 0 .../tests}/headers/decl_ptr_to_array.h | 0 .../headers/duplicated_constants_in_ns.hpp | 0 .../tests}/headers/elaborated.hpp | 0 .../headers/empty_template_param_name.hpp | 0 {tests => libbindgen/tests}/headers/enum.h | 0 .../tests}/headers/enum_alias.hpp | 0 .../headers/enum_and_vtable_mangling.hpp | 0 .../tests}/headers/enum_dupe.h | 0 .../tests}/headers/enum_explicit_type.hpp | 0 .../tests}/headers/enum_negative.h | 0 .../tests}/headers/enum_packed.h | 0 .../tests}/headers/extern.hpp | 0 .../tests}/headers/float128.hpp | 0 .../forward-inherit-struct-with-fields.hpp | 0 .../tests}/headers/forward-inherit-struct.hpp | 0 .../tests}/headers/forward_declared_struct.h | 0 .../tests}/headers/func_proto.h | 0 .../tests}/headers/func_ptr.h | 0 .../tests}/headers/func_ptr_in_struct.h | 0 .../tests}/headers/func_with_array_arg.h | 0 .../tests}/headers/func_with_func_ptr_arg.h | 0 .../tests}/headers/in_class_typedef.hpp | 0 .../tests}/headers/inherit-namespaced.hpp | 0 .../tests}/headers/inherit_named.hpp | 0 .../tests}/headers/inherit_typedef.hpp | 0 .../tests}/headers/inner_const.hpp | 0 .../tests}/headers/inner_template_self.hpp | 0 .../tests}/headers/int128_t.h | 0 .../tests}/headers/jsval_layout_opaque.hpp | 0 .../tests}/headers/keywords.h | 0 .../tests}/headers/macro-expr-basic.h | 0 .../tests}/headers/macro-redef.h | 0 .../multiple-inherit-empty-correct-layout.hpp | 0 .../tests}/headers/mutable.hpp | 0 .../tests}/headers/namespace.hpp | 0 .../tests}/headers/nested.hpp | 0 .../tests}/headers/nested_vtable.hpp | 0 {tests => libbindgen/tests}/headers/no-std.h | 0 .../tests}/headers/no_copy.hpp | 0 .../tests}/headers/nsStyleAutoArray.hpp | 0 .../tests}/headers/only_bitfields.hpp | 0 .../tests}/headers/opaque_in_struct.hpp | 0 .../tests}/headers/opaque_pointer.hpp | 0 .../tests}/headers/opaque_typedef.hpp | 0 .../tests}/headers/overflowed_enum.hpp | 0 .../tests}/headers/overloading.hpp | 0 .../tests}/headers/private.hpp | 0 .../tests}/headers/redeclaration.hpp | 0 .../tests}/headers/ref_argument_array.hpp | 0 .../tests}/headers/replace_template_alias.hpp | 0 .../tests}/headers/replaces_double.hpp | 0 .../tests}/headers/size_t_template.hpp | 0 ...truct_containing_forward_declared_struct.h | 0 .../tests}/headers/struct_with_anon_struct.h | 0 .../headers/struct_with_anon_struct_array.h | 0 .../headers/struct_with_anon_struct_pointer.h | 0 .../tests}/headers/struct_with_anon_union.h | 0 .../headers/struct_with_anon_unnamed_struct.h | 0 .../headers/struct_with_anon_unnamed_union.h | 0 .../tests}/headers/struct_with_bitfields.h | 0 .../tests}/headers/struct_with_derive_debug.h | 0 .../tests}/headers/struct_with_nesting.h | 0 .../tests}/headers/struct_with_packing.h | 0 .../tests}/headers/struct_with_struct.h | 0 .../struct_with_typedef_template_arg.hpp | 0 .../tests}/headers/template.hpp | 0 .../tests}/headers/template_alias.hpp | 0 .../tests}/headers/template_alias_basic.hpp | 0 .../headers/template_alias_namespace.hpp | 0 .../template_typedef_transitive_param.hpp | 0 .../tests}/headers/template_typedefs.hpp | 0 .../tests}/headers/type_alias_empty.hpp | 0 .../tests}/headers/typeref.hpp | 0 .../tests}/headers/union_dtor.hpp | 0 .../tests}/headers/union_fields.hpp | 0 .../tests}/headers/union_template.hpp | 0 .../tests}/headers/union_with_anon_struct.h | 0 .../headers/union_with_anon_struct_bitfield.h | 0 .../tests}/headers/union_with_anon_union.h | 0 .../headers/union_with_anon_unnamed_struct.h | 0 .../headers/union_with_anon_unnamed_union.h | 0 .../tests}/headers/union_with_big_member.h | 0 .../tests}/headers/union_with_nesting.h | 0 .../tests}/headers/unknown_attr.h | 0 .../tests}/headers/use-core.h | 0 {tests => libbindgen/tests}/headers/using.hpp | 0 .../tests}/headers/vector.hpp | 0 .../tests}/headers/virtual_dtor.hpp | 0 .../tests}/headers/virtual_overloaded.hpp | 0 .../tests}/headers/vtable_recursive_sig.hpp | 0 .../tests}/headers/weird_bitfields.hpp | 0 .../tests}/headers/what_is_going_on.hpp | 0 .../tests}/headers/whitelist_basic.hpp | 0 .../tests}/headers/whitelist_vars.h | 0 libbindgen/tests/tests.rs | 138 ++++++++++++++ {tests => libbindgen/tests}/uses/.gitignore | 0 src/{bin/bindgen.rs => main.rs} | 7 +- src/{bin => }/options.rs | 5 +- tests/tests.rs | 171 ----------------- tests/tools/run-bindgen.py | 175 ------------------ 280 files changed, 216 insertions(+), 472 deletions(-) delete mode 100644 Makefile create mode 100644 libbindgen/Cargo.toml rename build.rs => libbindgen/build.rs (100%) rename {src => libbindgen/src}/chooser.rs (100%) rename {src => libbindgen/src}/clang.rs (100%) mode change 100755 => 100644 rename {src => libbindgen/src}/clangll.rs (100%) rename {src => libbindgen/src}/codegen/helpers.rs (100%) rename {src => libbindgen/src}/codegen/mod.rs (100%) mode change 100755 => 100644 rename {src => libbindgen/src}/ir/annotations.rs (100%) rename {src => libbindgen/src}/ir/comp.rs (100%) rename {src => libbindgen/src}/ir/context.rs (100%) rename {src => libbindgen/src}/ir/enum_ty.rs (100%) rename {src => libbindgen/src}/ir/function.rs (100%) rename {src => libbindgen/src}/ir/int.rs (100%) rename {src => libbindgen/src}/ir/item.rs (100%) rename {src => libbindgen/src}/ir/item_kind.rs (100%) rename {src => libbindgen/src}/ir/layout.rs (100%) rename {src => libbindgen/src}/ir/mod.rs (100%) rename {src => libbindgen/src}/ir/module.rs (100%) rename {src => libbindgen/src}/ir/ty.rs (100%) rename {src => libbindgen/src}/ir/type_collector.rs (100%) rename {src => libbindgen/src}/ir/var.rs (100%) rename {src => libbindgen/src}/lib.rs (99%) mode change 100755 => 100644 rename {src => libbindgen/src}/parse.rs (100%) rename {src => libbindgen/src}/regex_set.rs (100%) rename {src => libbindgen/src}/uses.rs (100%) rename {tests => libbindgen/tests}/expectations/Cargo.toml (100%) rename {tests => libbindgen/tests}/expectations/src/lib.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/accessors.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/annotation_hide.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/anon_enum.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/anon_enum_whitelist.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/anon_union.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/arg_keyword.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/base-to-derived.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/bitfield-enum-basic.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/blocks.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/class.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/class_nested.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/class_no_members.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/class_static.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/class_static_const.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/class_use_as.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/class_with_dtor.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/class_with_inner_struct.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/class_with_typedef.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/complex.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/complex_global.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/const_enum_unnamed.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/const_ptr.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/const_resolved_ty.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/const_tparam.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/convert-floats.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/crtp.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/decl_extern_int_twice.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/decl_ptr_to_array.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/duplicated_constants_in_ns.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/elaborated.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/empty_template_param_name.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/enum.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/enum_alias.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/enum_and_vtable_mangling.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/enum_dupe.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/enum_explicit_type.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/enum_negative.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/enum_packed.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/extern.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/float128.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/forward-inherit-struct-with-fields.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/forward-inherit-struct.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/forward_declared_struct.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/func_proto.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/func_ptr.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/func_ptr_in_struct.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/func_with_array_arg.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/func_with_func_ptr_arg.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/in_class_typedef.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/inherit-namespaced.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/inherit_named.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/inherit_typedef.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/inner_const.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/inner_template_self.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/int128_t.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/jsval_layout_opaque.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/keywords.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/macro-expr-basic.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/macro-redef.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/multiple-inherit-empty-correct-layout.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/mutable.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/namespace.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/nested.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/nested_vtable.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/no-std.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/no_copy.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/nsStyleAutoArray.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/only_bitfields.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/opaque_in_struct.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/opaque_pointer.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/opaque_typedef.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/overflowed_enum.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/overloading.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/private.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/redeclaration.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/ref_argument_array.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/replace_template_alias.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/replaces_double.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/size_t_template.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/struct_containing_forward_declared_struct.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/struct_with_anon_struct.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/struct_with_anon_struct_array.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/struct_with_anon_struct_pointer.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/struct_with_anon_union.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/struct_with_anon_unnamed_struct.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/struct_with_anon_unnamed_union.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/struct_with_bitfields.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/struct_with_derive_debug.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/struct_with_nesting.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/struct_with_packing.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/struct_with_struct.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/struct_with_typedef_template_arg.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/template.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/template_alias.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/template_alias_basic.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/template_alias_namespace.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/template_typedef_transitive_param.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/template_typedefs.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/type_alias_empty.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/typeref.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/union_dtor.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/union_fields.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/union_template.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/union_with_anon_struct.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/union_with_anon_struct_bitfield.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/union_with_anon_union.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/union_with_anon_unnamed_struct.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/union_with_anon_unnamed_union.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/union_with_big_member.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/union_with_nesting.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/unknown_attr.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/use-core.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/using.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/vector.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/virtual_dtor.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/virtual_overloaded.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/vtable_recursive_sig.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/weird_bitfields.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/what_is_going_on.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/whitelist_basic.rs (100%) rename {tests => libbindgen/tests}/expectations/tests/whitelist_vars.rs (100%) rename {tests => libbindgen/tests}/headers/accessors.hpp (100%) rename {tests => libbindgen/tests}/headers/annotation_hide.hpp (100%) rename {tests => libbindgen/tests}/headers/anon_enum.hpp (100%) rename {tests => libbindgen/tests}/headers/anon_enum_whitelist.h (100%) rename {tests => libbindgen/tests}/headers/anon_union.hpp (100%) rename {tests => libbindgen/tests}/headers/arg_keyword.hpp (100%) rename {tests => libbindgen/tests}/headers/base-to-derived.hpp (100%) rename {tests => libbindgen/tests}/headers/bitfield-enum-basic.h (100%) rename {tests => libbindgen/tests}/headers/blocks.h (100%) rename {tests => libbindgen/tests}/headers/class.hpp (100%) rename {tests => libbindgen/tests}/headers/class_nested.hpp (100%) rename {tests => libbindgen/tests}/headers/class_no_members.hpp (100%) rename {tests => libbindgen/tests}/headers/class_static.hpp (100%) rename {tests => libbindgen/tests}/headers/class_static_const.hpp (100%) rename {tests => libbindgen/tests}/headers/class_use_as.hpp (100%) rename {tests => libbindgen/tests}/headers/class_with_dtor.hpp (100%) rename {tests => libbindgen/tests}/headers/class_with_inner_struct.hpp (100%) rename {tests => libbindgen/tests}/headers/class_with_typedef.hpp (100%) rename {tests => libbindgen/tests}/headers/complex.h (100%) rename {tests => libbindgen/tests}/headers/complex_global.h (100%) rename {tests => libbindgen/tests}/headers/const_enum_unnamed.hpp (100%) rename {tests => libbindgen/tests}/headers/const_ptr.hpp (100%) rename {tests => libbindgen/tests}/headers/const_resolved_ty.h (100%) rename {tests => libbindgen/tests}/headers/const_tparam.hpp (100%) rename {tests => libbindgen/tests}/headers/convert-floats.h (100%) rename {tests => libbindgen/tests}/headers/crtp.hpp (100%) rename {tests => libbindgen/tests}/headers/decl_extern_int_twice.h (100%) rename {tests => libbindgen/tests}/headers/decl_ptr_to_array.h (100%) rename {tests => libbindgen/tests}/headers/duplicated_constants_in_ns.hpp (100%) rename {tests => libbindgen/tests}/headers/elaborated.hpp (100%) rename {tests => libbindgen/tests}/headers/empty_template_param_name.hpp (100%) rename {tests => libbindgen/tests}/headers/enum.h (100%) rename {tests => libbindgen/tests}/headers/enum_alias.hpp (100%) rename {tests => libbindgen/tests}/headers/enum_and_vtable_mangling.hpp (100%) rename {tests => libbindgen/tests}/headers/enum_dupe.h (100%) rename {tests => libbindgen/tests}/headers/enum_explicit_type.hpp (100%) rename {tests => libbindgen/tests}/headers/enum_negative.h (100%) rename {tests => libbindgen/tests}/headers/enum_packed.h (100%) rename {tests => libbindgen/tests}/headers/extern.hpp (100%) rename {tests => libbindgen/tests}/headers/float128.hpp (100%) rename {tests => libbindgen/tests}/headers/forward-inherit-struct-with-fields.hpp (100%) rename {tests => libbindgen/tests}/headers/forward-inherit-struct.hpp (100%) rename {tests => libbindgen/tests}/headers/forward_declared_struct.h (100%) rename {tests => libbindgen/tests}/headers/func_proto.h (100%) rename {tests => libbindgen/tests}/headers/func_ptr.h (100%) rename {tests => libbindgen/tests}/headers/func_ptr_in_struct.h (100%) rename {tests => libbindgen/tests}/headers/func_with_array_arg.h (100%) rename {tests => libbindgen/tests}/headers/func_with_func_ptr_arg.h (100%) rename {tests => libbindgen/tests}/headers/in_class_typedef.hpp (100%) rename {tests => libbindgen/tests}/headers/inherit-namespaced.hpp (100%) rename {tests => libbindgen/tests}/headers/inherit_named.hpp (100%) rename {tests => libbindgen/tests}/headers/inherit_typedef.hpp (100%) rename {tests => libbindgen/tests}/headers/inner_const.hpp (100%) rename {tests => libbindgen/tests}/headers/inner_template_self.hpp (100%) rename {tests => libbindgen/tests}/headers/int128_t.h (100%) rename {tests => libbindgen/tests}/headers/jsval_layout_opaque.hpp (100%) rename {tests => libbindgen/tests}/headers/keywords.h (100%) rename {tests => libbindgen/tests}/headers/macro-expr-basic.h (100%) rename {tests => libbindgen/tests}/headers/macro-redef.h (100%) rename {tests => libbindgen/tests}/headers/multiple-inherit-empty-correct-layout.hpp (100%) rename {tests => libbindgen/tests}/headers/mutable.hpp (100%) rename {tests => libbindgen/tests}/headers/namespace.hpp (100%) rename {tests => libbindgen/tests}/headers/nested.hpp (100%) rename {tests => libbindgen/tests}/headers/nested_vtable.hpp (100%) rename {tests => libbindgen/tests}/headers/no-std.h (100%) rename {tests => libbindgen/tests}/headers/no_copy.hpp (100%) rename {tests => libbindgen/tests}/headers/nsStyleAutoArray.hpp (100%) rename {tests => libbindgen/tests}/headers/only_bitfields.hpp (100%) rename {tests => libbindgen/tests}/headers/opaque_in_struct.hpp (100%) rename {tests => libbindgen/tests}/headers/opaque_pointer.hpp (100%) rename {tests => libbindgen/tests}/headers/opaque_typedef.hpp (100%) rename {tests => libbindgen/tests}/headers/overflowed_enum.hpp (100%) rename {tests => libbindgen/tests}/headers/overloading.hpp (100%) rename {tests => libbindgen/tests}/headers/private.hpp (100%) rename {tests => libbindgen/tests}/headers/redeclaration.hpp (100%) rename {tests => libbindgen/tests}/headers/ref_argument_array.hpp (100%) rename {tests => libbindgen/tests}/headers/replace_template_alias.hpp (100%) rename {tests => libbindgen/tests}/headers/replaces_double.hpp (100%) rename {tests => libbindgen/tests}/headers/size_t_template.hpp (100%) rename {tests => libbindgen/tests}/headers/struct_containing_forward_declared_struct.h (100%) rename {tests => libbindgen/tests}/headers/struct_with_anon_struct.h (100%) rename {tests => libbindgen/tests}/headers/struct_with_anon_struct_array.h (100%) rename {tests => libbindgen/tests}/headers/struct_with_anon_struct_pointer.h (100%) rename {tests => libbindgen/tests}/headers/struct_with_anon_union.h (100%) rename {tests => libbindgen/tests}/headers/struct_with_anon_unnamed_struct.h (100%) rename {tests => libbindgen/tests}/headers/struct_with_anon_unnamed_union.h (100%) rename {tests => libbindgen/tests}/headers/struct_with_bitfields.h (100%) rename {tests => libbindgen/tests}/headers/struct_with_derive_debug.h (100%) rename {tests => libbindgen/tests}/headers/struct_with_nesting.h (100%) rename {tests => libbindgen/tests}/headers/struct_with_packing.h (100%) rename {tests => libbindgen/tests}/headers/struct_with_struct.h (100%) rename {tests => libbindgen/tests}/headers/struct_with_typedef_template_arg.hpp (100%) rename {tests => libbindgen/tests}/headers/template.hpp (100%) rename {tests => libbindgen/tests}/headers/template_alias.hpp (100%) rename {tests => libbindgen/tests}/headers/template_alias_basic.hpp (100%) rename {tests => libbindgen/tests}/headers/template_alias_namespace.hpp (100%) rename {tests => libbindgen/tests}/headers/template_typedef_transitive_param.hpp (100%) rename {tests => libbindgen/tests}/headers/template_typedefs.hpp (100%) rename {tests => libbindgen/tests}/headers/type_alias_empty.hpp (100%) rename {tests => libbindgen/tests}/headers/typeref.hpp (100%) rename {tests => libbindgen/tests}/headers/union_dtor.hpp (100%) rename {tests => libbindgen/tests}/headers/union_fields.hpp (100%) rename {tests => libbindgen/tests}/headers/union_template.hpp (100%) rename {tests => libbindgen/tests}/headers/union_with_anon_struct.h (100%) rename {tests => libbindgen/tests}/headers/union_with_anon_struct_bitfield.h (100%) rename {tests => libbindgen/tests}/headers/union_with_anon_union.h (100%) rename {tests => libbindgen/tests}/headers/union_with_anon_unnamed_struct.h (100%) rename {tests => libbindgen/tests}/headers/union_with_anon_unnamed_union.h (100%) rename {tests => libbindgen/tests}/headers/union_with_big_member.h (100%) rename {tests => libbindgen/tests}/headers/union_with_nesting.h (100%) rename {tests => libbindgen/tests}/headers/unknown_attr.h (100%) rename {tests => libbindgen/tests}/headers/use-core.h (100%) rename {tests => libbindgen/tests}/headers/using.hpp (100%) rename {tests => libbindgen/tests}/headers/vector.hpp (100%) rename {tests => libbindgen/tests}/headers/virtual_dtor.hpp (100%) rename {tests => libbindgen/tests}/headers/virtual_overloaded.hpp (100%) rename {tests => libbindgen/tests}/headers/vtable_recursive_sig.hpp (100%) rename {tests => libbindgen/tests}/headers/weird_bitfields.hpp (100%) rename {tests => libbindgen/tests}/headers/what_is_going_on.hpp (100%) rename {tests => libbindgen/tests}/headers/whitelist_basic.hpp (100%) rename {tests => libbindgen/tests}/headers/whitelist_vars.h (100%) create mode 100644 libbindgen/tests/tests.rs rename {tests => libbindgen/tests}/uses/.gitignore (100%) rename src/{bin/bindgen.rs => main.rs} (96%) mode change 100755 => 100644 rename src/{bin => }/options.rs (99%) delete mode 100644 tests/tests.rs delete mode 100755 tests/tools/run-bindgen.py diff --git a/.gitignore b/.gitignore index f54aca9873..049fbc4aa6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,5 @@ -bindgen -libbindgen* - # Cargo target/ Cargo.lock *~ #*# - diff --git a/.travis.yml b/.travis.yml index 467c42dca7..48f0b4b1a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,16 +24,19 @@ cache: before_install: . ./ci/before_install.sh +before_script: cd libbindgen + script: - - cargo build --verbose --features "$BINDGEN_FEATURES" - cargo test --features "$BINDGEN_FEATURES" - - cargo build --release --verbose --features "$BINDGEN_FEATURES" - cargo test --release --features "$BINDGEN_FEATURES" - git add -A - git diff @ - git diff-index --quiet HEAD - cargo test -p tests_expectations - cargo build --features "$BINDGEN_FEATURES _docs" + - cd .. + - cargo test --features "$BINDGEN_FEATURES" + - cargo test --release --features "$BINDGEN_FEATURES" notifications: webhooks: http://build.servo.org:54856/travis diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ce95e21cf8..bab631d653 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,20 +42,22 @@ that you aren't forgetting to document types and functions. CI will catch it if you forget, but the turn around will be a lot slower ;) ``` -$ cargo build --features "llvm_stable _docs" +$ cd libbindgen && cargo build --features "llvm_stable _docs" ``` ## Testing +Code for binding generation and testing thereof is in the `libbindgen` crate. +The following sections assume you are working in that subdirectory. + ### Overview -Input C/C++ test headers reside in the `tests/headers` directory. The expected -output rust bindings live in `tests/expectations/tests`; for example, -`tests/headers/my_header.h`'s expected generated rust bindings would be +Input C/C++ test headers reside in the `tests/headers` directory. Expected +output Rust bindings live in `tests/expectations/tests`. For example, +`tests/headers/my_header.h`'s expected generated Rust bindings would be `tests/expectations/tests/my_header.rs`. -The `tests/tools/run-bindgen.py` script runs `bindgen` on the test headers and -compares the results to the expectations. +Run `cargo test` to compare generated Rust bindings to the expectations. ### Running All Tests @@ -63,25 +65,11 @@ compares the results to the expectations. $ cargo test [--features llvm_stable] ``` -This spawns a `tests/tools/run-bindgen.py` subprocess for each test header. - -### Running a Single, Specific Test - -``` -$ ./tests/tools/run-bindgen.py ./target/debug/bindgen ./tests/headers/some_header.h -``` - -To learn more about the options available with `run-bindgen.py`: - -``` -$ ./tests/tools/run-bindgen.py --help -``` - ### Authoring New Tests To add a new test header to the suite, simply put it in the `tests/headers` -directory. Next, run the `run-bindgen.py` script with the new test header, which -will generate the initial expected output rust bindings. +directory. Next, run `bindgen` to generate the initial expected output Rust +bindings. Put those in `tests/expectations/tests`. If your new test requires certain flags to be passed to `bindgen`, you can specify them at the top of the test header, with a comment like this: @@ -90,14 +78,7 @@ specify them at the top of the test header, with a comment like this: // bindgen-flags: --enable-cxx-namespaces -- -std=c++14 ``` -If your new test requires `bindgen` to be built with certain features, you can -specify the required features at the top of the test header in a similar manner: - -```c -// bingden-features: llvm_stable -``` - -Then verify the new rust bindings compile and its tests pass: +Then verify the new Rust bindings compile and pass some basic tests: ``` $ cargo test -p tests_expectations @@ -130,14 +111,13 @@ To help debug what `bindgen` is doing, you can define the environment variable `RUST_LOG=bindgen` to get a bunch of debugging log spew. ``` -$ RUST_LOG=bindgen ./target/debug/bindgen [flags...] ~/path/to/some/header.h +$ RUST_LOG=libbindgen ./target/debug/bindgen [flags...] ~/path/to/some/header.h ``` -This logging can also be used when debugging failing tests under -`run-bindgen.py`: +This logging can also be used when debugging failing tests: ``` -$ RUST_LOG=bindgen ./tests/tools/run-bindgen.py ./target/debug/bindgen tests/headers/whatever.h +$ RUST_LOG=libbindgen cd libbindgen && cargo test ``` ## Using `creduce` to Minimize Test Cases diff --git a/Cargo.toml b/Cargo.toml index 920902268b..e5a14a6f82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,6 @@ authors = [ "Emilio Cobos Álvarez ", "The Servo project developers", ] -build = "build.rs" description = "A binding generator for Rust" homepage = "https://github.com/servo/rust-bindgen" keywords = ["bindings", "ffi", "code-generation"] @@ -14,50 +13,13 @@ readme = "README.md" repository = "https://github.com/servo/rust-bindgen" version = "0.17.0" -[[bin]] -doc = false -name = "bindgen" - -[build-dependencies] -quasi_codegen = "0.20" - [dependencies] -cfg-if = "0.1.0" clang-sys = "0.8.0" clap = "2" -lazy_static = "0.1.*" -libc = "0.2" +libbindgen = { path = "libbindgen" } log = "0.3" env_logger = "0.3" rustc-serialize = "0.3.19" -syntex_syntax = "0.44" -regex = "0.1" -cexpr = "0.2" - -[dependencies.aster] -features = ["with-syntex"] -version = "0.28" - -[dependencies.clippy] -optional = true -version = "*" - -[dependencies.quasi] -features = ["with-syntex"] -version = "0.20" [features] -llvm_stable = [] -static = [] -# This feature only exists for CI -- don't use it! -_docs = [] - -[lib] -name = "bindgen" -path = "src/lib.rs" - -[dev-dependencies.tests_expectations] -path = "tests/expectations" - -[[test]] -name = "tests" +llvm_stable = ["libbindgen/llvm_stable"] diff --git a/Makefile b/Makefile deleted file mode 100644 index 90281f7b61..0000000000 --- a/Makefile +++ /dev/null @@ -1,34 +0,0 @@ - -TEST_HEADERS := $(wildcard tests/headers/*.h) $(wildcard tests/headers/*.hpp) - -TEST_TARGETS := $(TEST_HEADERS:.h=.rs) -TEST_TARGETS := $(TEST_TARGETS:.hpp=.rs) -TEST_TARGETS := $(patsubst tests/headers/%, tests/expectations/tests/%, $(TEST_TARGETS)) - -BINDGEN := ./target/debug/bindgen - -.PHONY: $(BINDGEN) -$(BINDGEN): - [ -f $@ ] || cargo build --features llvm_stable - -.PHONY: test -test: - cargo test --features llvm_stable - - -.PHONY: regen-tests -regen-tests: $(BINDGEN) clean-tests $(TEST_TARGETS) - @echo > /dev/null - -.PHONY: clean-tests -clean-tests: - $(RM) $(TEST_TARGETS) - -# TODO: Add options to add flags and whatnot -tests/expectations/tests/%.rs: tests/headers/%.h - @mkdir -p $(dir $@) - ./tests/tools/run-bindgen.py $(BINDGEN) $< $@ - -tests/expectations/tests/%.rs: tests/headers/%.hpp - @mkdir -p $(dir $@) - ./tests/tools/run-bindgen.py $(BINDGEN) $< $@ diff --git a/libbindgen/Cargo.toml b/libbindgen/Cargo.toml new file mode 100644 index 0000000000..664ece6e6b --- /dev/null +++ b/libbindgen/Cargo.toml @@ -0,0 +1,54 @@ +[package] +authors = [ + "Jyun-Yan You ", + "Emilio Cobos Álvarez ", + "The Servo project developers", +] +build = "build.rs" +description = "A binding generator for Rust" +homepage = "https://github.com/servo/rust-bindgen" +keywords = ["bindings", "ffi", "code-generation"] +license = "BSD-3-Clause" +name = "libbindgen" +readme = "README.md" +repository = "https://github.com/servo/rust-bindgen" +version = "0.17.0" + +[dev-dependencies] +diff = "0.1" +clap = "2" +shlex = "0.1" +tests_expectations = { path = "tests/expectations" } + +[build-dependencies] +quasi_codegen = "0.20" + +[dependencies] +cfg-if = "0.1.0" +clang-sys = "0.8.0" +lazy_static = "0.1.*" +libc = "0.2" +log = "0.3" +env_logger = "0.3" +rustc-serialize = "0.3.19" +syntex_syntax = "0.44" +regex = "0.1" +cexpr = "0.2" + +[dependencies.aster] +features = ["with-syntex"] +version = "0.28" + +[dependencies.clippy] +optional = true +version = "*" + +[dependencies.quasi] +features = ["with-syntex"] +version = "0.20" + +[features] +llvm_stable = [] +static = [] +# This feature only exists for CI -- don't use it! +_docs = [] diff --git a/build.rs b/libbindgen/build.rs similarity index 100% rename from build.rs rename to libbindgen/build.rs diff --git a/src/chooser.rs b/libbindgen/src/chooser.rs similarity index 100% rename from src/chooser.rs rename to libbindgen/src/chooser.rs diff --git a/src/clang.rs b/libbindgen/src/clang.rs old mode 100755 new mode 100644 similarity index 100% rename from src/clang.rs rename to libbindgen/src/clang.rs diff --git a/src/clangll.rs b/libbindgen/src/clangll.rs similarity index 100% rename from src/clangll.rs rename to libbindgen/src/clangll.rs diff --git a/src/codegen/helpers.rs b/libbindgen/src/codegen/helpers.rs similarity index 100% rename from src/codegen/helpers.rs rename to libbindgen/src/codegen/helpers.rs diff --git a/src/codegen/mod.rs b/libbindgen/src/codegen/mod.rs old mode 100755 new mode 100644 similarity index 100% rename from src/codegen/mod.rs rename to libbindgen/src/codegen/mod.rs diff --git a/src/ir/annotations.rs b/libbindgen/src/ir/annotations.rs similarity index 100% rename from src/ir/annotations.rs rename to libbindgen/src/ir/annotations.rs diff --git a/src/ir/comp.rs b/libbindgen/src/ir/comp.rs similarity index 100% rename from src/ir/comp.rs rename to libbindgen/src/ir/comp.rs diff --git a/src/ir/context.rs b/libbindgen/src/ir/context.rs similarity index 100% rename from src/ir/context.rs rename to libbindgen/src/ir/context.rs diff --git a/src/ir/enum_ty.rs b/libbindgen/src/ir/enum_ty.rs similarity index 100% rename from src/ir/enum_ty.rs rename to libbindgen/src/ir/enum_ty.rs diff --git a/src/ir/function.rs b/libbindgen/src/ir/function.rs similarity index 100% rename from src/ir/function.rs rename to libbindgen/src/ir/function.rs diff --git a/src/ir/int.rs b/libbindgen/src/ir/int.rs similarity index 100% rename from src/ir/int.rs rename to libbindgen/src/ir/int.rs diff --git a/src/ir/item.rs b/libbindgen/src/ir/item.rs similarity index 100% rename from src/ir/item.rs rename to libbindgen/src/ir/item.rs diff --git a/src/ir/item_kind.rs b/libbindgen/src/ir/item_kind.rs similarity index 100% rename from src/ir/item_kind.rs rename to libbindgen/src/ir/item_kind.rs diff --git a/src/ir/layout.rs b/libbindgen/src/ir/layout.rs similarity index 100% rename from src/ir/layout.rs rename to libbindgen/src/ir/layout.rs diff --git a/src/ir/mod.rs b/libbindgen/src/ir/mod.rs similarity index 100% rename from src/ir/mod.rs rename to libbindgen/src/ir/mod.rs diff --git a/src/ir/module.rs b/libbindgen/src/ir/module.rs similarity index 100% rename from src/ir/module.rs rename to libbindgen/src/ir/module.rs diff --git a/src/ir/ty.rs b/libbindgen/src/ir/ty.rs similarity index 100% rename from src/ir/ty.rs rename to libbindgen/src/ir/ty.rs diff --git a/src/ir/type_collector.rs b/libbindgen/src/ir/type_collector.rs similarity index 100% rename from src/ir/type_collector.rs rename to libbindgen/src/ir/type_collector.rs diff --git a/src/ir/var.rs b/libbindgen/src/ir/var.rs similarity index 100% rename from src/ir/var.rs rename to libbindgen/src/ir/var.rs diff --git a/src/lib.rs b/libbindgen/src/lib.rs old mode 100755 new mode 100644 similarity index 99% rename from src/lib.rs rename to libbindgen/src/lib.rs index b56cb468e9..d0ca7b03af --- a/src/lib.rs +++ b/libbindgen/src/lib.rs @@ -5,9 +5,6 @@ //! //! See the [Builder](./struct.Builder.html) struct for usage. -#![crate_name = "bindgen"] -#![crate_type = "dylib"] - #![cfg_attr(feature = "clippy", feature(plugin))] #![cfg_attr(feature = "clippy", plugin(clippy))] diff --git a/src/parse.rs b/libbindgen/src/parse.rs similarity index 100% rename from src/parse.rs rename to libbindgen/src/parse.rs diff --git a/src/regex_set.rs b/libbindgen/src/regex_set.rs similarity index 100% rename from src/regex_set.rs rename to libbindgen/src/regex_set.rs diff --git a/src/uses.rs b/libbindgen/src/uses.rs similarity index 100% rename from src/uses.rs rename to libbindgen/src/uses.rs diff --git a/tests/expectations/Cargo.toml b/libbindgen/tests/expectations/Cargo.toml similarity index 100% rename from tests/expectations/Cargo.toml rename to libbindgen/tests/expectations/Cargo.toml diff --git a/tests/expectations/src/lib.rs b/libbindgen/tests/expectations/src/lib.rs similarity index 100% rename from tests/expectations/src/lib.rs rename to libbindgen/tests/expectations/src/lib.rs diff --git a/tests/expectations/tests/accessors.rs b/libbindgen/tests/expectations/tests/accessors.rs similarity index 100% rename from tests/expectations/tests/accessors.rs rename to libbindgen/tests/expectations/tests/accessors.rs diff --git a/tests/expectations/tests/annotation_hide.rs b/libbindgen/tests/expectations/tests/annotation_hide.rs similarity index 100% rename from tests/expectations/tests/annotation_hide.rs rename to libbindgen/tests/expectations/tests/annotation_hide.rs diff --git a/tests/expectations/tests/anon_enum.rs b/libbindgen/tests/expectations/tests/anon_enum.rs similarity index 100% rename from tests/expectations/tests/anon_enum.rs rename to libbindgen/tests/expectations/tests/anon_enum.rs diff --git a/tests/expectations/tests/anon_enum_whitelist.rs b/libbindgen/tests/expectations/tests/anon_enum_whitelist.rs similarity index 100% rename from tests/expectations/tests/anon_enum_whitelist.rs rename to libbindgen/tests/expectations/tests/anon_enum_whitelist.rs diff --git a/tests/expectations/tests/anon_union.rs b/libbindgen/tests/expectations/tests/anon_union.rs similarity index 100% rename from tests/expectations/tests/anon_union.rs rename to libbindgen/tests/expectations/tests/anon_union.rs diff --git a/tests/expectations/tests/arg_keyword.rs b/libbindgen/tests/expectations/tests/arg_keyword.rs similarity index 100% rename from tests/expectations/tests/arg_keyword.rs rename to libbindgen/tests/expectations/tests/arg_keyword.rs diff --git a/tests/expectations/tests/base-to-derived.rs b/libbindgen/tests/expectations/tests/base-to-derived.rs similarity index 100% rename from tests/expectations/tests/base-to-derived.rs rename to libbindgen/tests/expectations/tests/base-to-derived.rs diff --git a/tests/expectations/tests/bitfield-enum-basic.rs b/libbindgen/tests/expectations/tests/bitfield-enum-basic.rs similarity index 100% rename from tests/expectations/tests/bitfield-enum-basic.rs rename to libbindgen/tests/expectations/tests/bitfield-enum-basic.rs diff --git a/tests/expectations/tests/blocks.rs b/libbindgen/tests/expectations/tests/blocks.rs similarity index 100% rename from tests/expectations/tests/blocks.rs rename to libbindgen/tests/expectations/tests/blocks.rs diff --git a/tests/expectations/tests/class.rs b/libbindgen/tests/expectations/tests/class.rs similarity index 100% rename from tests/expectations/tests/class.rs rename to libbindgen/tests/expectations/tests/class.rs diff --git a/tests/expectations/tests/class_nested.rs b/libbindgen/tests/expectations/tests/class_nested.rs similarity index 100% rename from tests/expectations/tests/class_nested.rs rename to libbindgen/tests/expectations/tests/class_nested.rs diff --git a/tests/expectations/tests/class_no_members.rs b/libbindgen/tests/expectations/tests/class_no_members.rs similarity index 100% rename from tests/expectations/tests/class_no_members.rs rename to libbindgen/tests/expectations/tests/class_no_members.rs diff --git a/tests/expectations/tests/class_static.rs b/libbindgen/tests/expectations/tests/class_static.rs similarity index 100% rename from tests/expectations/tests/class_static.rs rename to libbindgen/tests/expectations/tests/class_static.rs diff --git a/tests/expectations/tests/class_static_const.rs b/libbindgen/tests/expectations/tests/class_static_const.rs similarity index 100% rename from tests/expectations/tests/class_static_const.rs rename to libbindgen/tests/expectations/tests/class_static_const.rs diff --git a/tests/expectations/tests/class_use_as.rs b/libbindgen/tests/expectations/tests/class_use_as.rs similarity index 100% rename from tests/expectations/tests/class_use_as.rs rename to libbindgen/tests/expectations/tests/class_use_as.rs diff --git a/tests/expectations/tests/class_with_dtor.rs b/libbindgen/tests/expectations/tests/class_with_dtor.rs similarity index 100% rename from tests/expectations/tests/class_with_dtor.rs rename to libbindgen/tests/expectations/tests/class_with_dtor.rs diff --git a/tests/expectations/tests/class_with_inner_struct.rs b/libbindgen/tests/expectations/tests/class_with_inner_struct.rs similarity index 100% rename from tests/expectations/tests/class_with_inner_struct.rs rename to libbindgen/tests/expectations/tests/class_with_inner_struct.rs diff --git a/tests/expectations/tests/class_with_typedef.rs b/libbindgen/tests/expectations/tests/class_with_typedef.rs similarity index 100% rename from tests/expectations/tests/class_with_typedef.rs rename to libbindgen/tests/expectations/tests/class_with_typedef.rs diff --git a/tests/expectations/tests/complex.rs b/libbindgen/tests/expectations/tests/complex.rs similarity index 100% rename from tests/expectations/tests/complex.rs rename to libbindgen/tests/expectations/tests/complex.rs diff --git a/tests/expectations/tests/complex_global.rs b/libbindgen/tests/expectations/tests/complex_global.rs similarity index 100% rename from tests/expectations/tests/complex_global.rs rename to libbindgen/tests/expectations/tests/complex_global.rs diff --git a/tests/expectations/tests/const_enum_unnamed.rs b/libbindgen/tests/expectations/tests/const_enum_unnamed.rs similarity index 100% rename from tests/expectations/tests/const_enum_unnamed.rs rename to libbindgen/tests/expectations/tests/const_enum_unnamed.rs diff --git a/tests/expectations/tests/const_ptr.rs b/libbindgen/tests/expectations/tests/const_ptr.rs similarity index 100% rename from tests/expectations/tests/const_ptr.rs rename to libbindgen/tests/expectations/tests/const_ptr.rs diff --git a/tests/expectations/tests/const_resolved_ty.rs b/libbindgen/tests/expectations/tests/const_resolved_ty.rs similarity index 100% rename from tests/expectations/tests/const_resolved_ty.rs rename to libbindgen/tests/expectations/tests/const_resolved_ty.rs diff --git a/tests/expectations/tests/const_tparam.rs b/libbindgen/tests/expectations/tests/const_tparam.rs similarity index 100% rename from tests/expectations/tests/const_tparam.rs rename to libbindgen/tests/expectations/tests/const_tparam.rs diff --git a/tests/expectations/tests/convert-floats.rs b/libbindgen/tests/expectations/tests/convert-floats.rs similarity index 100% rename from tests/expectations/tests/convert-floats.rs rename to libbindgen/tests/expectations/tests/convert-floats.rs diff --git a/tests/expectations/tests/crtp.rs b/libbindgen/tests/expectations/tests/crtp.rs similarity index 100% rename from tests/expectations/tests/crtp.rs rename to libbindgen/tests/expectations/tests/crtp.rs diff --git a/tests/expectations/tests/decl_extern_int_twice.rs b/libbindgen/tests/expectations/tests/decl_extern_int_twice.rs similarity index 100% rename from tests/expectations/tests/decl_extern_int_twice.rs rename to libbindgen/tests/expectations/tests/decl_extern_int_twice.rs diff --git a/tests/expectations/tests/decl_ptr_to_array.rs b/libbindgen/tests/expectations/tests/decl_ptr_to_array.rs similarity index 100% rename from tests/expectations/tests/decl_ptr_to_array.rs rename to libbindgen/tests/expectations/tests/decl_ptr_to_array.rs diff --git a/tests/expectations/tests/duplicated_constants_in_ns.rs b/libbindgen/tests/expectations/tests/duplicated_constants_in_ns.rs similarity index 100% rename from tests/expectations/tests/duplicated_constants_in_ns.rs rename to libbindgen/tests/expectations/tests/duplicated_constants_in_ns.rs diff --git a/tests/expectations/tests/elaborated.rs b/libbindgen/tests/expectations/tests/elaborated.rs similarity index 100% rename from tests/expectations/tests/elaborated.rs rename to libbindgen/tests/expectations/tests/elaborated.rs diff --git a/tests/expectations/tests/empty_template_param_name.rs b/libbindgen/tests/expectations/tests/empty_template_param_name.rs similarity index 100% rename from tests/expectations/tests/empty_template_param_name.rs rename to libbindgen/tests/expectations/tests/empty_template_param_name.rs diff --git a/tests/expectations/tests/enum.rs b/libbindgen/tests/expectations/tests/enum.rs similarity index 100% rename from tests/expectations/tests/enum.rs rename to libbindgen/tests/expectations/tests/enum.rs diff --git a/tests/expectations/tests/enum_alias.rs b/libbindgen/tests/expectations/tests/enum_alias.rs similarity index 100% rename from tests/expectations/tests/enum_alias.rs rename to libbindgen/tests/expectations/tests/enum_alias.rs diff --git a/tests/expectations/tests/enum_and_vtable_mangling.rs b/libbindgen/tests/expectations/tests/enum_and_vtable_mangling.rs similarity index 100% rename from tests/expectations/tests/enum_and_vtable_mangling.rs rename to libbindgen/tests/expectations/tests/enum_and_vtable_mangling.rs diff --git a/tests/expectations/tests/enum_dupe.rs b/libbindgen/tests/expectations/tests/enum_dupe.rs similarity index 100% rename from tests/expectations/tests/enum_dupe.rs rename to libbindgen/tests/expectations/tests/enum_dupe.rs diff --git a/tests/expectations/tests/enum_explicit_type.rs b/libbindgen/tests/expectations/tests/enum_explicit_type.rs similarity index 100% rename from tests/expectations/tests/enum_explicit_type.rs rename to libbindgen/tests/expectations/tests/enum_explicit_type.rs diff --git a/tests/expectations/tests/enum_negative.rs b/libbindgen/tests/expectations/tests/enum_negative.rs similarity index 100% rename from tests/expectations/tests/enum_negative.rs rename to libbindgen/tests/expectations/tests/enum_negative.rs diff --git a/tests/expectations/tests/enum_packed.rs b/libbindgen/tests/expectations/tests/enum_packed.rs similarity index 100% rename from tests/expectations/tests/enum_packed.rs rename to libbindgen/tests/expectations/tests/enum_packed.rs diff --git a/tests/expectations/tests/extern.rs b/libbindgen/tests/expectations/tests/extern.rs similarity index 100% rename from tests/expectations/tests/extern.rs rename to libbindgen/tests/expectations/tests/extern.rs diff --git a/tests/expectations/tests/float128.rs b/libbindgen/tests/expectations/tests/float128.rs similarity index 100% rename from tests/expectations/tests/float128.rs rename to libbindgen/tests/expectations/tests/float128.rs diff --git a/tests/expectations/tests/forward-inherit-struct-with-fields.rs b/libbindgen/tests/expectations/tests/forward-inherit-struct-with-fields.rs similarity index 100% rename from tests/expectations/tests/forward-inherit-struct-with-fields.rs rename to libbindgen/tests/expectations/tests/forward-inherit-struct-with-fields.rs diff --git a/tests/expectations/tests/forward-inherit-struct.rs b/libbindgen/tests/expectations/tests/forward-inherit-struct.rs similarity index 100% rename from tests/expectations/tests/forward-inherit-struct.rs rename to libbindgen/tests/expectations/tests/forward-inherit-struct.rs diff --git a/tests/expectations/tests/forward_declared_struct.rs b/libbindgen/tests/expectations/tests/forward_declared_struct.rs similarity index 100% rename from tests/expectations/tests/forward_declared_struct.rs rename to libbindgen/tests/expectations/tests/forward_declared_struct.rs diff --git a/tests/expectations/tests/func_proto.rs b/libbindgen/tests/expectations/tests/func_proto.rs similarity index 100% rename from tests/expectations/tests/func_proto.rs rename to libbindgen/tests/expectations/tests/func_proto.rs diff --git a/tests/expectations/tests/func_ptr.rs b/libbindgen/tests/expectations/tests/func_ptr.rs similarity index 100% rename from tests/expectations/tests/func_ptr.rs rename to libbindgen/tests/expectations/tests/func_ptr.rs diff --git a/tests/expectations/tests/func_ptr_in_struct.rs b/libbindgen/tests/expectations/tests/func_ptr_in_struct.rs similarity index 100% rename from tests/expectations/tests/func_ptr_in_struct.rs rename to libbindgen/tests/expectations/tests/func_ptr_in_struct.rs diff --git a/tests/expectations/tests/func_with_array_arg.rs b/libbindgen/tests/expectations/tests/func_with_array_arg.rs similarity index 100% rename from tests/expectations/tests/func_with_array_arg.rs rename to libbindgen/tests/expectations/tests/func_with_array_arg.rs diff --git a/tests/expectations/tests/func_with_func_ptr_arg.rs b/libbindgen/tests/expectations/tests/func_with_func_ptr_arg.rs similarity index 100% rename from tests/expectations/tests/func_with_func_ptr_arg.rs rename to libbindgen/tests/expectations/tests/func_with_func_ptr_arg.rs diff --git a/tests/expectations/tests/in_class_typedef.rs b/libbindgen/tests/expectations/tests/in_class_typedef.rs similarity index 100% rename from tests/expectations/tests/in_class_typedef.rs rename to libbindgen/tests/expectations/tests/in_class_typedef.rs diff --git a/tests/expectations/tests/inherit-namespaced.rs b/libbindgen/tests/expectations/tests/inherit-namespaced.rs similarity index 100% rename from tests/expectations/tests/inherit-namespaced.rs rename to libbindgen/tests/expectations/tests/inherit-namespaced.rs diff --git a/tests/expectations/tests/inherit_named.rs b/libbindgen/tests/expectations/tests/inherit_named.rs similarity index 100% rename from tests/expectations/tests/inherit_named.rs rename to libbindgen/tests/expectations/tests/inherit_named.rs diff --git a/tests/expectations/tests/inherit_typedef.rs b/libbindgen/tests/expectations/tests/inherit_typedef.rs similarity index 100% rename from tests/expectations/tests/inherit_typedef.rs rename to libbindgen/tests/expectations/tests/inherit_typedef.rs diff --git a/tests/expectations/tests/inner_const.rs b/libbindgen/tests/expectations/tests/inner_const.rs similarity index 100% rename from tests/expectations/tests/inner_const.rs rename to libbindgen/tests/expectations/tests/inner_const.rs diff --git a/tests/expectations/tests/inner_template_self.rs b/libbindgen/tests/expectations/tests/inner_template_self.rs similarity index 100% rename from tests/expectations/tests/inner_template_self.rs rename to libbindgen/tests/expectations/tests/inner_template_self.rs diff --git a/tests/expectations/tests/int128_t.rs b/libbindgen/tests/expectations/tests/int128_t.rs similarity index 100% rename from tests/expectations/tests/int128_t.rs rename to libbindgen/tests/expectations/tests/int128_t.rs diff --git a/tests/expectations/tests/jsval_layout_opaque.rs b/libbindgen/tests/expectations/tests/jsval_layout_opaque.rs similarity index 100% rename from tests/expectations/tests/jsval_layout_opaque.rs rename to libbindgen/tests/expectations/tests/jsval_layout_opaque.rs diff --git a/tests/expectations/tests/keywords.rs b/libbindgen/tests/expectations/tests/keywords.rs similarity index 100% rename from tests/expectations/tests/keywords.rs rename to libbindgen/tests/expectations/tests/keywords.rs diff --git a/tests/expectations/tests/macro-expr-basic.rs b/libbindgen/tests/expectations/tests/macro-expr-basic.rs similarity index 100% rename from tests/expectations/tests/macro-expr-basic.rs rename to libbindgen/tests/expectations/tests/macro-expr-basic.rs diff --git a/tests/expectations/tests/macro-redef.rs b/libbindgen/tests/expectations/tests/macro-redef.rs similarity index 100% rename from tests/expectations/tests/macro-redef.rs rename to libbindgen/tests/expectations/tests/macro-redef.rs diff --git a/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs b/libbindgen/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs similarity index 100% rename from tests/expectations/tests/multiple-inherit-empty-correct-layout.rs rename to libbindgen/tests/expectations/tests/multiple-inherit-empty-correct-layout.rs diff --git a/tests/expectations/tests/mutable.rs b/libbindgen/tests/expectations/tests/mutable.rs similarity index 100% rename from tests/expectations/tests/mutable.rs rename to libbindgen/tests/expectations/tests/mutable.rs diff --git a/tests/expectations/tests/namespace.rs b/libbindgen/tests/expectations/tests/namespace.rs similarity index 100% rename from tests/expectations/tests/namespace.rs rename to libbindgen/tests/expectations/tests/namespace.rs diff --git a/tests/expectations/tests/nested.rs b/libbindgen/tests/expectations/tests/nested.rs similarity index 100% rename from tests/expectations/tests/nested.rs rename to libbindgen/tests/expectations/tests/nested.rs diff --git a/tests/expectations/tests/nested_vtable.rs b/libbindgen/tests/expectations/tests/nested_vtable.rs similarity index 100% rename from tests/expectations/tests/nested_vtable.rs rename to libbindgen/tests/expectations/tests/nested_vtable.rs diff --git a/tests/expectations/tests/no-std.rs b/libbindgen/tests/expectations/tests/no-std.rs similarity index 100% rename from tests/expectations/tests/no-std.rs rename to libbindgen/tests/expectations/tests/no-std.rs diff --git a/tests/expectations/tests/no_copy.rs b/libbindgen/tests/expectations/tests/no_copy.rs similarity index 100% rename from tests/expectations/tests/no_copy.rs rename to libbindgen/tests/expectations/tests/no_copy.rs diff --git a/tests/expectations/tests/nsStyleAutoArray.rs b/libbindgen/tests/expectations/tests/nsStyleAutoArray.rs similarity index 100% rename from tests/expectations/tests/nsStyleAutoArray.rs rename to libbindgen/tests/expectations/tests/nsStyleAutoArray.rs diff --git a/tests/expectations/tests/only_bitfields.rs b/libbindgen/tests/expectations/tests/only_bitfields.rs similarity index 100% rename from tests/expectations/tests/only_bitfields.rs rename to libbindgen/tests/expectations/tests/only_bitfields.rs diff --git a/tests/expectations/tests/opaque_in_struct.rs b/libbindgen/tests/expectations/tests/opaque_in_struct.rs similarity index 100% rename from tests/expectations/tests/opaque_in_struct.rs rename to libbindgen/tests/expectations/tests/opaque_in_struct.rs diff --git a/tests/expectations/tests/opaque_pointer.rs b/libbindgen/tests/expectations/tests/opaque_pointer.rs similarity index 100% rename from tests/expectations/tests/opaque_pointer.rs rename to libbindgen/tests/expectations/tests/opaque_pointer.rs diff --git a/tests/expectations/tests/opaque_typedef.rs b/libbindgen/tests/expectations/tests/opaque_typedef.rs similarity index 100% rename from tests/expectations/tests/opaque_typedef.rs rename to libbindgen/tests/expectations/tests/opaque_typedef.rs diff --git a/tests/expectations/tests/overflowed_enum.rs b/libbindgen/tests/expectations/tests/overflowed_enum.rs similarity index 100% rename from tests/expectations/tests/overflowed_enum.rs rename to libbindgen/tests/expectations/tests/overflowed_enum.rs diff --git a/tests/expectations/tests/overloading.rs b/libbindgen/tests/expectations/tests/overloading.rs similarity index 100% rename from tests/expectations/tests/overloading.rs rename to libbindgen/tests/expectations/tests/overloading.rs diff --git a/tests/expectations/tests/private.rs b/libbindgen/tests/expectations/tests/private.rs similarity index 100% rename from tests/expectations/tests/private.rs rename to libbindgen/tests/expectations/tests/private.rs diff --git a/tests/expectations/tests/redeclaration.rs b/libbindgen/tests/expectations/tests/redeclaration.rs similarity index 100% rename from tests/expectations/tests/redeclaration.rs rename to libbindgen/tests/expectations/tests/redeclaration.rs diff --git a/tests/expectations/tests/ref_argument_array.rs b/libbindgen/tests/expectations/tests/ref_argument_array.rs similarity index 100% rename from tests/expectations/tests/ref_argument_array.rs rename to libbindgen/tests/expectations/tests/ref_argument_array.rs diff --git a/tests/expectations/tests/replace_template_alias.rs b/libbindgen/tests/expectations/tests/replace_template_alias.rs similarity index 100% rename from tests/expectations/tests/replace_template_alias.rs rename to libbindgen/tests/expectations/tests/replace_template_alias.rs diff --git a/tests/expectations/tests/replaces_double.rs b/libbindgen/tests/expectations/tests/replaces_double.rs similarity index 100% rename from tests/expectations/tests/replaces_double.rs rename to libbindgen/tests/expectations/tests/replaces_double.rs diff --git a/tests/expectations/tests/size_t_template.rs b/libbindgen/tests/expectations/tests/size_t_template.rs similarity index 100% rename from tests/expectations/tests/size_t_template.rs rename to libbindgen/tests/expectations/tests/size_t_template.rs diff --git a/tests/expectations/tests/struct_containing_forward_declared_struct.rs b/libbindgen/tests/expectations/tests/struct_containing_forward_declared_struct.rs similarity index 100% rename from tests/expectations/tests/struct_containing_forward_declared_struct.rs rename to libbindgen/tests/expectations/tests/struct_containing_forward_declared_struct.rs diff --git a/tests/expectations/tests/struct_with_anon_struct.rs b/libbindgen/tests/expectations/tests/struct_with_anon_struct.rs similarity index 100% rename from tests/expectations/tests/struct_with_anon_struct.rs rename to libbindgen/tests/expectations/tests/struct_with_anon_struct.rs diff --git a/tests/expectations/tests/struct_with_anon_struct_array.rs b/libbindgen/tests/expectations/tests/struct_with_anon_struct_array.rs similarity index 100% rename from tests/expectations/tests/struct_with_anon_struct_array.rs rename to libbindgen/tests/expectations/tests/struct_with_anon_struct_array.rs diff --git a/tests/expectations/tests/struct_with_anon_struct_pointer.rs b/libbindgen/tests/expectations/tests/struct_with_anon_struct_pointer.rs similarity index 100% rename from tests/expectations/tests/struct_with_anon_struct_pointer.rs rename to libbindgen/tests/expectations/tests/struct_with_anon_struct_pointer.rs diff --git a/tests/expectations/tests/struct_with_anon_union.rs b/libbindgen/tests/expectations/tests/struct_with_anon_union.rs similarity index 100% rename from tests/expectations/tests/struct_with_anon_union.rs rename to libbindgen/tests/expectations/tests/struct_with_anon_union.rs diff --git a/tests/expectations/tests/struct_with_anon_unnamed_struct.rs b/libbindgen/tests/expectations/tests/struct_with_anon_unnamed_struct.rs similarity index 100% rename from tests/expectations/tests/struct_with_anon_unnamed_struct.rs rename to libbindgen/tests/expectations/tests/struct_with_anon_unnamed_struct.rs diff --git a/tests/expectations/tests/struct_with_anon_unnamed_union.rs b/libbindgen/tests/expectations/tests/struct_with_anon_unnamed_union.rs similarity index 100% rename from tests/expectations/tests/struct_with_anon_unnamed_union.rs rename to libbindgen/tests/expectations/tests/struct_with_anon_unnamed_union.rs diff --git a/tests/expectations/tests/struct_with_bitfields.rs b/libbindgen/tests/expectations/tests/struct_with_bitfields.rs similarity index 100% rename from tests/expectations/tests/struct_with_bitfields.rs rename to libbindgen/tests/expectations/tests/struct_with_bitfields.rs diff --git a/tests/expectations/tests/struct_with_derive_debug.rs b/libbindgen/tests/expectations/tests/struct_with_derive_debug.rs similarity index 100% rename from tests/expectations/tests/struct_with_derive_debug.rs rename to libbindgen/tests/expectations/tests/struct_with_derive_debug.rs diff --git a/tests/expectations/tests/struct_with_nesting.rs b/libbindgen/tests/expectations/tests/struct_with_nesting.rs similarity index 100% rename from tests/expectations/tests/struct_with_nesting.rs rename to libbindgen/tests/expectations/tests/struct_with_nesting.rs diff --git a/tests/expectations/tests/struct_with_packing.rs b/libbindgen/tests/expectations/tests/struct_with_packing.rs similarity index 100% rename from tests/expectations/tests/struct_with_packing.rs rename to libbindgen/tests/expectations/tests/struct_with_packing.rs diff --git a/tests/expectations/tests/struct_with_struct.rs b/libbindgen/tests/expectations/tests/struct_with_struct.rs similarity index 100% rename from tests/expectations/tests/struct_with_struct.rs rename to libbindgen/tests/expectations/tests/struct_with_struct.rs diff --git a/tests/expectations/tests/struct_with_typedef_template_arg.rs b/libbindgen/tests/expectations/tests/struct_with_typedef_template_arg.rs similarity index 100% rename from tests/expectations/tests/struct_with_typedef_template_arg.rs rename to libbindgen/tests/expectations/tests/struct_with_typedef_template_arg.rs diff --git a/tests/expectations/tests/template.rs b/libbindgen/tests/expectations/tests/template.rs similarity index 100% rename from tests/expectations/tests/template.rs rename to libbindgen/tests/expectations/tests/template.rs diff --git a/tests/expectations/tests/template_alias.rs b/libbindgen/tests/expectations/tests/template_alias.rs similarity index 100% rename from tests/expectations/tests/template_alias.rs rename to libbindgen/tests/expectations/tests/template_alias.rs diff --git a/tests/expectations/tests/template_alias_basic.rs b/libbindgen/tests/expectations/tests/template_alias_basic.rs similarity index 100% rename from tests/expectations/tests/template_alias_basic.rs rename to libbindgen/tests/expectations/tests/template_alias_basic.rs diff --git a/tests/expectations/tests/template_alias_namespace.rs b/libbindgen/tests/expectations/tests/template_alias_namespace.rs similarity index 100% rename from tests/expectations/tests/template_alias_namespace.rs rename to libbindgen/tests/expectations/tests/template_alias_namespace.rs diff --git a/tests/expectations/tests/template_typedef_transitive_param.rs b/libbindgen/tests/expectations/tests/template_typedef_transitive_param.rs similarity index 100% rename from tests/expectations/tests/template_typedef_transitive_param.rs rename to libbindgen/tests/expectations/tests/template_typedef_transitive_param.rs diff --git a/tests/expectations/tests/template_typedefs.rs b/libbindgen/tests/expectations/tests/template_typedefs.rs similarity index 100% rename from tests/expectations/tests/template_typedefs.rs rename to libbindgen/tests/expectations/tests/template_typedefs.rs diff --git a/tests/expectations/tests/type_alias_empty.rs b/libbindgen/tests/expectations/tests/type_alias_empty.rs similarity index 100% rename from tests/expectations/tests/type_alias_empty.rs rename to libbindgen/tests/expectations/tests/type_alias_empty.rs diff --git a/tests/expectations/tests/typeref.rs b/libbindgen/tests/expectations/tests/typeref.rs similarity index 100% rename from tests/expectations/tests/typeref.rs rename to libbindgen/tests/expectations/tests/typeref.rs diff --git a/tests/expectations/tests/union_dtor.rs b/libbindgen/tests/expectations/tests/union_dtor.rs similarity index 100% rename from tests/expectations/tests/union_dtor.rs rename to libbindgen/tests/expectations/tests/union_dtor.rs diff --git a/tests/expectations/tests/union_fields.rs b/libbindgen/tests/expectations/tests/union_fields.rs similarity index 100% rename from tests/expectations/tests/union_fields.rs rename to libbindgen/tests/expectations/tests/union_fields.rs diff --git a/tests/expectations/tests/union_template.rs b/libbindgen/tests/expectations/tests/union_template.rs similarity index 100% rename from tests/expectations/tests/union_template.rs rename to libbindgen/tests/expectations/tests/union_template.rs diff --git a/tests/expectations/tests/union_with_anon_struct.rs b/libbindgen/tests/expectations/tests/union_with_anon_struct.rs similarity index 100% rename from tests/expectations/tests/union_with_anon_struct.rs rename to libbindgen/tests/expectations/tests/union_with_anon_struct.rs diff --git a/tests/expectations/tests/union_with_anon_struct_bitfield.rs b/libbindgen/tests/expectations/tests/union_with_anon_struct_bitfield.rs similarity index 100% rename from tests/expectations/tests/union_with_anon_struct_bitfield.rs rename to libbindgen/tests/expectations/tests/union_with_anon_struct_bitfield.rs diff --git a/tests/expectations/tests/union_with_anon_union.rs b/libbindgen/tests/expectations/tests/union_with_anon_union.rs similarity index 100% rename from tests/expectations/tests/union_with_anon_union.rs rename to libbindgen/tests/expectations/tests/union_with_anon_union.rs diff --git a/tests/expectations/tests/union_with_anon_unnamed_struct.rs b/libbindgen/tests/expectations/tests/union_with_anon_unnamed_struct.rs similarity index 100% rename from tests/expectations/tests/union_with_anon_unnamed_struct.rs rename to libbindgen/tests/expectations/tests/union_with_anon_unnamed_struct.rs diff --git a/tests/expectations/tests/union_with_anon_unnamed_union.rs b/libbindgen/tests/expectations/tests/union_with_anon_unnamed_union.rs similarity index 100% rename from tests/expectations/tests/union_with_anon_unnamed_union.rs rename to libbindgen/tests/expectations/tests/union_with_anon_unnamed_union.rs diff --git a/tests/expectations/tests/union_with_big_member.rs b/libbindgen/tests/expectations/tests/union_with_big_member.rs similarity index 100% rename from tests/expectations/tests/union_with_big_member.rs rename to libbindgen/tests/expectations/tests/union_with_big_member.rs diff --git a/tests/expectations/tests/union_with_nesting.rs b/libbindgen/tests/expectations/tests/union_with_nesting.rs similarity index 100% rename from tests/expectations/tests/union_with_nesting.rs rename to libbindgen/tests/expectations/tests/union_with_nesting.rs diff --git a/tests/expectations/tests/unknown_attr.rs b/libbindgen/tests/expectations/tests/unknown_attr.rs similarity index 100% rename from tests/expectations/tests/unknown_attr.rs rename to libbindgen/tests/expectations/tests/unknown_attr.rs diff --git a/tests/expectations/tests/use-core.rs b/libbindgen/tests/expectations/tests/use-core.rs similarity index 100% rename from tests/expectations/tests/use-core.rs rename to libbindgen/tests/expectations/tests/use-core.rs diff --git a/tests/expectations/tests/using.rs b/libbindgen/tests/expectations/tests/using.rs similarity index 100% rename from tests/expectations/tests/using.rs rename to libbindgen/tests/expectations/tests/using.rs diff --git a/tests/expectations/tests/vector.rs b/libbindgen/tests/expectations/tests/vector.rs similarity index 100% rename from tests/expectations/tests/vector.rs rename to libbindgen/tests/expectations/tests/vector.rs diff --git a/tests/expectations/tests/virtual_dtor.rs b/libbindgen/tests/expectations/tests/virtual_dtor.rs similarity index 100% rename from tests/expectations/tests/virtual_dtor.rs rename to libbindgen/tests/expectations/tests/virtual_dtor.rs diff --git a/tests/expectations/tests/virtual_overloaded.rs b/libbindgen/tests/expectations/tests/virtual_overloaded.rs similarity index 100% rename from tests/expectations/tests/virtual_overloaded.rs rename to libbindgen/tests/expectations/tests/virtual_overloaded.rs diff --git a/tests/expectations/tests/vtable_recursive_sig.rs b/libbindgen/tests/expectations/tests/vtable_recursive_sig.rs similarity index 100% rename from tests/expectations/tests/vtable_recursive_sig.rs rename to libbindgen/tests/expectations/tests/vtable_recursive_sig.rs diff --git a/tests/expectations/tests/weird_bitfields.rs b/libbindgen/tests/expectations/tests/weird_bitfields.rs similarity index 100% rename from tests/expectations/tests/weird_bitfields.rs rename to libbindgen/tests/expectations/tests/weird_bitfields.rs diff --git a/tests/expectations/tests/what_is_going_on.rs b/libbindgen/tests/expectations/tests/what_is_going_on.rs similarity index 100% rename from tests/expectations/tests/what_is_going_on.rs rename to libbindgen/tests/expectations/tests/what_is_going_on.rs diff --git a/tests/expectations/tests/whitelist_basic.rs b/libbindgen/tests/expectations/tests/whitelist_basic.rs similarity index 100% rename from tests/expectations/tests/whitelist_basic.rs rename to libbindgen/tests/expectations/tests/whitelist_basic.rs diff --git a/tests/expectations/tests/whitelist_vars.rs b/libbindgen/tests/expectations/tests/whitelist_vars.rs similarity index 100% rename from tests/expectations/tests/whitelist_vars.rs rename to libbindgen/tests/expectations/tests/whitelist_vars.rs diff --git a/tests/headers/accessors.hpp b/libbindgen/tests/headers/accessors.hpp similarity index 100% rename from tests/headers/accessors.hpp rename to libbindgen/tests/headers/accessors.hpp diff --git a/tests/headers/annotation_hide.hpp b/libbindgen/tests/headers/annotation_hide.hpp similarity index 100% rename from tests/headers/annotation_hide.hpp rename to libbindgen/tests/headers/annotation_hide.hpp diff --git a/tests/headers/anon_enum.hpp b/libbindgen/tests/headers/anon_enum.hpp similarity index 100% rename from tests/headers/anon_enum.hpp rename to libbindgen/tests/headers/anon_enum.hpp diff --git a/tests/headers/anon_enum_whitelist.h b/libbindgen/tests/headers/anon_enum_whitelist.h similarity index 100% rename from tests/headers/anon_enum_whitelist.h rename to libbindgen/tests/headers/anon_enum_whitelist.h diff --git a/tests/headers/anon_union.hpp b/libbindgen/tests/headers/anon_union.hpp similarity index 100% rename from tests/headers/anon_union.hpp rename to libbindgen/tests/headers/anon_union.hpp diff --git a/tests/headers/arg_keyword.hpp b/libbindgen/tests/headers/arg_keyword.hpp similarity index 100% rename from tests/headers/arg_keyword.hpp rename to libbindgen/tests/headers/arg_keyword.hpp diff --git a/tests/headers/base-to-derived.hpp b/libbindgen/tests/headers/base-to-derived.hpp similarity index 100% rename from tests/headers/base-to-derived.hpp rename to libbindgen/tests/headers/base-to-derived.hpp diff --git a/tests/headers/bitfield-enum-basic.h b/libbindgen/tests/headers/bitfield-enum-basic.h similarity index 100% rename from tests/headers/bitfield-enum-basic.h rename to libbindgen/tests/headers/bitfield-enum-basic.h diff --git a/tests/headers/blocks.h b/libbindgen/tests/headers/blocks.h similarity index 100% rename from tests/headers/blocks.h rename to libbindgen/tests/headers/blocks.h diff --git a/tests/headers/class.hpp b/libbindgen/tests/headers/class.hpp similarity index 100% rename from tests/headers/class.hpp rename to libbindgen/tests/headers/class.hpp diff --git a/tests/headers/class_nested.hpp b/libbindgen/tests/headers/class_nested.hpp similarity index 100% rename from tests/headers/class_nested.hpp rename to libbindgen/tests/headers/class_nested.hpp diff --git a/tests/headers/class_no_members.hpp b/libbindgen/tests/headers/class_no_members.hpp similarity index 100% rename from tests/headers/class_no_members.hpp rename to libbindgen/tests/headers/class_no_members.hpp diff --git a/tests/headers/class_static.hpp b/libbindgen/tests/headers/class_static.hpp similarity index 100% rename from tests/headers/class_static.hpp rename to libbindgen/tests/headers/class_static.hpp diff --git a/tests/headers/class_static_const.hpp b/libbindgen/tests/headers/class_static_const.hpp similarity index 100% rename from tests/headers/class_static_const.hpp rename to libbindgen/tests/headers/class_static_const.hpp diff --git a/tests/headers/class_use_as.hpp b/libbindgen/tests/headers/class_use_as.hpp similarity index 100% rename from tests/headers/class_use_as.hpp rename to libbindgen/tests/headers/class_use_as.hpp diff --git a/tests/headers/class_with_dtor.hpp b/libbindgen/tests/headers/class_with_dtor.hpp similarity index 100% rename from tests/headers/class_with_dtor.hpp rename to libbindgen/tests/headers/class_with_dtor.hpp diff --git a/tests/headers/class_with_inner_struct.hpp b/libbindgen/tests/headers/class_with_inner_struct.hpp similarity index 100% rename from tests/headers/class_with_inner_struct.hpp rename to libbindgen/tests/headers/class_with_inner_struct.hpp diff --git a/tests/headers/class_with_typedef.hpp b/libbindgen/tests/headers/class_with_typedef.hpp similarity index 100% rename from tests/headers/class_with_typedef.hpp rename to libbindgen/tests/headers/class_with_typedef.hpp diff --git a/tests/headers/complex.h b/libbindgen/tests/headers/complex.h similarity index 100% rename from tests/headers/complex.h rename to libbindgen/tests/headers/complex.h diff --git a/tests/headers/complex_global.h b/libbindgen/tests/headers/complex_global.h similarity index 100% rename from tests/headers/complex_global.h rename to libbindgen/tests/headers/complex_global.h diff --git a/tests/headers/const_enum_unnamed.hpp b/libbindgen/tests/headers/const_enum_unnamed.hpp similarity index 100% rename from tests/headers/const_enum_unnamed.hpp rename to libbindgen/tests/headers/const_enum_unnamed.hpp diff --git a/tests/headers/const_ptr.hpp b/libbindgen/tests/headers/const_ptr.hpp similarity index 100% rename from tests/headers/const_ptr.hpp rename to libbindgen/tests/headers/const_ptr.hpp diff --git a/tests/headers/const_resolved_ty.h b/libbindgen/tests/headers/const_resolved_ty.h similarity index 100% rename from tests/headers/const_resolved_ty.h rename to libbindgen/tests/headers/const_resolved_ty.h diff --git a/tests/headers/const_tparam.hpp b/libbindgen/tests/headers/const_tparam.hpp similarity index 100% rename from tests/headers/const_tparam.hpp rename to libbindgen/tests/headers/const_tparam.hpp diff --git a/tests/headers/convert-floats.h b/libbindgen/tests/headers/convert-floats.h similarity index 100% rename from tests/headers/convert-floats.h rename to libbindgen/tests/headers/convert-floats.h diff --git a/tests/headers/crtp.hpp b/libbindgen/tests/headers/crtp.hpp similarity index 100% rename from tests/headers/crtp.hpp rename to libbindgen/tests/headers/crtp.hpp diff --git a/tests/headers/decl_extern_int_twice.h b/libbindgen/tests/headers/decl_extern_int_twice.h similarity index 100% rename from tests/headers/decl_extern_int_twice.h rename to libbindgen/tests/headers/decl_extern_int_twice.h diff --git a/tests/headers/decl_ptr_to_array.h b/libbindgen/tests/headers/decl_ptr_to_array.h similarity index 100% rename from tests/headers/decl_ptr_to_array.h rename to libbindgen/tests/headers/decl_ptr_to_array.h diff --git a/tests/headers/duplicated_constants_in_ns.hpp b/libbindgen/tests/headers/duplicated_constants_in_ns.hpp similarity index 100% rename from tests/headers/duplicated_constants_in_ns.hpp rename to libbindgen/tests/headers/duplicated_constants_in_ns.hpp diff --git a/tests/headers/elaborated.hpp b/libbindgen/tests/headers/elaborated.hpp similarity index 100% rename from tests/headers/elaborated.hpp rename to libbindgen/tests/headers/elaborated.hpp diff --git a/tests/headers/empty_template_param_name.hpp b/libbindgen/tests/headers/empty_template_param_name.hpp similarity index 100% rename from tests/headers/empty_template_param_name.hpp rename to libbindgen/tests/headers/empty_template_param_name.hpp diff --git a/tests/headers/enum.h b/libbindgen/tests/headers/enum.h similarity index 100% rename from tests/headers/enum.h rename to libbindgen/tests/headers/enum.h diff --git a/tests/headers/enum_alias.hpp b/libbindgen/tests/headers/enum_alias.hpp similarity index 100% rename from tests/headers/enum_alias.hpp rename to libbindgen/tests/headers/enum_alias.hpp diff --git a/tests/headers/enum_and_vtable_mangling.hpp b/libbindgen/tests/headers/enum_and_vtable_mangling.hpp similarity index 100% rename from tests/headers/enum_and_vtable_mangling.hpp rename to libbindgen/tests/headers/enum_and_vtable_mangling.hpp diff --git a/tests/headers/enum_dupe.h b/libbindgen/tests/headers/enum_dupe.h similarity index 100% rename from tests/headers/enum_dupe.h rename to libbindgen/tests/headers/enum_dupe.h diff --git a/tests/headers/enum_explicit_type.hpp b/libbindgen/tests/headers/enum_explicit_type.hpp similarity index 100% rename from tests/headers/enum_explicit_type.hpp rename to libbindgen/tests/headers/enum_explicit_type.hpp diff --git a/tests/headers/enum_negative.h b/libbindgen/tests/headers/enum_negative.h similarity index 100% rename from tests/headers/enum_negative.h rename to libbindgen/tests/headers/enum_negative.h diff --git a/tests/headers/enum_packed.h b/libbindgen/tests/headers/enum_packed.h similarity index 100% rename from tests/headers/enum_packed.h rename to libbindgen/tests/headers/enum_packed.h diff --git a/tests/headers/extern.hpp b/libbindgen/tests/headers/extern.hpp similarity index 100% rename from tests/headers/extern.hpp rename to libbindgen/tests/headers/extern.hpp diff --git a/tests/headers/float128.hpp b/libbindgen/tests/headers/float128.hpp similarity index 100% rename from tests/headers/float128.hpp rename to libbindgen/tests/headers/float128.hpp diff --git a/tests/headers/forward-inherit-struct-with-fields.hpp b/libbindgen/tests/headers/forward-inherit-struct-with-fields.hpp similarity index 100% rename from tests/headers/forward-inherit-struct-with-fields.hpp rename to libbindgen/tests/headers/forward-inherit-struct-with-fields.hpp diff --git a/tests/headers/forward-inherit-struct.hpp b/libbindgen/tests/headers/forward-inherit-struct.hpp similarity index 100% rename from tests/headers/forward-inherit-struct.hpp rename to libbindgen/tests/headers/forward-inherit-struct.hpp diff --git a/tests/headers/forward_declared_struct.h b/libbindgen/tests/headers/forward_declared_struct.h similarity index 100% rename from tests/headers/forward_declared_struct.h rename to libbindgen/tests/headers/forward_declared_struct.h diff --git a/tests/headers/func_proto.h b/libbindgen/tests/headers/func_proto.h similarity index 100% rename from tests/headers/func_proto.h rename to libbindgen/tests/headers/func_proto.h diff --git a/tests/headers/func_ptr.h b/libbindgen/tests/headers/func_ptr.h similarity index 100% rename from tests/headers/func_ptr.h rename to libbindgen/tests/headers/func_ptr.h diff --git a/tests/headers/func_ptr_in_struct.h b/libbindgen/tests/headers/func_ptr_in_struct.h similarity index 100% rename from tests/headers/func_ptr_in_struct.h rename to libbindgen/tests/headers/func_ptr_in_struct.h diff --git a/tests/headers/func_with_array_arg.h b/libbindgen/tests/headers/func_with_array_arg.h similarity index 100% rename from tests/headers/func_with_array_arg.h rename to libbindgen/tests/headers/func_with_array_arg.h diff --git a/tests/headers/func_with_func_ptr_arg.h b/libbindgen/tests/headers/func_with_func_ptr_arg.h similarity index 100% rename from tests/headers/func_with_func_ptr_arg.h rename to libbindgen/tests/headers/func_with_func_ptr_arg.h diff --git a/tests/headers/in_class_typedef.hpp b/libbindgen/tests/headers/in_class_typedef.hpp similarity index 100% rename from tests/headers/in_class_typedef.hpp rename to libbindgen/tests/headers/in_class_typedef.hpp diff --git a/tests/headers/inherit-namespaced.hpp b/libbindgen/tests/headers/inherit-namespaced.hpp similarity index 100% rename from tests/headers/inherit-namespaced.hpp rename to libbindgen/tests/headers/inherit-namespaced.hpp diff --git a/tests/headers/inherit_named.hpp b/libbindgen/tests/headers/inherit_named.hpp similarity index 100% rename from tests/headers/inherit_named.hpp rename to libbindgen/tests/headers/inherit_named.hpp diff --git a/tests/headers/inherit_typedef.hpp b/libbindgen/tests/headers/inherit_typedef.hpp similarity index 100% rename from tests/headers/inherit_typedef.hpp rename to libbindgen/tests/headers/inherit_typedef.hpp diff --git a/tests/headers/inner_const.hpp b/libbindgen/tests/headers/inner_const.hpp similarity index 100% rename from tests/headers/inner_const.hpp rename to libbindgen/tests/headers/inner_const.hpp diff --git a/tests/headers/inner_template_self.hpp b/libbindgen/tests/headers/inner_template_self.hpp similarity index 100% rename from tests/headers/inner_template_self.hpp rename to libbindgen/tests/headers/inner_template_self.hpp diff --git a/tests/headers/int128_t.h b/libbindgen/tests/headers/int128_t.h similarity index 100% rename from tests/headers/int128_t.h rename to libbindgen/tests/headers/int128_t.h diff --git a/tests/headers/jsval_layout_opaque.hpp b/libbindgen/tests/headers/jsval_layout_opaque.hpp similarity index 100% rename from tests/headers/jsval_layout_opaque.hpp rename to libbindgen/tests/headers/jsval_layout_opaque.hpp diff --git a/tests/headers/keywords.h b/libbindgen/tests/headers/keywords.h similarity index 100% rename from tests/headers/keywords.h rename to libbindgen/tests/headers/keywords.h diff --git a/tests/headers/macro-expr-basic.h b/libbindgen/tests/headers/macro-expr-basic.h similarity index 100% rename from tests/headers/macro-expr-basic.h rename to libbindgen/tests/headers/macro-expr-basic.h diff --git a/tests/headers/macro-redef.h b/libbindgen/tests/headers/macro-redef.h similarity index 100% rename from tests/headers/macro-redef.h rename to libbindgen/tests/headers/macro-redef.h diff --git a/tests/headers/multiple-inherit-empty-correct-layout.hpp b/libbindgen/tests/headers/multiple-inherit-empty-correct-layout.hpp similarity index 100% rename from tests/headers/multiple-inherit-empty-correct-layout.hpp rename to libbindgen/tests/headers/multiple-inherit-empty-correct-layout.hpp diff --git a/tests/headers/mutable.hpp b/libbindgen/tests/headers/mutable.hpp similarity index 100% rename from tests/headers/mutable.hpp rename to libbindgen/tests/headers/mutable.hpp diff --git a/tests/headers/namespace.hpp b/libbindgen/tests/headers/namespace.hpp similarity index 100% rename from tests/headers/namespace.hpp rename to libbindgen/tests/headers/namespace.hpp diff --git a/tests/headers/nested.hpp b/libbindgen/tests/headers/nested.hpp similarity index 100% rename from tests/headers/nested.hpp rename to libbindgen/tests/headers/nested.hpp diff --git a/tests/headers/nested_vtable.hpp b/libbindgen/tests/headers/nested_vtable.hpp similarity index 100% rename from tests/headers/nested_vtable.hpp rename to libbindgen/tests/headers/nested_vtable.hpp diff --git a/tests/headers/no-std.h b/libbindgen/tests/headers/no-std.h similarity index 100% rename from tests/headers/no-std.h rename to libbindgen/tests/headers/no-std.h diff --git a/tests/headers/no_copy.hpp b/libbindgen/tests/headers/no_copy.hpp similarity index 100% rename from tests/headers/no_copy.hpp rename to libbindgen/tests/headers/no_copy.hpp diff --git a/tests/headers/nsStyleAutoArray.hpp b/libbindgen/tests/headers/nsStyleAutoArray.hpp similarity index 100% rename from tests/headers/nsStyleAutoArray.hpp rename to libbindgen/tests/headers/nsStyleAutoArray.hpp diff --git a/tests/headers/only_bitfields.hpp b/libbindgen/tests/headers/only_bitfields.hpp similarity index 100% rename from tests/headers/only_bitfields.hpp rename to libbindgen/tests/headers/only_bitfields.hpp diff --git a/tests/headers/opaque_in_struct.hpp b/libbindgen/tests/headers/opaque_in_struct.hpp similarity index 100% rename from tests/headers/opaque_in_struct.hpp rename to libbindgen/tests/headers/opaque_in_struct.hpp diff --git a/tests/headers/opaque_pointer.hpp b/libbindgen/tests/headers/opaque_pointer.hpp similarity index 100% rename from tests/headers/opaque_pointer.hpp rename to libbindgen/tests/headers/opaque_pointer.hpp diff --git a/tests/headers/opaque_typedef.hpp b/libbindgen/tests/headers/opaque_typedef.hpp similarity index 100% rename from tests/headers/opaque_typedef.hpp rename to libbindgen/tests/headers/opaque_typedef.hpp diff --git a/tests/headers/overflowed_enum.hpp b/libbindgen/tests/headers/overflowed_enum.hpp similarity index 100% rename from tests/headers/overflowed_enum.hpp rename to libbindgen/tests/headers/overflowed_enum.hpp diff --git a/tests/headers/overloading.hpp b/libbindgen/tests/headers/overloading.hpp similarity index 100% rename from tests/headers/overloading.hpp rename to libbindgen/tests/headers/overloading.hpp diff --git a/tests/headers/private.hpp b/libbindgen/tests/headers/private.hpp similarity index 100% rename from tests/headers/private.hpp rename to libbindgen/tests/headers/private.hpp diff --git a/tests/headers/redeclaration.hpp b/libbindgen/tests/headers/redeclaration.hpp similarity index 100% rename from tests/headers/redeclaration.hpp rename to libbindgen/tests/headers/redeclaration.hpp diff --git a/tests/headers/ref_argument_array.hpp b/libbindgen/tests/headers/ref_argument_array.hpp similarity index 100% rename from tests/headers/ref_argument_array.hpp rename to libbindgen/tests/headers/ref_argument_array.hpp diff --git a/tests/headers/replace_template_alias.hpp b/libbindgen/tests/headers/replace_template_alias.hpp similarity index 100% rename from tests/headers/replace_template_alias.hpp rename to libbindgen/tests/headers/replace_template_alias.hpp diff --git a/tests/headers/replaces_double.hpp b/libbindgen/tests/headers/replaces_double.hpp similarity index 100% rename from tests/headers/replaces_double.hpp rename to libbindgen/tests/headers/replaces_double.hpp diff --git a/tests/headers/size_t_template.hpp b/libbindgen/tests/headers/size_t_template.hpp similarity index 100% rename from tests/headers/size_t_template.hpp rename to libbindgen/tests/headers/size_t_template.hpp diff --git a/tests/headers/struct_containing_forward_declared_struct.h b/libbindgen/tests/headers/struct_containing_forward_declared_struct.h similarity index 100% rename from tests/headers/struct_containing_forward_declared_struct.h rename to libbindgen/tests/headers/struct_containing_forward_declared_struct.h diff --git a/tests/headers/struct_with_anon_struct.h b/libbindgen/tests/headers/struct_with_anon_struct.h similarity index 100% rename from tests/headers/struct_with_anon_struct.h rename to libbindgen/tests/headers/struct_with_anon_struct.h diff --git a/tests/headers/struct_with_anon_struct_array.h b/libbindgen/tests/headers/struct_with_anon_struct_array.h similarity index 100% rename from tests/headers/struct_with_anon_struct_array.h rename to libbindgen/tests/headers/struct_with_anon_struct_array.h diff --git a/tests/headers/struct_with_anon_struct_pointer.h b/libbindgen/tests/headers/struct_with_anon_struct_pointer.h similarity index 100% rename from tests/headers/struct_with_anon_struct_pointer.h rename to libbindgen/tests/headers/struct_with_anon_struct_pointer.h diff --git a/tests/headers/struct_with_anon_union.h b/libbindgen/tests/headers/struct_with_anon_union.h similarity index 100% rename from tests/headers/struct_with_anon_union.h rename to libbindgen/tests/headers/struct_with_anon_union.h diff --git a/tests/headers/struct_with_anon_unnamed_struct.h b/libbindgen/tests/headers/struct_with_anon_unnamed_struct.h similarity index 100% rename from tests/headers/struct_with_anon_unnamed_struct.h rename to libbindgen/tests/headers/struct_with_anon_unnamed_struct.h diff --git a/tests/headers/struct_with_anon_unnamed_union.h b/libbindgen/tests/headers/struct_with_anon_unnamed_union.h similarity index 100% rename from tests/headers/struct_with_anon_unnamed_union.h rename to libbindgen/tests/headers/struct_with_anon_unnamed_union.h diff --git a/tests/headers/struct_with_bitfields.h b/libbindgen/tests/headers/struct_with_bitfields.h similarity index 100% rename from tests/headers/struct_with_bitfields.h rename to libbindgen/tests/headers/struct_with_bitfields.h diff --git a/tests/headers/struct_with_derive_debug.h b/libbindgen/tests/headers/struct_with_derive_debug.h similarity index 100% rename from tests/headers/struct_with_derive_debug.h rename to libbindgen/tests/headers/struct_with_derive_debug.h diff --git a/tests/headers/struct_with_nesting.h b/libbindgen/tests/headers/struct_with_nesting.h similarity index 100% rename from tests/headers/struct_with_nesting.h rename to libbindgen/tests/headers/struct_with_nesting.h diff --git a/tests/headers/struct_with_packing.h b/libbindgen/tests/headers/struct_with_packing.h similarity index 100% rename from tests/headers/struct_with_packing.h rename to libbindgen/tests/headers/struct_with_packing.h diff --git a/tests/headers/struct_with_struct.h b/libbindgen/tests/headers/struct_with_struct.h similarity index 100% rename from tests/headers/struct_with_struct.h rename to libbindgen/tests/headers/struct_with_struct.h diff --git a/tests/headers/struct_with_typedef_template_arg.hpp b/libbindgen/tests/headers/struct_with_typedef_template_arg.hpp similarity index 100% rename from tests/headers/struct_with_typedef_template_arg.hpp rename to libbindgen/tests/headers/struct_with_typedef_template_arg.hpp diff --git a/tests/headers/template.hpp b/libbindgen/tests/headers/template.hpp similarity index 100% rename from tests/headers/template.hpp rename to libbindgen/tests/headers/template.hpp diff --git a/tests/headers/template_alias.hpp b/libbindgen/tests/headers/template_alias.hpp similarity index 100% rename from tests/headers/template_alias.hpp rename to libbindgen/tests/headers/template_alias.hpp diff --git a/tests/headers/template_alias_basic.hpp b/libbindgen/tests/headers/template_alias_basic.hpp similarity index 100% rename from tests/headers/template_alias_basic.hpp rename to libbindgen/tests/headers/template_alias_basic.hpp diff --git a/tests/headers/template_alias_namespace.hpp b/libbindgen/tests/headers/template_alias_namespace.hpp similarity index 100% rename from tests/headers/template_alias_namespace.hpp rename to libbindgen/tests/headers/template_alias_namespace.hpp diff --git a/tests/headers/template_typedef_transitive_param.hpp b/libbindgen/tests/headers/template_typedef_transitive_param.hpp similarity index 100% rename from tests/headers/template_typedef_transitive_param.hpp rename to libbindgen/tests/headers/template_typedef_transitive_param.hpp diff --git a/tests/headers/template_typedefs.hpp b/libbindgen/tests/headers/template_typedefs.hpp similarity index 100% rename from tests/headers/template_typedefs.hpp rename to libbindgen/tests/headers/template_typedefs.hpp diff --git a/tests/headers/type_alias_empty.hpp b/libbindgen/tests/headers/type_alias_empty.hpp similarity index 100% rename from tests/headers/type_alias_empty.hpp rename to libbindgen/tests/headers/type_alias_empty.hpp diff --git a/tests/headers/typeref.hpp b/libbindgen/tests/headers/typeref.hpp similarity index 100% rename from tests/headers/typeref.hpp rename to libbindgen/tests/headers/typeref.hpp diff --git a/tests/headers/union_dtor.hpp b/libbindgen/tests/headers/union_dtor.hpp similarity index 100% rename from tests/headers/union_dtor.hpp rename to libbindgen/tests/headers/union_dtor.hpp diff --git a/tests/headers/union_fields.hpp b/libbindgen/tests/headers/union_fields.hpp similarity index 100% rename from tests/headers/union_fields.hpp rename to libbindgen/tests/headers/union_fields.hpp diff --git a/tests/headers/union_template.hpp b/libbindgen/tests/headers/union_template.hpp similarity index 100% rename from tests/headers/union_template.hpp rename to libbindgen/tests/headers/union_template.hpp diff --git a/tests/headers/union_with_anon_struct.h b/libbindgen/tests/headers/union_with_anon_struct.h similarity index 100% rename from tests/headers/union_with_anon_struct.h rename to libbindgen/tests/headers/union_with_anon_struct.h diff --git a/tests/headers/union_with_anon_struct_bitfield.h b/libbindgen/tests/headers/union_with_anon_struct_bitfield.h similarity index 100% rename from tests/headers/union_with_anon_struct_bitfield.h rename to libbindgen/tests/headers/union_with_anon_struct_bitfield.h diff --git a/tests/headers/union_with_anon_union.h b/libbindgen/tests/headers/union_with_anon_union.h similarity index 100% rename from tests/headers/union_with_anon_union.h rename to libbindgen/tests/headers/union_with_anon_union.h diff --git a/tests/headers/union_with_anon_unnamed_struct.h b/libbindgen/tests/headers/union_with_anon_unnamed_struct.h similarity index 100% rename from tests/headers/union_with_anon_unnamed_struct.h rename to libbindgen/tests/headers/union_with_anon_unnamed_struct.h diff --git a/tests/headers/union_with_anon_unnamed_union.h b/libbindgen/tests/headers/union_with_anon_unnamed_union.h similarity index 100% rename from tests/headers/union_with_anon_unnamed_union.h rename to libbindgen/tests/headers/union_with_anon_unnamed_union.h diff --git a/tests/headers/union_with_big_member.h b/libbindgen/tests/headers/union_with_big_member.h similarity index 100% rename from tests/headers/union_with_big_member.h rename to libbindgen/tests/headers/union_with_big_member.h diff --git a/tests/headers/union_with_nesting.h b/libbindgen/tests/headers/union_with_nesting.h similarity index 100% rename from tests/headers/union_with_nesting.h rename to libbindgen/tests/headers/union_with_nesting.h diff --git a/tests/headers/unknown_attr.h b/libbindgen/tests/headers/unknown_attr.h similarity index 100% rename from tests/headers/unknown_attr.h rename to libbindgen/tests/headers/unknown_attr.h diff --git a/tests/headers/use-core.h b/libbindgen/tests/headers/use-core.h similarity index 100% rename from tests/headers/use-core.h rename to libbindgen/tests/headers/use-core.h diff --git a/tests/headers/using.hpp b/libbindgen/tests/headers/using.hpp similarity index 100% rename from tests/headers/using.hpp rename to libbindgen/tests/headers/using.hpp diff --git a/tests/headers/vector.hpp b/libbindgen/tests/headers/vector.hpp similarity index 100% rename from tests/headers/vector.hpp rename to libbindgen/tests/headers/vector.hpp diff --git a/tests/headers/virtual_dtor.hpp b/libbindgen/tests/headers/virtual_dtor.hpp similarity index 100% rename from tests/headers/virtual_dtor.hpp rename to libbindgen/tests/headers/virtual_dtor.hpp diff --git a/tests/headers/virtual_overloaded.hpp b/libbindgen/tests/headers/virtual_overloaded.hpp similarity index 100% rename from tests/headers/virtual_overloaded.hpp rename to libbindgen/tests/headers/virtual_overloaded.hpp diff --git a/tests/headers/vtable_recursive_sig.hpp b/libbindgen/tests/headers/vtable_recursive_sig.hpp similarity index 100% rename from tests/headers/vtable_recursive_sig.hpp rename to libbindgen/tests/headers/vtable_recursive_sig.hpp diff --git a/tests/headers/weird_bitfields.hpp b/libbindgen/tests/headers/weird_bitfields.hpp similarity index 100% rename from tests/headers/weird_bitfields.hpp rename to libbindgen/tests/headers/weird_bitfields.hpp diff --git a/tests/headers/what_is_going_on.hpp b/libbindgen/tests/headers/what_is_going_on.hpp similarity index 100% rename from tests/headers/what_is_going_on.hpp rename to libbindgen/tests/headers/what_is_going_on.hpp diff --git a/tests/headers/whitelist_basic.hpp b/libbindgen/tests/headers/whitelist_basic.hpp similarity index 100% rename from tests/headers/whitelist_basic.hpp rename to libbindgen/tests/headers/whitelist_basic.hpp diff --git a/tests/headers/whitelist_vars.h b/libbindgen/tests/headers/whitelist_vars.h similarity index 100% rename from tests/headers/whitelist_vars.h rename to libbindgen/tests/headers/whitelist_vars.h diff --git a/libbindgen/tests/tests.rs b/libbindgen/tests/tests.rs new file mode 100644 index 0000000000..c98262608e --- /dev/null +++ b/libbindgen/tests/tests.rs @@ -0,0 +1,138 @@ +extern crate clap; +extern crate diff; +#[macro_use] +extern crate env_logger; +extern crate libbindgen; +extern crate log; +extern crate shlex; + +use std::env; +use std::fs; +use std::io::{BufRead, BufReader, Error, ErrorKind, Read}; +use std::path::{Path, PathBuf}; + +#[path="../../src/options.rs"] +mod options; +use options::builder_from_flags; + +fn compare_generated_header(header: &PathBuf, + builder: libbindgen::Builder) + -> Result<(), Error> { + let file_name = try!(header.file_name() + .ok_or(Error::new(ErrorKind::Other, "spawn_bindgen expects a file"))); + + let mut expected = PathBuf::from(header); + expected.pop(); + expected.pop(); + expected.push("expectations"); + expected.push("tests"); + expected.push(file_name); + expected.set_extension("rs"); + + // We skip the generate() error here so we get a full diff below + let output = match builder.generate() { + Ok(bindings) => bindings.to_string(), + Err(_) => "".to_string(), + }; + + let mut buffer = String::new(); + let f = try!(fs::File::open(&expected)); + let _ = try!(BufReader::new(f).read_to_string(&mut buffer)); + + if output == buffer { + return Ok(()); + } + + println!("diff expected generated"); + println!("--- expected: {:?}", expected); + println!("+++ generated from: {:?}", header); + + for diff in diff::lines(&buffer, &output) { + match diff { + diff::Result::Left(l) => println!("-{}", l), + diff::Result::Both(l, _) => println!(" {}", l), + diff::Result::Right(r) => println!("+{}", r), + } + } + Err(Error::new(ErrorKind::Other, "Header and binding differ!")) +} + +fn create_bindgen_builder(header: &PathBuf) + -> Result { + let source = try!(fs::File::open(header)); + let reader = BufReader::new(source); + + // Scoop up bindgen-flags from test header + let line: String = try!(reader.lines().take(1).collect()); + let flags: Vec = if line.contains("bindgen-flags:") { + line.split("bindgen-flags:").last().and_then(shlex::split) + } else { + None + }.unwrap_or(Vec::with_capacity(2)); + + // Fool builder_from_flags() into believing it has real env::args_os... + // - add "bindgen" as executable name 0th element + // - add header filename as 1st element + // - prepend raw lines so they're in the right order for expected output + // - append the test header's bindgen flags + let header_str = try!(header.to_str() + .ok_or(Error::new(ErrorKind::Other, "Invalid header file name"))); + + let prepend = [ + "bindgen", + header_str, + "--raw-line", "", + "--raw-line", "#![allow(non_snake_case)]", + "--raw-line", "", + ]; + + let args = prepend.into_iter() + .map(ToString::to_string) + .chain(flags.into_iter()); + + builder_from_flags(args).map(|(builder, _)| builder.no_unstable_rust()) +} + +#[test] +fn run_bindgen_tests() { + log::set_logger(|max_log_level| { + use env_logger::Logger; + let env_logger = Logger::new(); + max_log_level.set(env_logger.filter()); + Box::new(env_logger) + }) + .expect("Failed to set logger."); + + let manifest_env = env::var("CARGO_MANIFEST_DIR") + .expect("CARGO_MANIFEST_DIR not set!"); + let manifest_dir = Path::new(&manifest_env); + let headers_dir = manifest_dir.join("tests").join("headers"); + + let entries = fs::read_dir(&headers_dir) + .expect("Couldn't read headers dir") + .map(|result| result.expect("Couldn't read header file")); + + let headers: Vec<_> = entries.filter_map(|entry| { + match entry.path().extension().and_then(|s| s.to_str()) { + Some("h") | Some("hpp") => Some(entry.path()), + _ => None, + } + }) + .collect(); + + let failures: Vec<_> = headers.iter() + .filter_map(|header| { + create_bindgen_builder(header) + .and_then(|builder| compare_generated_header(header, builder)) + .err() + }) + .collect(); + + let num_failures = failures.len(); + + if num_failures > 0 { + panic!("{} test{} failed!", + num_failures, + if num_failures > 1 {"s"} else {""}); + } +} diff --git a/tests/uses/.gitignore b/libbindgen/tests/uses/.gitignore similarity index 100% rename from tests/uses/.gitignore rename to libbindgen/tests/uses/.gitignore diff --git a/src/bin/bindgen.rs b/src/main.rs old mode 100755 new mode 100644 similarity index 96% rename from src/bin/bindgen.rs rename to src/main.rs index 14e882bccf..8cbff63bb8 --- a/src/bin/bindgen.rs +++ b/src/main.rs @@ -1,7 +1,4 @@ -#![crate_name = "bindgen"] -#![crate_type = "bin"] - -extern crate bindgen; +extern crate libbindgen; extern crate env_logger; #[macro_use] extern crate log; @@ -9,7 +6,7 @@ extern crate clang_sys; extern crate clap; extern crate rustc_serialize; -use bindgen::clang_version; +use libbindgen::clang_version; use std::env; mod options; diff --git a/src/bin/options.rs b/src/options.rs similarity index 99% rename from src/bin/options.rs rename to src/options.rs index 9f746fd087..c3c6a1f269 100644 --- a/src/bin/options.rs +++ b/src/options.rs @@ -1,8 +1,5 @@ - - -use bindgen::{Builder, builder}; - use clap::{App, Arg}; +use libbindgen::{Builder, builder}; use std::fs::File; use std::io::{self, Error, ErrorKind}; diff --git a/tests/tests.rs b/tests/tests.rs deleted file mode 100644 index 1f72fccf9d..0000000000 --- a/tests/tests.rs +++ /dev/null @@ -1,171 +0,0 @@ -// We add this `extern crate` here to ensure that bindgen is up-to-date and -// rebuilt, even though we aren't using any of its types or functions here, only -// indirectly calling the executable. -#[allow(dead_code)] -extern crate bindgen; - -use std::env; -use std::fs; -use std::io::Read; -use std::path::{Path, PathBuf}; -use std::process; - -const TEST_BATCH_DEFAULT_SIZE: usize = 16; - -fn spawn_run_bindgen(run_bindgen: P, - bindgen: Q, - header: R) - -> process::Child - where P: AsRef, - Q: AsRef, - R: AsRef, -{ - let run_bindgen = run_bindgen.as_ref(); - let bindgen = bindgen.as_ref(); - let header = header.as_ref(); - - // Convert from "tests/headers/foo.hpp" to "tests/expectations/tests/foo.rs" by - // saving the filename, popping off "headers/foo.hpp", pushing - // "expectations/tests", pushing the saved filename, and finally modifying the - // extension. - - let mut expected = PathBuf::from(header); - let file_name = expected.file_name() - .expect("Should have filename") - .to_os_string(); - expected.pop(); - expected.pop(); - expected.push("expectations"); - expected.push("tests"); - expected.push(file_name); - expected.set_extension("rs"); - - // And the same style conversion as above, but for the dummy uses. We assume - // that .hpp means we should generate a .cpp uses file, and .h means we - // should generate a .c file. - - let mut dummy_uses = PathBuf::from(header); - let file_name = dummy_uses.file_name() - .expect("Should still have filename") - .to_os_string(); - dummy_uses.pop(); - dummy_uses.pop(); - dummy_uses.push("uses"); - dummy_uses.push(file_name); - dummy_uses.set_extension(if header.extension().and_then(|s| s.to_str()) == - Some("hpp") { - "cpp" - } else { - "c" - }); - - process::Command::new(run_bindgen) - .stdout(process::Stdio::piped()) - .stderr(process::Stdio::piped()) - .arg(bindgen) - .arg(header) - .arg(expected) - .arg("--dummy-uses") - .arg(dummy_uses) - .spawn() - .expect("Should be able to spawn run-bindgen.py child process") -} - -#[test] -fn run_bindgen_tests() { - let crate_root = env::var("CARGO_MANIFEST_DIR") - .expect("should have CARGO_MANIFEST_DIR environment variable"); - - let mut run_bindgen = PathBuf::from(&crate_root); - run_bindgen.push("tests"); - run_bindgen.push("tools"); - run_bindgen.push("run-bindgen.py"); - - let mut bindgen = PathBuf::from(&crate_root); - bindgen.push("target"); - if cfg!(debug_assertions) { - bindgen.push("debug"); - } else { - bindgen.push("release"); - } - bindgen.push("bindgen"); - if !bindgen.is_file() { - panic!("{} is not a file! Build bindgen before running tests.", - bindgen.display()); - } - - let mut headers_dir = PathBuf::from(&crate_root); - headers_dir.push("tests"); - headers_dir.push("headers"); - - let entries = fs::read_dir(&headers_dir) - .expect("Should read directory") - .map(|result| result.expect("Should read directory entry")); - - let tests = entries.filter(|entry| { - match entry.path().extension().and_then(|s| s.to_str()) { - Some("h") | Some("hpp") => true, - _ => false, - } - }) - .collect::>(); - - let batch_size = env::var("BINDGEN_TEST_BATCH_SIZE") - .ok() - .and_then(|x| x.parse::().ok()) - .unwrap_or(TEST_BATCH_DEFAULT_SIZE); - - // Spawn `batch_size` children to run in parallel and wait on all of them - // before processing the next batch. This puts a limit on the resources - // consumed when testing, so that we don't overload the system. - - let children = tests.chunks(batch_size).map(|x| { - x.iter() - .map(|entry| { - let child = spawn_run_bindgen(run_bindgen.clone(), - bindgen.clone(), - entry.path()); - (entry.path(), child) - }) - .collect::>() - }); - - let failures: Vec<_> = children.flat_map(|x| { - x.into_iter().filter_map(|(path, mut child)| { - let passed = child.wait() - .expect("Should wait on child process") - .success(); - - if passed { None } else { Some((path, child)) } - }) - }) - .collect(); - - let num_failures = failures.len(); - - for (path, child) in failures { - println!("FAIL: {}", path.display()); - - let mut buf = String::new(); - - child.stdout - .expect("should have stdout piped") - .read_to_string(&mut buf) - .expect("should read child's stdout"); - for line in buf.lines() { - println!("child stdout> {}", line); - } - - child.stderr - .expect("should have stderr piped") - .read_to_string(&mut buf) - .expect("should read child's stderr"); - for line in buf.lines() { - println!("child stderr> {}", line); - } - } - - if num_failures > 0 { - panic!("{} test failures!", num_failures); - } -} diff --git a/tests/tools/run-bindgen.py b/tests/tools/run-bindgen.py deleted file mode 100755 index 519e6891af..0000000000 --- a/tests/tools/run-bindgen.py +++ /dev/null @@ -1,175 +0,0 @@ -#!/usr/bin/env python - -from __future__ import print_function - -import argparse -import difflib -import os -import sys -import subprocess -import tempfile -import shlex - -BINDGEN_FLAGS_PREFIX = "// bindgen-flags: " - -COMMON_PRELUDE = """ -#![allow(non_snake_case)] -""" - -DESCRIPTION = """ -Run bindgen on a test header and check the generated bindings against expected -output. -""" - -def make_parser(): - """Make the commandline parser""" - parser = argparse.ArgumentParser(description=DESCRIPTION) - parser.add_argument("bindgen", - metavar="BINDGEN", - help="The path to the bindgen executable") - parser.add_argument("header", - metavar="HEADER", - help="The path to the input header") - parser.add_argument("rust_bindings", - metavar="RUST_BINDINGS", - help="The path to the generated rust output. If a file \ - at this path already exists, the newly generated \ - bindings will be checked against those extant \ - expected bindings.") - parser.add_argument("--feature", - dest="features", - action="append", - nargs=1, - help="Run tests that depend on bindgen being built with \ - the given feature.") - parser.add_argument("--dummy-uses", - dest="dummy_uses", - help="The path to generate dummy C/C++ uses of the \ - whitelisted types from the input header at.") - return parser - -def usage_and_exit(*args): - """Print the program usage and exit. If args are given, print them first""" - if len(args) > 0: - print(*args) - make_parser().print_help() - sys.exit(1) - -def parse_args(): - """Get, parse, and validate commandline arguments.""" - parser = make_parser() - args = parser.parse_args() - - if args.features is None: - args.features = [] - - if not os.path.isfile(args.bindgen): - usage_and_exit("error: bindgen is not a file:", args.bindgen) - - if not os.path.isfile(args.header): - usage_and_exit("error: header is not a file:", args.header) - - return args - -def make_bindgen_env(): - """Build the environment to run bindgen in.""" - env = os.environ.copy() - env["RUST_BACKTRACE"] = "1" - - # El Capitan likes to unset dyld variables - # https://forums.developer.apple.com/thread/9233 - if "DYLD_LIBRARY_PATH" not in env and "LIBCLANG_PATH" in env: - env["DYLD_LIBRARY_PATH"] = env["LIBCLANG_PATH"] - - return env - -def get_bindgen_flags(header_path): - """ - Return the bindgen flags required for this header - """ - flags = ["--no-unstable-rust"] - for line in COMMON_PRELUDE.split("\n"): - flags.append("--raw-line") - flags.append(line) - - with open(header_path) as f: - for line in f: - if line.startswith(BINDGEN_FLAGS_PREFIX): - flags.extend(shlex.split(line.strip().split(BINDGEN_FLAGS_PREFIX)[1])) - break - - return flags - -def get_expected_bindings(rust_bindings_path): - """ - Get the expected, generated rust bindings output, or None if there is no - expected output yet. - """ - expected_bindings = None - if os.path.isfile(rust_bindings_path): - with open(rust_bindings_path) as f: - expected_bindings = f.read() - return expected_bindings - -def get_actual_bindings(rust_bindings_path): - """Get the actual generated rust bindings output.""" - assert os.path.isfile(rust_bindings_path) - with open(rust_bindings_path) as f: - return f.read() - -def run_cmd(command, **kwargs): - """Run the given command, passing through **kwargs to subprocess.check_call""" - print("run-bindgen.py: running", command) - subprocess.check_call(command, **kwargs) - -def generate_bindings(bindgen, dummy_uses, flags, header, output): - """Generate the rust bindings.""" - command = [bindgen, "-o", output] - if dummy_uses: - command.extend(["--dummy-uses", dummy_uses]) - command.extend(flags) - command.append(header) - run_cmd(command, cwd=os.getcwd(), env=make_bindgen_env()) - -def check_actual_vs_expected(expected_bindings, rust_bindings_path): - """ - Check the actual generated rust bindings versus our expected generated rust - bindings. If they don't match up, print a diff between them and exit with a - failure. - """ - if expected_bindings is None: - return - - actual_bindings = get_actual_bindings(rust_bindings_path) - if actual_bindings == expected_bindings: - return - - print("error: actual generated bindings do not match expected generated bindings!") - - def to_diffable(s): - return map(lambda l: l + "\n", s.split("\n")) - - diff = difflib.unified_diff(to_diffable(expected_bindings), - to_diffable(actual_bindings), - fromfile="expected_bindings.rs", - tofile="actual_bindings.rs") - sys.stderr.writelines(diff) - sys.stderr.write("\n") - - sys.exit(1) - -def main(): - args = parse_args() - - test_flags = get_bindgen_flags(args.header) - expected_bindings = get_expected_bindings(args.rust_bindings) - generate_bindings(args.bindgen, - args.dummy_uses, - test_flags, - args.header, - args.rust_bindings) - check_actual_vs_expected(expected_bindings, args.rust_bindings) - sys.exit(0) - -if __name__ == "__main__": - main() From c555fcf76a3b3b2e416a8a517e72b319e9a4d18b Mon Sep 17 00:00:00 2001 From: Jeff Waugh Date: Tue, 15 Nov 2016 17:01:08 +1100 Subject: [PATCH 2/3] Document library usage --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 97488b6b71..7187201f16 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,40 @@ $ LIBCLANG_PATH=path/to/clang-3.9/build/lib \ cargo build ``` +# Library usage with `build.rs` + +In `Cargo.toml`: + +```toml +[package] +... +build = "build.rs" + +[build-dependencies.libbindgen] +git = "https://github.com/servo/rust-bindgen" +features = ["llvm_stable"] +``` + +In `build.rs`: + +```rust +extern crate libbindgen; + +fn main() { + let _ = libbindgen::builder() + .header("example.h") + .use_core() + .generate().unwrap() + .write_to_file(concat!(env!("OUT_DIR"), "/example.rs")); +} +``` + +In `src/main.rs`: + +```rust +include!(concat!(env!("OUT_DIR"), "/example.rs")); +``` + # Command Line Usage There are a few options documented when running `./bindgen --help`. Other From 073b12ff35a8ec6314d655804915f177ce453227 Mon Sep 17 00:00:00 2001 From: Jeff Waugh Date: Tue, 15 Nov 2016 17:01:49 +1100 Subject: [PATCH 3/3] Remove plugin and its documentation --- README.md | 8 - bindgen_plugin/Cargo.toml | 20 -- bindgen_plugin/src/bgmacro.rs | 344 ---------------------------------- bindgen_plugin/src/lib.rs | 17 -- 4 files changed, 389 deletions(-) delete mode 100644 bindgen_plugin/Cargo.toml delete mode 100644 bindgen_plugin/src/bgmacro.rs delete mode 100644 bindgen_plugin/src/lib.rs diff --git a/README.md b/README.md index 7187201f16..ead988ecd6 100644 --- a/README.md +++ b/README.md @@ -176,11 +176,3 @@ the ones that would be generated for `nsTArray_Simple`. The `nocopy` annotation is used to prevent bindgen to autoderive the `Copy` and `Clone` traits for a type. - -# Macro Usage - -This mode isn't actively maintained, so no promises are made around it. Check -out the upstream documentation for info about how it *should* work. - -[sm-script]: https://github.com/servo/rust-mozjs/blob/master/etc/bindings.sh -[stylo-scripts]: https://github.com/servo/servo/tree/master/components/style/binding_tools diff --git a/bindgen_plugin/Cargo.toml b/bindgen_plugin/Cargo.toml deleted file mode 100644 index 0ebcb16f50..0000000000 --- a/bindgen_plugin/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] - -name = "bindgen_plugin" -version = "0.16.0" -description = "A binding generator for Rust - compiler plugin" -authors = ["Jyun-Yan You "] -license = "BSD-3-Clause" - -[dependencies.bindgen] -version = "0.16.0" -path = ".." - -[features] -static = [] - -[lib] - -name = "bindgen_plugin" -path = "src/lib.rs" -plugin = true diff --git a/bindgen_plugin/src/bgmacro.rs b/bindgen_plugin/src/bgmacro.rs deleted file mode 100644 index 0e95b9a5af..0000000000 --- a/bindgen_plugin/src/bgmacro.rs +++ /dev/null @@ -1,344 +0,0 @@ -use std::default::Default; -use std::env; -use std::path::Path; - -use syntax::ast; -use syntax::codemap; -use syntax::ext::base; -use syntax::fold::Folder; -use syntax::parse; -use syntax::parse::token; -use syntax::ptr::P; -use syntax::util::small_vector::SmallVector; - -use bindgen::{Bindings, BindgenOptions, LinkType, Logger, self}; - -pub fn bindgen_macro(cx: &mut base::ExtCtxt, sp: codemap::Span, tts: &[ast::TokenTree]) -> Box { - let mut visit = BindgenArgsVisitor { - options: Default::default(), - seen_named: false - }; - - visit.options.builtins = true; - if !parse_macro_opts(cx, tts, &mut visit) { - return base::DummyResult::any(sp); - } - - // Reparse clang_args as it is passed in string form - let clang_args = visit.options.clang_args.connect(" "); - visit.options.clang_args = parse_process_args(&clang_args); - - if let Some(path) = bindgen::get_include_dir() { - visit.options.clang_args.push("-I".to_owned()); - visit.options.clang_args.push(path); - } - - // Set the working dir to the directory containing the invoking rs file so - // that clang searches for headers relative to it rather than the crate root - let filename = cx.codemap().span_to_filename(sp); - let mod_dir = Path::new(&filename).parent().unwrap(); - let cwd = match env::current_dir() { - Ok(d) => d, - Err(e) => panic!("Invalid current working directory: {}", e), - }; - let p = Path::new(mod_dir); - if let Err(e) = env::set_current_dir(&p) { - panic!("Failed to change to directory {}: {}", p.display(), e); - }; - - // We want the span for errors to just match the bindgen! symbol - // instead of the whole invocation which can span multiple lines - let mut short_span = sp; - short_span.hi = short_span.lo + codemap::BytePos(8); - - let logger = MacroLogger { sp: short_span, cx: cx }; - - let ret = match Bindings::generate(&visit.options, Some(&logger as &Logger), None) { - Ok(bindings) => { - // syntex_syntax is not compatible with libsyntax so convert to string and reparse - let bindings_str = bindings.to_string(); - // Unfortunately we lose span information due to reparsing - let mut parser = parse::new_parser_from_source_str(cx.parse_sess(), cx.cfg(), "(Auto-generated bindings)".to_string(), bindings_str); - - let mut items = Vec::new(); - while let Ok(Some(item)) = parser.parse_item() { - items.push(item); - } - - Box::new(BindgenResult { items: Some(SmallVector::many(items)) }) as Box - - } - Err(_) => base::DummyResult::any(sp) - }; - - let p = Path::new(&cwd); - if let Err(e) = env::set_current_dir(&p) { - panic!("Failed to return to directory {}: {}", p.display(), e); - } - - ret -} - -trait MacroArgsVisitor { - fn visit_str(&mut self, name: Option<&str>, val: &str) -> bool; - fn visit_int(&mut self, name: Option<&str>, val: i64) -> bool; - fn visit_bool(&mut self, name: Option<&str>, val: bool) -> bool; - fn visit_ident(&mut self, name: Option<&str>, ident: &str) -> bool; -} - -struct BindgenArgsVisitor { - pub options: BindgenOptions, - seen_named: bool -} - -impl MacroArgsVisitor for BindgenArgsVisitor { - fn visit_str(&mut self, mut name: Option<&str>, val: &str) -> bool { - if name.is_some() { self.seen_named = true; } - else if !self.seen_named { name = Some("clang_args") } - match name { - Some("link") => self.options.links.push((val.to_string(), LinkType::Default)), - Some("link_static") => self.options.links.push((val.to_string(), LinkType::Static)), - Some("link_framework") => self.options.links.push((val.to_string(), LinkType::Framework)), - Some("match") => self.options.match_pat.push(val.to_string()), - Some("clang_args") => self.options.clang_args.push(val.to_string()), - _ => return false - } - true - } - - fn visit_int(&mut self, name: Option<&str>, _val: i64) -> bool { - if name.is_some() { self.seen_named = true; } - false - } - - fn visit_bool(&mut self, name: Option<&str>, val: bool) -> bool { - if name.is_some() { self.seen_named = true; } - match name { - Some("emit_builtins") => self.options.builtins = val, - _ => return false - } - true - } - - fn visit_ident(&mut self, name: Option<&str>, _val: &str) -> bool { - if name.is_some() { self.seen_named = true; } - false - } -} - -// Parses macro invocations in the form [ident=|:]value where value is an ident or literal -// e.g. bindgen!(module_name, "header.h", emit_builtins=false, clang_args:"-I /usr/local/include") -fn parse_macro_opts(cx: &mut base::ExtCtxt, tts: &[ast::TokenTree], visit: &mut MacroArgsVisitor) -> bool { - let mut parser = cx.new_parser_from_tts(tts); - let mut args_good = true; - - loop { - let mut name: Option = None; - let mut span = parser.span; - - // Check for [ident=]value and if found save ident to name - if parser.look_ahead(1, |t| t == &token::Eq) { - match parser.bump_and_get() { - Ok(token::Ident(ident, _)) => { - let ident = parser.id_to_interned_str(ident); - name = Some(ident.to_string()); - if let Err(_) = parser.expect(&token::Eq) { - return false; - } - }, - _ => { - cx.span_err(span, "invalid argument format"); - return false - } - } - } - - match parser.token { - // Match [ident] - token::Ident(val, _) => { - let val = parser.id_to_interned_str(val); - span.hi = parser.span.hi; - if let Err(_) = parser.bump() { - return false; - } - - // Bools are simply encoded as idents - let ret = match &*val { - "true" => visit.visit_bool(as_str(&name), true), - "false" => visit.visit_bool(as_str(&name), false), - val => visit.visit_ident(as_str(&name), val) - }; - if !ret { - cx.span_err(span, "invalid argument"); - args_good = false; - } - } - // Match [literal] and parse as an expression so we can expand macros - _ => { - let expr = cx.expander().fold_expr(parser.parse_expr().unwrap()); - span.hi = expr.span.hi; - match expr.node { - ast::ExprLit(ref lit) => { - let ret = match lit.node { - ast::LitStr(ref s, _) => visit.visit_str(as_str(&name), &*s), - ast::LitBool(b) => visit.visit_bool(as_str(&name), b), - ast::LitInt(i, ast::SignedIntLit(_, sign)) | - ast::LitInt(i, ast::UnsuffixedIntLit(sign)) => { - let i = i as i64; - let i = if sign == ast::Minus { -i } else { i }; - visit.visit_int(as_str(&name), i) - }, - ast::LitInt(i, ast::UnsignedIntLit(_)) => visit.visit_int(as_str(&name), i as i64), - _ => { - cx.span_err(span, "invalid argument format"); - return false - } - }; - if !ret { - cx.span_err(span, "invalid argument"); - args_good = false; - } - }, - _ => { - cx.span_err(span, "invalid argument format"); - return false - } - } - } - } - - if parser.check(&token::Eof) { - return args_good - } - - if parser.eat(&token::Comma).is_err() { - cx.span_err(parser.span, "invalid argument format"); - return false - } - } -} - -// I'm sure there's a nicer way of doing it -fn as_str<'a>(owned: &'a Option) -> Option<&'a str> { - match owned { - &Some(ref s) => Some(s), - &None => None - } -} - -#[derive(PartialEq, Eq)] -enum QuoteState { - InNone, - InSingleQuotes, - InDoubleQuotes -} - -fn parse_process_args(s: &str) -> Vec { - let s = s.trim(); - let mut parts = Vec::new(); - let mut quote_state = QuoteState::InNone; - let mut positions = vec!(0); - let mut last = ' '; - for (i, c) in s.chars().chain(" ".chars()).enumerate() { - match (last, c) { - // Match \" set has_escaped and skip - ('\\', '\"') => (), - // Match \' - ('\\', '\'') => (), - // Match \ - // Check we don't escape the final added space - ('\\', ' ') if i < s.len() => (), - // Match \\ - ('\\', '\\') => (), - // Match " - (_, '\"') if quote_state == QuoteState::InNone => { - quote_state = QuoteState::InDoubleQuotes; - positions.push(i); - positions.push(i + 1); - }, - (_, '\"') if quote_state == QuoteState::InDoubleQuotes => { - quote_state = QuoteState::InNone; - positions.push(i); - positions.push(i + 1); - }, - // Match ' - (_, '\'') if quote_state == QuoteState::InNone => { - quote_state = QuoteState::InSingleQuotes; - positions.push(i); - positions.push(i + 1); - }, - (_, '\'') if quote_state == QuoteState::InSingleQuotes => { - quote_state = QuoteState::InNone; - positions.push(i); - positions.push(i + 1); - }, - // Match - // If we are at the end of the string close any open quotes - (_, ' ') if quote_state == QuoteState::InNone || i >= s.len() => { - { - positions.push(i); - - let starts = positions.iter().enumerate().filter(|&(i, _)| i % 2 == 0); - let ends = positions.iter().enumerate().filter(|&(i, _)| i % 2 == 1); - - let part: Vec = starts.zip(ends).map(|((_, start), (_, end))| s[*start..*end].to_string()).collect(); - - let part = part.join(""); - - if part.len() > 0 { - // Remove any extra whitespace outside the quotes - let part = part.trim(); - // Replace quoted characters - let part = part.replace("\\\"", "\""); - let part = part.replace("\\\'", "\'"); - let part = part.replace("\\ ", " "); - let part = part.replace("\\\\", "\\"); - parts.push(part); - } - } - - positions.clear(); - positions.push(i + 1); - }, - (_, _) => () - } - last = c; - } - parts -} - -struct MacroLogger<'a, 'b:'a> { - sp: codemap::Span, - cx: &'a base::ExtCtxt<'b> -} - -impl<'a, 'b> Logger for MacroLogger<'a, 'b> { - fn error(&self, msg: &str) { - self.cx.span_err(self.sp, msg) - } - - fn warn(&self, msg: &str) { - self.cx.span_warn(self.sp, msg) - } -} - -struct BindgenResult { - items: Option>> -} - -impl base::MacResult for BindgenResult { - fn make_items(mut self: Box) -> Option>> { - self.items.take() - } -} - -#[test] -fn test_parse_process_args() { - assert_eq!(parse_process_args("a b c"), vec!("a", "b", "c")); - assert_eq!(parse_process_args("a \"b\" c"), vec!("a", "b", "c")); - assert_eq!(parse_process_args("a \'b\' c"), vec!("a", "b", "c")); - assert_eq!(parse_process_args("a \"b c\""), vec!("a", "b c")); - assert_eq!(parse_process_args("a \'\"b\"\' c"), vec!("a", "\"b\"", "c")); - assert_eq!(parse_process_args("a b\\ c"), vec!("a", "b c")); - assert_eq!(parse_process_args("a b c\\"), vec!("a", "b", "c\\")); -} diff --git a/bindgen_plugin/src/lib.rs b/bindgen_plugin/src/lib.rs deleted file mode 100644 index 970e06ecf2..0000000000 --- a/bindgen_plugin/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![crate_name = "bindgen_plugin"] -#![crate_type = "dylib"] -#![feature(plugin_registrar, rustc_private)] - -extern crate bindgen; -extern crate rustc_plugin; -extern crate syntax; - -mod bgmacro; - -use rustc_plugin::Registry; - -#[doc(hidden)] -#[plugin_registrar] -pub fn plugin_registrar(reg: &mut Registry) { - reg.register_macro("bindgen", bgmacro::bindgen_macro); -}