Skip to content
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

Catch binding conflicts between libc/citro3d/ctru #49

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
8 changes: 7 additions & 1 deletion citro3d-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ libc = "0.2.116"
ctru-sys = { git = "https://github.com/rust3ds/ctru-rs.git" }

[build-dependencies]
bindgen = { version = "0.68.1", features = ["experimental"] }
cc = "1.0.83"
doxygen-rs = "0.4.2"

[build-dependencies.bindgen]
# Use 0.* so that we take the same version ctru-sys uses by default
version = "0.*"
features = ["experimental"]
git = "https://github.com/ian-h-chamberlain/rust-bindgen.git"
rev = "fa88e08fb5abf8d17e596243846016776ac32c2f"

[dev-dependencies]
shim-3ds = { git = "https://github.com/rust3ds/shim-3ds.git" }
5 changes: 4 additions & 1 deletion citro3d-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ fn main() {
.ctypes_prefix("::libc")
.prepend_enum_name(false)
.fit_macro_constants(true)
.raw_line("use ctru_sys::*;")
.must_use_type("Result")
.blocklist_type("u(8|16|32|64)")
.opaque_type("(GPU|GFX)_.*")
Expand All @@ -74,6 +73,10 @@ fn main() {
.allowlist_file(".*/tex3ds[.]h")
.blocklist_file(".*/3ds/.*[.]h")
.blocklist_file(".*/sys/.*[.]h")
.blocklist_type("FILE")
// ctru-sys already generates one of these, let's reuse it instead of
// regenerating another one in citro3d-sys bindings.
.blocklist_type("__BindgenBitfieldUnit")
.wrap_static_fns(true)
.wrap_static_fns_path(out_dir.join(static_fns_path))
.clang_args([
Expand Down
19 changes: 17 additions & 2 deletions citro3d-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![allow(warnings)]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![deny(ambiguous_glob_reexports)]
#![allow(clippy::all)]
#![doc(html_root_url = "https://rust3ds.github.io/citro3d-rs/crates")]
#![doc(
Expand All @@ -12,11 +13,25 @@
html_logo_url = "https://user-images.githubusercontent.com/11131775/225929072-2fa1741c-93ae-4b47-9bdf-af70f3d59910.png"
)]

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
// During testing, re-export types to trigger `ambiguous_glob_reexports`
// if we ended up regenerating the same type as upstream ctru-sys or libc.
#[cfg(test)]
pub use ctru_sys::*;
#[cfg(test)]
pub use libc::*;

mod bindings {
use ctru_sys::*;
use libc::*;

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}

pub use bindings::*;

pub mod gx;
pub use gx::*;

// Prevent linking errors from the standard `test` library when running `cargo 3ds test --lib`.
#[cfg(test)]
#[cfg(all(test, not(rust_analyzer)))]
extern crate shim_3ds;
2 changes: 1 addition & 1 deletion citro3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ approx = ["dep:approx"]
glam = ["dep:glam"]

[dev-dependencies]
test-runner = { git = "https://github.com/rust3ds/test-runner.git" }
test-runner = { git = "https://github.com/rust3ds/ctru-rs.git" }

[dev-dependencies.citro3d]
# Basically, this works like `cargo 3ds test --features ...` for building tests
Expand Down
Loading