Skip to content

Commit

Permalink
Pull out bindgen-tests into its own crate
Browse files Browse the repository at this point in the history
Citro3d-rs can probably use this the same way, so let's make a separate
crate for it to make depending on it easier.
  • Loading branch information
ian-h-chamberlain committed May 19, 2024
1 parent 7e0be08 commit 3953844
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[workspace]
members = ["ctru-rs", "ctru-sys", "test-runner"]
members = ["bindgen-tests", "ctru-rs", "ctru-sys", "test-runner"]
default-members = ["ctru-rs", "ctru-sys"]
resolver = "2"

[workspace.dependencies]
libc = { version = "0.2.153", default-features = false }
bindgen = "0.69.4"
shim-3ds = { git = "https://github.com/rust3ds/shim-3ds.git" }
pthread-3ds = { git = "https://github.com/rust3ds/pthread-3ds.git" }
test-runner = { git = "https://github.com/rust3ds/ctru-rs.git" }
Expand All @@ -15,6 +16,7 @@ test-runner = { git = "https://github.com/rust3ds/ctru-rs.git" }
test-runner = { path = "test-runner" }
ctru-rs = { path = "ctru-rs" }
ctru-sys = { path = "ctru-sys" }
bindgen-tests = { path = "bindgen-tests" }

# This was the previous git repo for test-runner
[patch."https://github.com/rust3ds/test-runner.git"]
Expand Down
11 changes: 11 additions & 0 deletions bindgen-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "bindgen-tests"
version = "0.1.0"
edition = "2021"

[dependencies]
bindgen = { workspace = true, features = ["experimental"] }
proc-macro2 = { version = "1.0.81" }
quote = { version = "1.0.36" }
regex = { version = "1.10.4" }
rust-format = { version = "0.3.4", features = ["token_stream"] }
File renamed without changes.
12 changes: 3 additions & 9 deletions ctru-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ default = []
## Downstream users of `ctru-sys` shouldn't need to use this feature.
layout-tests = [
"dep:cpp_build",
"dep:proc-macro2",
"dep:quote",
"dep:regex",
"dep:rust-format",
"dep:bindgen-tests",
]

[[test]]
Expand All @@ -33,16 +30,13 @@ required-features = ["layout-tests"]
libc = { workspace = true }

[build-dependencies]
bindgen = { version = "0.69", features = ["experimental"] }
bindgen = { workspace = true, features = ["experimental"] }
bindgen-tests = { git = "https://github.com/rust3ds/ctru-rs.git", optional = true }
cc = "1.0"
# Use git dependency so we can use https://github.com/mystor/rust-cpp/pull/111
cpp_build = { optional = true, git = "https://github.com/mystor/rust-cpp.git" }
doxygen-rs = "0.4.2"
itertools = "0.11.0"
proc-macro2 = { version = "1.0.81", optional = true }
quote = { version = "1.0.36", optional = true }
regex = { version = "1.10.4", optional = true }
rust-format = { version = "0.3.4", optional = true, features = ["token_stream"] }
which = "4.4.0"

[dev-dependencies]
Expand Down
11 changes: 2 additions & 9 deletions ctru-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ use std::error::Error;
use std::path::{Path, PathBuf};
use std::process::{Command, Output, Stdio};

// This allows us to have a directory layout of build/*.rs which is a little
// cleaner than having all the submodules as siblings to build.rs.
mod build {
#[cfg(feature = "layout-tests")]
pub mod test_gen;
}

#[derive(Debug)]
struct CustomCallbacks;

Expand Down Expand Up @@ -146,7 +139,7 @@ fn main() {
.parse_callbacks(Box::new(CustomCallbacks));

#[cfg(feature = "layout-tests")]
let (test_callbacks, test_generator) = build::test_gen::LayoutTestCallbacks::new();
let (test_callbacks, test_generator) = bindgen_tests::LayoutTestCallbacks::new();
#[cfg(feature = "layout-tests")]
let binding_builder = binding_builder.parse_callbacks(Box::new(test_callbacks));

Expand Down Expand Up @@ -275,7 +268,7 @@ fn track_libctru_files(pacman: &Path) -> Result<(), String> {
#[cfg(feature = "layout-tests")]
fn generate_layout_tests(
output_file: &Path,
test_generator: &build::test_gen::LayoutTestGenerator,
test_generator: &bindgen_tests::LayoutTestGenerator,
) -> Result<(), Box<dyn Error>> {
// There are several bindgen-generated types/fields that we can't check:
test_generator
Expand Down

0 comments on commit 3953844

Please sign in to comment.