Skip to content

Gate on libclang 4 CI passing :) #720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ env:
global:
- CARGO_TARGET_DIR=/tmp/bindgen
matrix:
- LLVM_VERSION=3.7.1 BINDGEN_FEATURES=testing_only_llvm_stable
- LLVM_VERSION=3.8.1 BINDGEN_FEATURES=testing_only_llvm_stable
- LLVM_VERSION=3.9.0 BINDGEN_FEATURES=
- LLVM_VERSION=4.0.0 BINDGEN_FEATURES=
- LLVM_VERSION=3.7.1 BINDGEN_FEATURES=testing_only_libclang_3_8
- LLVM_VERSION=3.8.1 BINDGEN_FEATURES=testing_only_libclang_3_8
- LLVM_VERSION=3.9.0 BINDGEN_FEATURES=testing_only_libclang_3_9
- LLVM_VERSION=4.0.0 BINDGEN_FEATURES=testing_only_libclang_4

matrix:
fast_finish: true
allow_failures:
- env: LLVM_VERSION=4.0.0 BINDGEN_FEATURES=
- env: LLVM_VERSION=3.7.1 BINDGEN_FEATURES=testing_only_llvm_stable
- env: LLVM_VERSION=3.7.1 BINDGEN_FEATURES=testing_only_libclang_3_8

cache:
directories:
Expand Down
31 changes: 30 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ out to us in a GitHub issue, or stop by
- [Testing](#testing)
- [Overview](#overview)
- [Running All Tests](#running-all-tests)
- [Running a Single Test](#running-a-single-test)
- [Authoring New Tests](#authoring-new-tests)
- [Test Expectations and `libclang` Versions](#test-expectations-and-libclang-versions)
- [Automatic code formatting](#automatic-code-formatting)
- [Generating Graphviz Dot Files](#generating-graphviz-dot-files)
- [Debug Logging](#debug-logging)
Expand Down Expand Up @@ -91,9 +93,17 @@ Run `cargo test` to compare generated Rust bindings to the expectations.
### Running All Tests

```
$ cargo test [--all-features]
$ cargo test --features testing_only_libclang_$VERSION
```

Where `$VERSION` is one of:

* `4`
* `3_9`
* `3_8`

depending on which version of `libclang` you have installed.

### Running a Single Test

To generate bindings for a single test header, compile the bindings, and run the
Expand Down Expand Up @@ -124,6 +134,25 @@ Then verify the new Rust bindings compile and pass some basic tests:
$ cargo test -p tests_expectations
```

### Test Expectations and `libclang` Versions

If a test generates different bindings across different `libclang` versions (for
example, because we take advantage of better/newer APIs when possible), then you
can add multiple test expectations, one for each supported `libclang`
version. Instead of having a single `tests/expectations/tests/my_test.rs` file,
add each of:

* `tests/expectations/tests/libclang-4/my_test.rs`
* `tests/expectations/tests/libclang-3.9/my_test.rs`
* `tests/expectations/tests/libclang-3.8/my_test.rs`

If you need to update the test expectations for a test file that generates
different bindings for different `libclang` versions, you *don't* need to have
many version of `libclang` installed locally. Just make a work-in-progress pull
request, and then when Travis CI fails, it will log a diff of the
expectations. Use the diff to patch the appropriate expectation file locally and
then update your pull request.

## Automatic code formatting

We use [`rustfmt`](https://github.com/rust-lang-nursery/rustfmt) to enforce a
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,6 @@ static = []
# on bindgen!
testing_only_docs = []
testing_only_extra_assertions = []
testing_only_llvm_stable = []
testing_only_libclang_4 = []
testing_only_libclang_3_9 = []
testing_only_libclang_3_8 = []
4 changes: 3 additions & 1 deletion bindgen-integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ bindgen = { path = ".." }
gcc = "0.3"

[features]
testing_only_llvm_stable = ["bindgen/testing_only_llvm_stable"]
testing_only_libclang_4 = ["bindgen/testing_only_libclang_4"]
testing_only_libclang_3_9 = ["bindgen/testing_only_libclang_3_9"]
testing_only_libclang_3_8 = ["bindgen/testing_only_libclang_3_8"]
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ pub fn main() {
let bind_args: Vec<_> = env::args().collect();

let version = clang_version();
let expected_version = if cfg!(feature = "testing_only_llvm_stable") {
let expected_version = if cfg!(feature = "testing_only_libclang_4") {
(4, 0)
} else if cfg!(feature = "testing_only_libclang_3_8") {
(3, 8)
} else {
// Default to 3.9.
(3, 9)
};

Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/16-byte-alignment.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/381-decltype-alias.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/accessors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/annotation_hide.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


/**
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/anon_enum.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/anon_enum_trait.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/anon_enum_whitelist.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


pub const NODE_FLAG_FOO: _bindgen_ty_1 = _bindgen_ty_1::NODE_FLAG_FOO;
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/anon_struct_in_union.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/anon_union.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/anonymous-template-types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/arg_keyword.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


extern "C" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/base-to-derived.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/bitfield-enum-basic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


pub const Foo_Bar: Foo = Foo(2);
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/bitfield-large.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/bitfield-method-same-name.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/bitfield_align.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/bitfield_method_mangling.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/blocks.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/builtin-template.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


pub type std_make_integer_sequence = u8;
2 changes: 1 addition & 1 deletion tests/expectations/tests/c-empty-layout.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/char.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


pub type Char = ::std::os::raw::c_char;
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/class.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/class_nested.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/class_no_members.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/class_static.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/class_static_const.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/class_use_as.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


/**
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/class_with_dtor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/class_with_inner_struct.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion tests/expectations/tests/class_with_typedef.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


pub type AnotherInt = ::std::os::raw::c_int;
Expand Down
Loading