rust3ds / ctru-rs

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

Update bindgen script and bindings #125

Closed Meziu closed 1 year ago

Meziu commented 1 year ago

This is a continuation of #110, rebased on a local branch to aid collaboration on this issue.

Meziu commented 1 year ago

@ian-h-chamberlain It seems the CI is running this command: cargo 3ds clippy --color=always --workspace --verbose --all-targets. However, due to the workspace flag, crates which are meant for the host machine (like clang-sys) are getting built by clippy (and fail to do so). Is it safe to remove this requirement?

Meziu commented 1 year ago

@Techie-Pi Some comments within the generated bindings are getting mistaken as doctests by cargo test. Is this an error within bindgen-rs?

Techie-Pi commented 1 year ago

doxygen-rs just parses and transpiles the Doxygen comments using the ParseCallbacks::process_comment API. This doesn't look like an issue from doxygen-rs. I'm not really sure why rustdoc thinks those are doctests...

ian-h-chamberlain commented 1 year ago

@ian-h-chamberlain It seems the CI is running this command: cargo 3ds clippy --color=always --workspace --verbose --all-targets. However, due to the workspace flag, crates which are meant for the host machine (like clang-sys) are getting built by clippy (and fail to do so). Is it safe to remove this requirement?

Yeah, I think it's probably fine. I think we can just remove --workspace, and the default-members in Cargo.toml will pick the right packages to check - but it would be good to double check.

@Techie-Pi Some comments within the generated bindings are getting mistaken as doctests by cargo test. Is this an error within bindgen-rs?

It looks like some of the documentation contains entries with 4 spaces, is treated as "rust code" by the doctest runner. Example:

extern "C" {
    #[must_use]
    #[doc = "Process management\n# **\n* Gets the handle of a process.\n* # Arguments\n\n* `process` (direction out) -   The handle of the process\n*      processId The ID of the process to open\n*/"]
    pub fn svcOpenProcess(process: *mut Handle, processId: u32_) -> Result;
}

The docstring expanded looks like this:

Process management
# **
* Gets the handle of a process.
* # Arguments

* `process` (direction out) -   The handle of the process
*      processId The ID of the process to open
*/

The second-to-last line gets treated like a bullet containing a code block, which of course fails to compile:

Process management

**

  • Gets the handle of a process.

  • Arguments

  • process (direction out) - The handle of the process

  • processId The ID of the process to open */

The original comment looks like it uses the spaces to align params:

///@name Process management
///@{
/**
 * @brief Gets the handle of a process.
 * @param[out] process   The handle of the process
 * @param      processId The ID of the process to open
 */
Techie-Pi commented 1 year ago

That's interesting tbh, I'll fix it later and publish a new version.

Edit: Just published 0.4.2 which should fix (or at least improve) it.