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

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

Merged
merged 7 commits into from
May 23, 2023
Merged

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

merged 7 commits into from
May 23, 2023

Conversation

Techie-Pi
Copy link
Member

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 rust3ds/citro3d-rs#10

- Added the `bindgen-ctru-sys` to be able to use `ParseCallbacks` when generating the bindings.
- Updated `doxygen-rs` to 0.4, which has a faster engine and more extensible internal (even though there are some regressions).
- Removes the `docstring-to-rustdoc` package because it is no longer needed.
Copy link
Member

@ian-h-chamberlain ian-h-chamberlain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks, the new docs seem nicer for sure!

ctru-sys/bindgen-ctru-sys/src/main.rs Outdated Show resolved Hide resolved
Cargo.toml Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As more of this is converted to Rust now I almost wonder if we should consider writing the other logic that I just added for libctru version numbering into bindgen-ctru-sys as well... Doesn't need to be part of this PR just something to think about

Copy link
Member Author

@Techie-Pi Techie-Pi Apr 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would be great. That would also allow support for multiple platforms (right now I'm using Windows and I had to run the commands manually because the script couldn't determine my version due to the need of pacman, which of course I don't have)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah man, I had been wondering about Windows support with that script, but don't have a Windows environment handy for testing it (and couldn't get Wine to work either).
I opened #113 to track this.

@Meziu
Copy link
Member

Meziu commented Apr 8, 2023

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
Copy link
Member

Meziu commented Apr 8, 2023

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.

Copy link
Member

@Meziu Meziu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

@ian-h-chamberlain
Copy link
Member

@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 rust-lang/libc#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;
+}

@Meziu Meziu changed the base branch from master to update-sys May 23, 2023 18:46
@Meziu Meziu merged commit 9201f4d into rust3ds:update-sys May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants