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 conflicts with libc and stop generating them #186

Merged
merged 3 commits into from
May 4, 2024
Merged
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
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
Loading