All Projects β†’ malept β†’ Thermite

malept / Thermite

Licence: mit
A Rake-based helper for building and distributing Rust-based Ruby extensions

Programming Languages

ruby
36898 projects - #4 most used programming language
rust
11053 projects

Labels

Projects that are alternatives of or similar to Thermite

Snm
🀏 Smol Node Manager written in Rust
Stars: ✭ 24 (-80.8%)
Mutual labels:  cargo
Nat
nat - the 'ls' replacement you never knew you needed
Stars: ✭ 1,129 (+803.2%)
Mutual labels:  cargo
Corrosion
Marrying Rust and CMake - Easy Rust and C/C++ Integration!
Stars: ✭ 106 (-15.2%)
Mutual labels:  cargo
Rust Android Gradle
Stars: ✭ 14 (-88.8%)
Mutual labels:  cargo
Cargo Contribute
Cargo subcommand for contributing to your dependencies
Stars: ✭ 56 (-55.2%)
Mutual labels:  cargo
Cargo Watch
πŸ”­πŸš’ Watches over your Cargo project's source.
Stars: ✭ 1,281 (+924.8%)
Mutual labels:  cargo
Cargo Make
Rust task runner and build tool.
Stars: ✭ 895 (+616%)
Mutual labels:  cargo
Crate2nix
nix build file generator for rust crates
Stars: ✭ 123 (-1.6%)
Mutual labels:  cargo
Tarpaulin
A code coverage tool for Rust projects
Stars: ✭ 1,097 (+777.6%)
Mutual labels:  cargo
Cargo Embed
a cargo extension for working with microcontrollers
Stars: ✭ 100 (-20%)
Mutual labels:  cargo
Small Deployer
Git Webhook client, in rust.
Stars: ✭ 30 (-76%)
Mutual labels:  cargo
Vim Crates
Handle Cargo dependencies like a Rustavimean.
Stars: ✭ 54 (-56.8%)
Mutual labels:  cargo
Cargo Remote
cargo subcommand to compile rust projects remotely
Stars: ✭ 87 (-30.4%)
Mutual labels:  cargo
Xargo
The sysroot manager that lets you build and customize `std`
Stars: ✭ 841 (+572.8%)
Mutual labels:  cargo
Meta Rust
OpenEmbedded/Yocto layer for Rust and Cargo
Stars: ✭ 108 (-13.6%)
Mutual labels:  cargo
Cargo Tomlfmt
Formatting Cargo.toml
Stars: ✭ 18 (-85.6%)
Mutual labels:  cargo
Rust Python Ext
Distutils helpers for rust Python extensions
Stars: ✭ 69 (-44.8%)
Mutual labels:  cargo
Kernel Roulette
A kernel module written in Rust
Stars: ✭ 124 (-0.8%)
Mutual labels:  cargo
Shadow Rs
A build-time information stored in your rust project.(binary,lib,cdylib,dylib)
Stars: ✭ 117 (-6.4%)
Mutual labels:  cargo
Audit Check
πŸ›‘οΈ GitHub Action for security audits
Stars: ✭ 90 (-28%)
Mutual labels:  cargo

Thermite

Linux/OSX build status Windows build status Code Climate Test coverage Inline docs Gem

Thermite is a Rake-based helper for building and distributing Rust-based Ruby extensions.

Features

  • Provides wrappers for cargo commands.
  • Handles non-standard cargo installations via the CARGO environment variable.
  • Opt-in to allow users to install pre-compiled Rust extensions hosted on GitHub releases.
  • Opt-in to allow users to install pre-compiled Rust extensions hosted on a third party server.
  • Provides a wrapper for initializing a Rust extension via Fiddle.

Usage

  1. Add the following to your gemspec file:
spec.extensions << 'ext/Rakefile'
spec.add_runtime_dependency 'thermite', '~> 0'
  1. Create ext/Rakefile with the following code, assuming that the Cargo project root is the same as the Ruby project root:
require 'thermite/tasks'

project_dir = File.dirname(File.dirname(__FILE__))
Thermite::Tasks.new(cargo_project_path: project_dir, ruby_project_path: project_dir)
task default: %w(thermite:build)
  1. In Rakefile, integrate Thermite into your build-test workflow:
require 'thermite/tasks'

Thermite::Tasks.new

desc 'Run Rust & Ruby testsuites'
task test: ['thermite:build', 'thermite:test'] do
  # …
end

Run rake -T thermite to view all of the available tasks in the thermite namespace.

Configuration

Task configuration for your project can be set in two ways:

  • passing arguments to Thermite::Tasks.new
  • adding a package.metadata.thermite section to Cargo.toml. These settings override the arguments passed to the Tasks class. Due to the conflict, it is infeasible for cargo_project_path or cargo_workspace_member to be set in this way. Example section:
[package.metadata.thermite]

github_releases = true

Possible options:

  • binary_uri_format - if set, the interpolation-formatted string used to construct the download URI for the pre-built native extension. If the environment variable THERMITE_BINARY_URI_FORMAT is set, it takes precedence over this option. Either method of setting this option overrides the github_releases option. Example: https://example.com/download/%{version}/%{filename}. Replacement variables:
    • filename - The value of Config.tarball_filename
    • version - the crate version from Cargo.toml
  • cargo_project_path - the path to the top-level Cargo project. Defaults to the current working directory.
  • cargo_workspace_member - if set, the relative path to the Cargo workspace member. Usually used when it is part of a repository containing multiple crates.
  • github_releases - whether to look for Rust binaries via GitHub releases when installing the gem, and cargo is not found. Defaults to false.
  • github_release_type - when github_releases is true, the mode to use to download the Rust binary from GitHub releases. 'cargo' (the default) uses the version in Cargo.toml, along with the git_tag_format option (described below) to determine the download URI. 'latest' takes the latest release matching the git_tag_regex option (described below) to determine the download URI.
  • git_tag_format - when github_release_type is 'cargo' (the default), the format string used to determine the tag used in the GitHub download URI. Defaults to v%s, where %s is the version in Cargo.toml.
  • git_tag_regex - when github_releases is enabled and github_release_type is 'latest', a regular expression (expressed as a String) that determines which tagged releases to look for precompiled Rust tarballs. One group must be specified that indicates the version number to be used in the tarball filename. Defaults to the semantic versioning 2.0.0 format. In this case, the group is around the entire expression.
  • optional_rust_extension - prints a warning to STDERR instead of raising an exception, if Cargo is unavailable and github_releases is either disabled or unavailable. Useful for projects where either fallback code exists, or a native extension is desirable but not required. Defaults to false.
  • ruby_project_path - the top-level directory of the Ruby gem's project. Defaults to the current working directory.
  • ruby_extension_dir - the directory relative to ruby_project_path where the extension is located. Defaults to lib.

Example

Using the clichΓ© Rust+Ruby example, the rusty_blank repository contains an example of using Thermite with ruru to provide a String.blank? speedup extension. While the example uses ruru, this gem should be usable with any method of integrating Rust and Ruby that you choose.

Debug / release build

By default Thermite will do a release build of your Rust code. To do a debug build instead, set the CARGO_PROFILE environment variable to debug.

For example, you can run CARGO_PROFILE=debug rake thermite:build.

Troubleshooting

Debug statements can be written to a file specified by the THERMITE_DEBUG_FILENAME environment variable.

FAQ

Why is it named Thermite?

According to Wikipedia:

  • The chemical formula for ruby includes Al2O3, or aluminum oxide.
  • Rust is iron oxide, or Fe2O3.
  • A common thermite reaction uses iron oxide and aluminum to produce iron and aluminum oxide: Fe2O3 + 2Al β†’ 2Fe + Al2O3

Release Notes

Contributing

Legal

This gem is licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].