rust3ds / ctru-rs

Rust wrapper for libctru
https://rust3ds.github.io/ctru-rs/
Other
117 stars 17 forks source link

Add `bindgen-ctru-sys` package and update bindings #110

Closed Techie-Pi closed 1 year ago

Techie-Pi commented 1 year ago

I've used the citro3d-rs repo as inspiration for creating the script. This doesn't bring any improvements per se, but I think this is a cleaner approach :)

This also updates doxygen-rs to 0.4, which has a new engine that will allow me to more easily start supporting the things that are left. Right now there are some regressions, but the documentations is still completely understandable.

Also, thanks to the use of a package to create the bindings, we're able to use ParseCallbacks (which is great for the Doxygen conversions, because the previous approach was quite hacky to say the least...)

Related #32 #75 https://github.com/rust3ds/citro3d-rs/pull/10

Meziu commented 1 year ago

A new release of libctru has been released: https://github.com/devkitPro/libctru/releases/tag/v2.2.0

You should update the bindings and change the version of ctru-sys to correspond to libctru.

Meziu commented 1 year ago

As of #101 we also need to bump the ctru-sys version when pulling a new libctru. As such, you should change the version of ctru-sys to 22.0.0+2.2.0 in its Cargo.toml file.

ian-h-chamberlain commented 1 year ago

@ian-h-chamberlain __getreent has been moved to newlib. As such, it doesn’t appear in the bindings anymore. Since it’s not available on libc either, maybe we should add it to ctru-sys’ lib.rs?

Hmmm, we could, I suppose... It looks like the only reason we use it today is for errno, which we might be able to work around by fixing https://github.com/rust-lang/libc/issues/1995 upstream, or maybe just by providing our own binding like this:

extern "C" {
    unsafe fn __errno() -> *mut libc::c_int;
}

Or we could even just include errno.h when generating bindings, from a quick test it looks like it would add a bunch of constants like ENOSYS etc., plus this small diff:

@@ -22929,3 +23016,13 @@ extern "C" {
     #[doc = ""]
     pub fn link3dsConnectToHost(redirStdout: bool, redirStderr: bool) -> ::libc::c_int;
 }
+pub type error_t = ::libc::c_int;
+extern "C" {
+    pub fn __errno() -> *mut ::libc::c_int;
+}
+extern "C" {
+    pub static _sys_errlist: [*const ::libc::c_char; 0usize];
+}
+extern "C" {
+    pub static mut _sys_nerr: ::libc::c_int;
+}