ctru-rs-old icon indicating copy to clipboard operation
ctru-rs-old copied to clipboard

Generate ctru-sys as part of the build system

Open linkmauve opened this issue 6 years ago • 6 comments

Have a look at rust-bindgen, it can create -sys crates automatically from headers, which will alleviate a good part of your work.

linkmauve avatar Dec 16 '17 14:12 linkmauve

Actually, I didn’t see it was already generated, my request then is to make it automated as part of the build system, or at least documenting how to update it.

linkmauve avatar Dec 16 '17 15:12 linkmauve

IIRC we opted for generating them only when needed to stay in sync with a specific libctru release.

I have a script for citro3d-sys to generate bindings, which I will probably port over for libctru-sys. It might even make sense to use some sort of Rust task runner like cargo-make or even just cargo-script instead (to get away from platform dependant scripts).

panicbit avatar Dec 16 '17 15:12 panicbit

It was exactly for citro3d that I wanted to use this. :) I’ll wait for your release then, thanks!

linkmauve avatar Dec 16 '17 15:12 linkmauve

citro3d is a bit of a pain to port to safe Rust, but I intended to at least release a sys crate

panicbit avatar Dec 16 '17 15:12 panicbit

Here you go: https://github.com/rust3ds/citro3d-sys

I didn't manage to verify that the crate still builds properly because ctru-rs doesn't build for me right now and I have no time to figure out why.

panicbit avatar Dec 16 '17 15:12 panicbit

For the record, this is the build script I used to generate ctru-sys locally last time I updated it: https://github.com/FenrirWolf/ctru-rs/blob/bindgen/ctru-sys/build.rs

We definitely could generate the bindings at build-time by default instead of checking them in manually, but the trade-off there is that running bindgen increases compile times and adds a dependency on clang.

FenrirWolf avatar Dec 16 '17 17:12 FenrirWolf