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

Migrating from bazelruby/rules_ruby for gems with native extensions #186

Open
JasonLunn opened this issue Dec 27, 2024 · 5 comments
Open
Labels
question Further information is requested

Comments

@JasonLunn
Copy link

Follow up to #180

How do gem authors use bazel-contrib/rules_ruby to reference parts of the Ruby environment needed to construct native extensions?

For example, if building a native extension in C for MRI, under bazelruby/rules_ruby I might include "@rules_ruby//ruby/runtime:headers" in the deps of the cc_library to expose ruby.h. Similarly, for an native extension targeting JRuby, I might include "@rules_ruby//ruby/runtime:jars" in the deps of the java_library.

@p0deje
Copy link
Member

p0deje commented Dec 28, 2024

I haven't seen an example of gems building native extensions yet, so you might be the first to encounter this. It's worth asking in the #ruby channel on Bazel Slack though.

If you have an example you could share, I can help figure out what needs to be changed in the ruleset to support your case.

@p0deje p0deje added the question Further information is requested label Dec 28, 2024
@JasonLunn
Copy link
Author

This is a good example of a Ruby C extension that needs to leverage definitions from ruby.h, and this is for the JRuby version of the same gem that needs jruby.jar.

@p0deje
Copy link
Member

p0deje commented Dec 29, 2024

I will take a look at it, but please share if you have a simpler example I can experiment with (protobuf is quite large). It might be something w/o the Bazel bits, I just need to make sure I understand how to build platform-specific versions.

@JasonLunn
Copy link
Author

bundle gem foo --ext=c will generate a trivial gem in the folder foo with a native extension implemented in C nested inside the ext subdirectory.

@p0deje
Copy link
Member

p0deje commented Jan 2, 2025

@JasonLunn I've started experiment with native extensions in https://github.com/bazel-contrib/rules_ruby/tree/ext and so far I had no issues compiling the gem using rake compile or packaging it in a gem and then use gem install to install it. Can you give me an example of a command I can run to reproduce the issue with missing headers when compiling extensions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants