The primary goal of rb-sys
is to make building native Ruby extensions in Rust easier than it would be in C. If
it's not easy, it's a bug.
- Battle-tested Rust bindings for the Ruby C API
- Support for Ruby 2.4+
- Supports all major platforms (Linux, macOS, Windows)
- Cross compilation of gems
- Integration with
rake-compiler
- Ruby on Rust Book ๐ to describe how to build, test, and deploy a Rusty Ruby Gem
- Contributing Docs ๐ป to get started in making your first contributions to rb-sys
rb-sys
gem ๐ to learn more about therb-sys
gem for compiling extensions
- Battle-tested Ruby FFI bindings for Rust (via
rb-sys
crate) - GitHub action to setup a test environment in CI
- GitHub action to easily cross compile in CI
- Test helpers) for testing Ruby extensions in Rust
Below are some examples of how to use rb-sys
to build native Rust extensions. Use these as a starting point for your
building your own gem.
- The
wasmtime-rb
gem usesrb-sys
andmagnus
to package the rustwasmtime
library as a Ruby gem. - The
oxi-test
gem is the canonical example of how to userb-sys
. It is a minimal, fully tested with GitHub actions, and cross-compiles native gem binaries. This should be your first stop for learning how to userb-sys
. - Docs for the
rb_sys
gem and using it with anextconf.rb
file. - The
magnus
repo has some solid examples. - This demo repository that @ianks made for a talk has a gem which has 4 native extensions in the
ext
directory. - This PR for the
yrb
gem shows how to integraterb-sys
andmagnus
into an existing gem. - A guide for setting debug breakpoints in VSCode is available.
- Ruby: 2.4+ (for full compatibility with Rubygems)
- Rust: 1.60+
We support cross compilation to the following platforms (this information is also available in the ./data
directory for automation purposes):
Platform | Supported | Docker Image |
---|---|---|
x86_64-linux | โ | rbsys/x86_64-linux:0.9.91 |
x86_64-linux-musl | โ | rbsys/x86_64-linux-musl:0.9.91 |
aarch64-linux | โ | rbsys/aarch64-linux:0.9.91 |
aarch64-linux-musl | โ | rbsys/aarch64-linux-musl:0.9.91 |
arm-linux | โ | rbsys/arm-linux:0.9.91 |
arm64-darwin | โ | rbsys/arm64-darwin:0.9.91 |
x64-mingw32 | โ | rbsys/x64-mingw32:0.9.91 |
x64-mingw-ucrt | โ | rbsys/x64-mingw-ucrt:0.9.91 |
mswin | โ | not available on Docker |
We make a concerted effort to help out new users. If you have questions, please join our Slack and post your
question in the #general
channel. Alternatively, you can open an issue and we'll try to help you out.
See the CONTRIBUTING.md file for information about setting up a development environment.
Bug reports and pull requests are welcome on GitHub at https://github.com/oxidize-rb/rb-sys.
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.