-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend CMake tests with testing different config variants
We now test "no config file", "explicit config file" and "implicit config file", which are all supported variants.
- Loading branch information
Showing
19 changed files
with
218 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cmake_minimum_required(VERSION 3.21.0) | ||
|
||
project(depfile_test | ||
LANGUAGES C | ||
DESCRIPTION "A CMake Project to test the --depfile output from cbindgen" | ||
) | ||
|
||
include(../cbindgen_test.cmake) | ||
|
||
add_cbindgen_command(gen_bindings | ||
"${CMAKE_CURRENT_BINARY_DIR}/single_crate.h" | ||
--config "${CMAKE_CURRENT_SOURCE_DIR}/config.toml" | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "single_crate" | ||
version = "0.1.0" | ||
authors = ["cbindgen"] | ||
|
||
[features] | ||
cbindgen = [] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
config.toml | ||
src/alias/mod.rs | ||
src/annotation.rs | ||
src/lib.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#[repr(C)] | ||
struct Dep { | ||
a: i32, | ||
b: f32, | ||
} | ||
|
||
#[repr(C)] | ||
struct Foo<X> { | ||
a: X, | ||
b: X, | ||
c: Dep, | ||
} | ||
|
||
#[repr(u32)] | ||
enum Status { | ||
Ok, | ||
Err, | ||
} | ||
|
||
type IntFoo = Foo<i32>; | ||
type DoubleFoo = Foo<f64>; | ||
|
||
type Unit = i32; | ||
type SpecialStatus = Status; | ||
|
||
#[no_mangle] | ||
pub extern "C" fn root( | ||
x: IntFoo, | ||
y: DoubleFoo, | ||
z: Unit, | ||
w: SpecialStatus, | ||
) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/// cbindgen:derive-lt=true | ||
/// cbindgen:derive-lte=true | ||
/// cbindgen:derive-constructor=true | ||
/// cbindgen:rename-all=GeckoCase | ||
#[repr(C)] | ||
struct A(i32); | ||
|
||
/// cbindgen:field-names=[x, y] | ||
#[repr(C)] | ||
struct B(i32, f32); | ||
|
||
/// cbindgen:trailing-values=[Z, W] | ||
#[repr(u32)] | ||
enum C { | ||
X = 2, | ||
Y, | ||
} | ||
|
||
/// cbindgen:derive-helper-methods=true | ||
#[repr(u8)] | ||
enum F { | ||
Foo(i16), | ||
Bar { x: u8, y: i16 }, | ||
Baz, | ||
} | ||
|
||
/// cbindgen:derive-helper-methods | ||
#[repr(C, u8)] | ||
enum H { | ||
Hello(i16), | ||
There { x: u8, y: i16 }, | ||
Everyone, | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn root( | ||
x: A, | ||
y: B, | ||
z: C, | ||
f: F, | ||
h: H, | ||
) {} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod alias; | ||
mod annotation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cmake_minimum_required(VERSION 3.21.0) | ||
|
||
project(depfile_test | ||
LANGUAGES C | ||
DESCRIPTION "A CMake Project to test the --depfile output from cbindgen" | ||
) | ||
|
||
include(../cbindgen_test.cmake) | ||
|
||
add_cbindgen_command(gen_bindings | ||
"${CMAKE_CURRENT_BINARY_DIR}/single_crate.h" | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "single_crate" | ||
version = "0.1.0" | ||
authors = ["cbindgen"] | ||
|
||
[features] | ||
cbindgen = [] |
Empty file.
4 changes: 4 additions & 0 deletions
4
tests/depfile/single_crate_default_config/expectations/dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cbindgen.toml | ||
src/alias/mod.rs | ||
src/annotation.rs | ||
src/lib.rs |
32 changes: 32 additions & 0 deletions
32
tests/depfile/single_crate_default_config/src/alias/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#[repr(C)] | ||
struct Dep { | ||
a: i32, | ||
b: f32, | ||
} | ||
|
||
#[repr(C)] | ||
struct Foo<X> { | ||
a: X, | ||
b: X, | ||
c: Dep, | ||
} | ||
|
||
#[repr(u32)] | ||
enum Status { | ||
Ok, | ||
Err, | ||
} | ||
|
||
type IntFoo = Foo<i32>; | ||
type DoubleFoo = Foo<f64>; | ||
|
||
type Unit = i32; | ||
type SpecialStatus = Status; | ||
|
||
#[no_mangle] | ||
pub extern "C" fn root( | ||
x: IntFoo, | ||
y: DoubleFoo, | ||
z: Unit, | ||
w: SpecialStatus, | ||
) {} |
43 changes: 43 additions & 0 deletions
43
tests/depfile/single_crate_default_config/src/annotation.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/// cbindgen:derive-lt=true | ||
/// cbindgen:derive-lte=true | ||
/// cbindgen:derive-constructor=true | ||
/// cbindgen:rename-all=GeckoCase | ||
#[repr(C)] | ||
struct A(i32); | ||
|
||
/// cbindgen:field-names=[x, y] | ||
#[repr(C)] | ||
struct B(i32, f32); | ||
|
||
/// cbindgen:trailing-values=[Z, W] | ||
#[repr(u32)] | ||
enum C { | ||
X = 2, | ||
Y, | ||
} | ||
|
||
/// cbindgen:derive-helper-methods=true | ||
#[repr(u8)] | ||
enum F { | ||
Foo(i16), | ||
Bar { x: u8, y: i16 }, | ||
Baz, | ||
} | ||
|
||
/// cbindgen:derive-helper-methods | ||
#[repr(C, u8)] | ||
enum H { | ||
Hello(i16), | ||
There { x: u8, y: i16 }, | ||
Everyone, | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn root( | ||
x: A, | ||
y: B, | ||
z: C, | ||
f: F, | ||
h: H, | ||
) {} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod alias; | ||
mod annotation; |