From 3a43ccbf3b6716d298c4f23d8a43c2b5f44c4f47 Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Thu, 2 May 2024 22:23:46 -0400 Subject: [PATCH 1/2] Catch conflicts with libc and stop generating them --- ctru-sys/build.rs | 9 +++++++++ ctru-sys/src/lib.rs | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ctru-sys/build.rs b/ctru-sys/build.rs index 278bd00a..71ad909c 100644 --- a/ctru-sys/build.rs +++ b/ctru-sys/build.rs @@ -76,9 +76,18 @@ fn main() { .layout_tests(true) .ctypes_prefix("::libc") .prepend_enum_name(false) + .allowlist_file(include_path.join("3ds[.]h").to_string_lossy()) + .allowlist_file(include_path.join("3ds/.*").to_string_lossy()) + .allowlist_function("__errno") + .blocklist_function("gethost(id|name)") .blocklist_type("u(8|16|32|64)") .blocklist_type("__builtin_va_list") .blocklist_type("__va_list") + .blocklist_type("timeval") + .blocklist_type("in_addr") + .blocklist_type("sockaddr_storage") + .blocklist_type("(in_addr|wchar|socklen|suseconds|sa_family|time)_t") + .blocklist_item("SOL_CONFIG") .opaque_type("MiiData") .derive_default(true) .wrap_static_fns(true) diff --git a/ctru-sys/src/lib.rs b/ctru-sys/src/lib.rs index b9f71de9..ed2127b7 100644 --- a/ctru-sys/src/lib.rs +++ b/ctru-sys/src/lib.rs @@ -3,6 +3,7 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(clippy::all)] +#![deny(ambiguous_glob_reexports)] #![cfg_attr(test, feature(custom_test_frameworks))] #![cfg_attr(test, test_runner(test_runner::run_gdb))] #![doc( @@ -16,7 +17,19 @@ pub mod result; pub use result::*; -include!(concat!(env!("OUT_DIR"), "/bindings.rs")); +// By only exporting the `libc` module in tests, we can catch any potential conflicts between +// generated bindings and existing `libc` types, since we use #[deny(ambiguous_glob_reexports)]. +#[cfg(test)] +pub use libc::*; + +mod bindings { + // Meanwhile, make sure generated bindings can still refer to libc types if needed: + use libc::*; + + include!(concat!(env!("OUT_DIR"), "/bindings.rs")); +} + +pub use bindings::*; /// In lieu of a proper errno function exposed by libc /// (). From 2041e5e6775f9ba5df45e2c837d1a85ec3d42298 Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Thu, 2 May 2024 22:49:17 -0400 Subject: [PATCH 2/2] Use known good toolchain for doc building --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0487a66c..1f39fdab 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -22,7 +22,7 @@ jobs: - uses: rust3ds/test-runner/setup@v1 with: - toolchain: nightly + toolchain: nightly-2024-02-18 - name: Build workspace docs run: cargo 3ds --verbose doc --verbose --no-deps --workspace