danielpclark / rutie

“The Tie Between Ruby and Rust.”
MIT License
938 stars 62 forks source link

Integration with `rb-sys` #163

Open ianks opened 1 year ago

ianks commented 1 year ago

Hi there!

I’ve been working on rb-sys. The main goal of the project is to make building native extensions in Rust easier than C.

Traditionally, most Ruby/Rust gems have packaged their own Ruby bindings. As you know, there are many edge cases and supporting these bindings across multiple platforms can be a total pain. With rb-sys, the goal is remove that burden. Some features are:

I would love to add support for rb-sys to Rutie if you are interested. I recently made the switch this for magnus and things went smoothly. For Rutie, I imagine it will solve a lot of build issues (particularly with libruby-static, and upcoming changes with Ruby 3.2). On top of this, it will make it easier for Rutie users to cross compile gems.

Let me know if this sounds like something you would accept. Happy to start working on it!

danielpclark commented 1 year ago

Hi @ianks, Rutie allows for builds to work in both directions. So yes it allows Ruby to integrate Rust into Ruby, but it also allows Rust to integrate Ruby into Rust. I get the benefit of a standardized way setup as the foundation on which Rutie can be used to help Rust integrate into Ruby. But have you done an initial survey of this project to see how good of a fit it would be and how feasible it is to do without detracting from the Rust integrating Ruby into Rust side of things?

We currently have some Windows developers working on seeing how we can have Rutie better supported on that platform, which is exiting, so I'd like to know the impact of what changes need to come. Depending on the answer I may be in favor of moving forward with this. But I'm not going to give the full go ahead without much more serious consideration given to it.

Thanks!

ianks commented 1 year ago

Hey @danielpclark,

But have you done an initial survey of this project to see how good of a fit it would be and how feasible it is to do without detracting from the Rust integrating Ruby into Rust side of things?

rb-sys does indeed support the embedded use case, and it's a first-class concern. We've been supporting this on magnus for awhile with the embed feature, and the entire test suite uses it.

We currently have some Windows developers working on seeing how we can have Rutie better supported on that platform, which is exiting, so I'd like to know the impact of what changes need to come.

For window, [rb-sys] is with every every Windows target supported by [rake-compiler-dock], and probably more. I even recently added mswin support for the msvc toolchain, which is an upcoming feature of Ruby 3.2. You can see the list of fully supported platforms here. If you want to dive deeper, you can take a look at the CI test matrix as well.

Enjoy your weekend! Ian

danielpclark commented 1 year ago

I'd like you to move forward with this if you have the time. I expect not everything will work initially but we'll cross that bridge when we get there.

ianks commented 1 year ago

FYI @goyox86 has stepped up and volunteered to do this 🙏🏻

goyox86 commented 1 year ago

Managed to send a PR moving to rb-sys still needs work but its a start, please take a look whenever you can @ianks @danielpclark I was waiting to have some time to clean and create the PR.

I also experimented a branch to have both implementations with Cargo features, not sure if I like it xD

danielpclark commented 1 year ago

@goyox86 Great work! I love seeing progress made on this and it looks like you're making good headway.

Is the rampant use of .into() due to the changes to ruby value type? Would it be feasible to have .into() refactored back out without removing the progress on types you've made?

Also I prefer having the named CallbackPtr naming convention over the raw type details as this provides clarity and context for developers when using such references. I suppose it doesn't need to be truncated; perhaps CallbackPointer would be better.

goyox86 commented 1 year ago

Hello there @danielpclark !

Sorry for the radio silence, I have been a bit busy with work.

Regarding your comment, I think I am using into() right now just because what was allowed me to progress, but TBH I did not give to much thought to that part of the changes. I noticed it seemed pervasive, but my objective is to have things running, cargo test --doc passing on all platforms.

Currently I am focused on making rb-sys "just work" with the standard Ruby Installer 2 on windows and then I will come back here. I expect to have some time this weekend to come here and rebase stuff. I saw you have been working on the CI for the current implementation of rutie. Looks great!