mirror of
https://gitee.com/openharmony/third_party_rust_bindgen
synced 2024-12-04 05:22:20 +00:00
Now that we have stuff that depends on libclang-5 we need to do this.
This commit is contained in:
parent
fa1245198a
commit
ae0fdf7a55
18
.travis.yml
18
.travis.yml
@ -20,19 +20,23 @@ env:
|
||||
- LLVM_VERSION="3.9.0" BINDGEN_JOB="integration" BINDGEN_PROFILE="--release"
|
||||
- LLVM_VERSION="4.0.0" BINDGEN_JOB="test" BINDGEN_PROFILE=
|
||||
- LLVM_VERSION="4.0.0" BINDGEN_JOB="test" BINDGEN_PROFILE="--release"
|
||||
- LLVM_VERSION="4.0.0" BINDGEN_JOB="test" BINDGEN_PROFILE= BINDGEN_FEATURES="testing_only_extra_assertions"
|
||||
- LLVM_VERSION="4.0.0" BINDGEN_JOB="test" BINDGEN_PROFILE="--release" BINDGEN_FEATURES="testing_only_extra_assertions"
|
||||
- LLVM_VERSION="4.0.0" BINDGEN_JOB="integration" BINDGEN_PROFILE=
|
||||
- LLVM_VERSION="4.0.0" BINDGEN_JOB="integration" BINDGEN_PROFILE="--release"
|
||||
- LLVM_VERSION="4.0.0" BINDGEN_JOB="expectations" BINDGEN_PROFILE=
|
||||
- LLVM_VERSION="4.0.0" BINDGEN_JOB="expectations" BINDGEN_PROFILE="--release"
|
||||
- LLVM_VERSION="4.0.0" BINDGEN_JOB="misc"
|
||||
- LLVM_VERSION="4.0.0" BINDGEN_JOB="quickchecking"
|
||||
- LLVM_VERSION="5.0.0" BINDGEN_JOB="test" BINDGEN_PROFILE=
|
||||
- LLVM_VERSION="5.0.0" BINDGEN_JOB="test" BINDGEN_PROFILE="--release"
|
||||
- LLVM_VERSION="5.0.0" BINDGEN_JOB="test" BINDGEN_PROFILE= BINDGEN_FEATURES="testing_only_extra_assertions"
|
||||
- LLVM_VERSION="5.0.0" BINDGEN_JOB="test" BINDGEN_PROFILE="--release" BINDGEN_FEATURES="testing_only_extra_assertions"
|
||||
- LLVM_VERSION="5.0.0" BINDGEN_JOB="integration" BINDGEN_PROFILE=
|
||||
- LLVM_VERSION="5.0.0" BINDGEN_JOB="integration" BINDGEN_PROFILE="--release"
|
||||
- LLVM_VERSION="5.0.0" BINDGEN_JOB="expectations" BINDGEN_PROFILE=
|
||||
- LLVM_VERSION="5.0.0" BINDGEN_JOB="expectations" BINDGEN_PROFILE="--release"
|
||||
- LLVM_VERSION="5.0.0" BINDGEN_JOB="misc"
|
||||
- LLVM_VERSION="5.0.0" BINDGEN_JOB="quickchecking"
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- env: LLVM_VERSION=4.0.0 BINDGEN_JOB=rustfmt
|
||||
- env: LLVM_VERSION=5.0.0 BINDGEN_JOB=rustfmt
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
@ -71,6 +71,7 @@ static = []
|
||||
# on bindgen!
|
||||
testing_only_docs = []
|
||||
testing_only_extra_assertions = []
|
||||
testing_only_libclang_5 = []
|
||||
testing_only_libclang_4 = []
|
||||
testing_only_libclang_3_9 = []
|
||||
testing_only_libclang_3_8 = []
|
||||
|
@ -8,12 +8,18 @@ environment:
|
||||
- TARGET: gnu
|
||||
LLVM_VERSION: 4.0.0-1
|
||||
BINDGEN_FEATURES: testing_only_libclang_4
|
||||
- TARGET: msvc
|
||||
LLVM_VERSION: 5.0.0-1
|
||||
BINDGEN_FEATURES: testing_only_libclang_5
|
||||
- TARGET: msvc
|
||||
LLVM_VERSION: 3.9.0
|
||||
BINDGEN_FEATURES: testing_only_libclang_3_9
|
||||
- TARGET: msvc
|
||||
LLVM_VERSION: 4.0.0
|
||||
BINDGEN_FEATURES: testing_only_libclang_4
|
||||
- TARGET: msvc
|
||||
LLVM_VERSION: 5.0.0
|
||||
BINDGEN_FEATURES: testing_only_libclang_5
|
||||
|
||||
configuration:
|
||||
- stable
|
||||
|
@ -11,6 +11,7 @@ bindgen = { path = ".." }
|
||||
gcc = "0.3"
|
||||
|
||||
[features]
|
||||
testing_only_libclang_5 = ["bindgen/testing_only_libclang_5"]
|
||||
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"]
|
||||
|
@ -9,7 +9,7 @@ use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
const LIBCLANG_VERSION_DIRS: &'static [&'static str] =
|
||||
&["libclang-3.8", "libclang-3.9", "libclang-4"];
|
||||
&["libclang-3.8", "libclang-3.9", "libclang-4", "libclang-5"];
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
|
||||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
|
||||
#![cfg(not(test))]
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
|
||||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
|
||||
#![cfg(not(test))]
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
|
||||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
|
||||
#![cfg(not(test))]
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
|
34
tests/expectations/tests/libclang-5/auto.rs
Normal file
34
tests/expectations/tests/libclang-5/auto.rs
Normal file
@ -0,0 +1,34 @@
|
||||
/* automatically generated by rust-bindgen */
|
||||
|
||||
|
||||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
pub struct Foo {
|
||||
pub _address: u8,
|
||||
}
|
||||
pub const Foo_kFoo: bool = true;
|
||||
#[test]
|
||||
fn bindgen_test_layout_Foo() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<Foo>(),
|
||||
1usize,
|
||||
concat!("Size of: ", stringify!(Foo))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<Foo>(),
|
||||
1usize,
|
||||
concat!("Alignment of ", stringify!(Foo))
|
||||
);
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
pub struct Bar {
|
||||
pub _address: u8,
|
||||
}
|
||||
extern "C" {
|
||||
#[link_name = "\u{1}_Z5Test2v"]
|
||||
pub fn Test2() -> ::std::os::raw::c_uint;
|
||||
}
|
51
tests/expectations/tests/libclang-5/call-conv-field.rs
Normal file
51
tests/expectations/tests/libclang-5/call-conv-field.rs
Normal file
@ -0,0 +1,51 @@
|
||||
/* automatically generated by rust-bindgen */
|
||||
|
||||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
|
||||
#![cfg(not(test))]
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct JNINativeInterface_ {
|
||||
pub GetVersion: ::std::option::Option<
|
||||
unsafe extern "stdcall" fn(env: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
|
||||
>,
|
||||
pub __bindgen_padding_0: u32,
|
||||
pub __hack: ::std::os::raw::c_ulonglong,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_JNINativeInterface_() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<JNINativeInterface_>(),
|
||||
16usize,
|
||||
concat!("Size of: ", stringify!(JNINativeInterface_))
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<JNINativeInterface_>())).GetVersion as *const _ as usize },
|
||||
0usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(JNINativeInterface_),
|
||||
"::",
|
||||
stringify!(GetVersion)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<JNINativeInterface_>())).__hack as *const _ as usize },
|
||||
8usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(JNINativeInterface_),
|
||||
"::",
|
||||
stringify!(__hack)
|
||||
)
|
||||
);
|
||||
}
|
||||
impl Default for JNINativeInterface_ {
|
||||
fn default() -> Self {
|
||||
unsafe { ::std::mem::zeroed() }
|
||||
}
|
||||
}
|
||||
extern "stdcall" {
|
||||
#[link_name = "\u{1}_bar@0"]
|
||||
pub fn bar();
|
||||
}
|
28
tests/expectations/tests/libclang-5/const_bool.rs
Normal file
28
tests/expectations/tests/libclang-5/const_bool.rs
Normal file
@ -0,0 +1,28 @@
|
||||
/* automatically generated by rust-bindgen */
|
||||
|
||||
|
||||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
|
||||
|
||||
|
||||
pub const k: bool = true;
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
pub struct A {
|
||||
pub _address: u8,
|
||||
}
|
||||
pub const A_k: bool = false;
|
||||
#[test]
|
||||
fn bindgen_test_layout_A() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<A>(),
|
||||
1usize,
|
||||
concat!("Size of: ", stringify!(A))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<A>(),
|
||||
1usize,
|
||||
concat!("Alignment of ", stringify!(A))
|
||||
);
|
||||
}
|
||||
pub type foo = bool;
|
||||
pub const k2: foo = true;
|
21
tests/expectations/tests/libclang-5/constant-evaluate.rs
Normal file
21
tests/expectations/tests/libclang-5/constant-evaluate.rs
Normal file
@ -0,0 +1,21 @@
|
||||
/* automatically generated by rust-bindgen */
|
||||
|
||||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
|
||||
|
||||
pub const foo: _bindgen_ty_1 = _bindgen_ty_1::foo;
|
||||
pub const bar: _bindgen_ty_1 = _bindgen_ty_1::bar;
|
||||
#[repr(u32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum _bindgen_ty_1 {
|
||||
foo = 4,
|
||||
bar = 8,
|
||||
}
|
||||
pub type EasyToOverflow = ::std::os::raw::c_ulonglong;
|
||||
pub const k: EasyToOverflow = 2147483648;
|
||||
pub const k_expr: EasyToOverflow = 0;
|
||||
pub const BAZ: ::std::os::raw::c_longlong = 24;
|
||||
pub const fuzz: f64 = 51.;
|
||||
pub const BAZZ: ::std::os::raw::c_char = 53;
|
||||
pub const WAT: ::std::os::raw::c_char = 0;
|
||||
pub const bytestring: &'static [u8; 4usize] = b"Foo\0";
|
||||
pub const NOT_UTF8: [u8; 5usize] = [240u8, 40u8, 140u8, 40u8, 0u8];
|
@ -0,0 +1,40 @@
|
||||
/* automatically generated by rust-bindgen */
|
||||
|
||||
|
||||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
|
||||
|
||||
|
||||
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
|
||||
pub mod root {
|
||||
#[allow(unused_imports)]
|
||||
use self::super::root;
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct Rooted<T> {
|
||||
pub member: T,
|
||||
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
|
||||
}
|
||||
impl<T> Default for Rooted<T> {
|
||||
fn default() -> Self {
|
||||
unsafe { ::std::mem::zeroed() }
|
||||
}
|
||||
}
|
||||
pub type AutoValueVector_Alias = ::std::os::raw::c_int;
|
||||
#[test]
|
||||
fn __bindgen_test_layout_Rooted_open0_int_close0_instantiation() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<root::Rooted<::std::os::raw::c_int>>(),
|
||||
4usize,
|
||||
concat!(
|
||||
"Size of template specialization: ",
|
||||
stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > )
|
||||
)
|
||||
);
|
||||
assert_eq ! ( :: std :: mem :: align_of :: < root :: Rooted < :: std :: os :: raw :: c_int > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: Rooted < :: std :: os :: raw :: c_int > ) ) );
|
||||
}
|
||||
#[test]
|
||||
fn __bindgen_test_layout_Rooted_open0_AutoValueVector_Alias_close0_instantiation() {
|
||||
assert_eq ! ( :: std :: mem :: size_of :: < root :: Rooted < root :: AutoValueVector_Alias > > ( ) , 4usize , concat ! ( "Size of template specialization: " , stringify ! ( root :: Rooted < root :: AutoValueVector_Alias > ) ) );
|
||||
assert_eq ! ( :: std :: mem :: align_of :: < root :: Rooted < root :: AutoValueVector_Alias > > ( ) , 4usize , concat ! ( "Alignment of template specialization: " , stringify ! ( root :: Rooted < root :: AutoValueVector_Alias > ) ) );
|
||||
}
|
||||
}
|
18
tests/expectations/tests/libclang-5/objc_template.rs
Normal file
18
tests/expectations/tests/libclang-5/objc_template.rs
Normal file
@ -0,0 +1,18 @@
|
||||
/* automatically generated by rust-bindgen */
|
||||
|
||||
|
||||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
|
||||
|
||||
#![cfg(target_os="macos")]
|
||||
|
||||
#[macro_use]
|
||||
extern crate objc;
|
||||
#[allow(non_camel_case_types)]
|
||||
pub type id = *mut objc::runtime::Object;
|
||||
pub trait Foo {
|
||||
unsafe fn get(self)
|
||||
-> *mut ObjectType;
|
||||
}
|
||||
impl Foo for id {
|
||||
unsafe fn get(self) -> *mut ObjectType { msg_send!(self , get) }
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/* automatically generated by rust-bindgen */
|
||||
|
||||
|
||||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
pub struct Base {
|
||||
pub _address: u8,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
pub struct Derived {
|
||||
pub b: bool,
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Default, Copy, Clone)]
|
||||
pub struct Usage {
|
||||
pub _address: u8,
|
||||
}
|
||||
extern "C" {
|
||||
#[link_name = "\u{1}_ZN5Usage13static_memberE"]
|
||||
pub static mut Usage_static_member: [u32; 2usize];
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_Usage() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<Usage>(),
|
||||
1usize,
|
||||
concat!("Size of: ", stringify!(Usage))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<Usage>(),
|
||||
1usize,
|
||||
concat!("Alignment of ", stringify!(Usage))
|
||||
);
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/* automatically generated by rust-bindgen */
|
||||
|
||||
|
||||
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct Rooted {
|
||||
pub ptr: MaybeWrapped<::std::os::raw::c_int>,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_Rooted() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<Rooted>(),
|
||||
4usize,
|
||||
concat!("Size of: ", stringify!(Rooted))
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<Rooted>(),
|
||||
4usize,
|
||||
concat!("Alignment of ", stringify!(Rooted))
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe { &(*(::std::ptr::null::<Rooted>())).ptr as *const _ as usize },
|
||||
0usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(Rooted),
|
||||
"::",
|
||||
stringify!(ptr)
|
||||
)
|
||||
);
|
||||
}
|
||||
impl Default for Rooted {
|
||||
fn default() -> Self {
|
||||
unsafe { ::std::mem::zeroed() }
|
||||
}
|
||||
}
|
||||
/// <div rustbindgen replaces="MaybeWrapped"></div>
|
||||
pub type MaybeWrapped<a> = a;
|
||||
#[test]
|
||||
fn __bindgen_test_layout_MaybeWrapped_open0_int_close0_instantiation() {
|
||||
assert_eq!(
|
||||
::std::mem::size_of::<MaybeWrapped<::std::os::raw::c_int>>(),
|
||||
4usize,
|
||||
concat!(
|
||||
"Size of template specialization: ",
|
||||
stringify!(MaybeWrapped<::std::os::raw::c_int>)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
::std::mem::align_of::<MaybeWrapped<::std::os::raw::c_int>>(),
|
||||
4usize,
|
||||
concat!(
|
||||
"Alignment of template specialization: ",
|
||||
stringify!(MaybeWrapped<::std::os::raw::c_int>)
|
||||
)
|
||||
);
|
||||
}
|
@ -1,11 +1,8 @@
|
||||
// bindgen-flags: -- --target=i686-pc-win32
|
||||
// bindgen-flags: --raw-line "#![cfg(not(test))]" -- --target=i686-pc-win32
|
||||
// bindgen-unstable
|
||||
// bindgen-generate-bindings-on-linux-only
|
||||
//
|
||||
// The linux-only thing is a hack around our lack of understanding when
|
||||
// bindgen's target_os != the bindings' target_os :(
|
||||
//
|
||||
// https://github.com/rust-lang-nursery/rust-bindgen/issues/593
|
||||
// We can only check that this builds, but not that it actually passes, because
|
||||
// we have no CI on the target platform.
|
||||
|
||||
struct JNINativeInterface_ {
|
||||
int (__stdcall *GetVersion)(void *env);
|
||||
|
@ -118,6 +118,8 @@ fn compare_generated_header(
|
||||
|
||||
if cfg!(feature = "testing_only_libclang_4") {
|
||||
expectation.push("libclang-4");
|
||||
} else if cfg!(feature = "testing_only_libclang_5") {
|
||||
expectation.push("libclang-5");
|
||||
} else if cfg!(feature = "testing_only_libclang_3_9") {
|
||||
expectation.push("libclang-3.9");
|
||||
} else if cfg!(feature = "testing_only_libclang_3_8") {
|
||||
@ -127,7 +129,9 @@ fn compare_generated_header(
|
||||
None => {}
|
||||
Some(version) => {
|
||||
let (maj, min) = version;
|
||||
let version_str = if maj >= 4 {
|
||||
let version_str = if maj >= 5 {
|
||||
"5".to_owned()
|
||||
} else if maj == 4 {
|
||||
"4".to_owned()
|
||||
} else {
|
||||
format!("{}.{}", maj, min)
|
||||
|
Loading…
Reference in New Issue
Block a user