Skip to content

Commit

Permalink
Merge pull request #186 from rust3ds/feat/remove-libc-conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-h-chamberlain committed May 4, 2024
2 parents 30d663f + 37f0bd9 commit 0cddff4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions ctru-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 14 additions & 1 deletion ctru-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
/// (<https://github.com/rust-lang/libc/issues/1995>).
Expand Down

0 comments on commit 0cddff4

Please sign in to comment.