Giter VIP home page Giter VIP logo

rules_ruby's Introduction

Ruby Rules for Bazel

Overview

This repository hosts Ruby language ruleset for Bazel.

The ruleset is known to work with:

  • Bazel 7 using WORKSPACE and Bzlmod (tested on CI);
  • Bazel 6 using WORKSPACE and Bzlmod (not tested on CI);
  • Bazel 5 using WORKSPACE (no longer tested on CI).

Getting Started

WORKSPACE

  1. Install the ruleset following WORKSPACE instructions on the latest release.
  2. Download and install Ruby:
# WORKSPACE
load("@rules_ruby//ruby:deps.bzl", "rb_register_toolchains")

rb_register_toolchains(
    version = "3.0.6",
    # alternatively, load version from .ruby-version file
    # version_file = "//:.ruby-version",
)
  1. (Optional) Download and install Bundler dependencies:
# WORKSPACE
load("@rules_ruby//ruby:deps.bzl", "rb_bundle_fetch")

rb_bundle_fetch(
    name = "bundle",
    gemfile = "//:Gemfile",
    gemfile_lock = "//:Gemfile.lock",
)
  1. Start defining your library, binary and test targets in BUILD files.

Bzlmod

  1. Install ruleset following Bzlmod instructions on the latest release.
  2. Download and install Ruby:
# MODULE.bazel
ruby = use_extension("@rules_ruby//ruby:extensions.bzl", "ruby")
ruby.toolchain(
    name = "ruby",
    version = "3.0.6",
    # alternatively, load version from .ruby-version file
    # version_file = "//:.ruby-version",
)
use_repo(ruby, "ruby")
  1. (Optional) Download and install Bundler dependencies:
# MODULE.bazel
ruby.bundle_fetch(
    name = "bundle",
    gemfile = "//:Gemfile",
    gemfile_lock = "//:Gemfile.lock",
)
use_repo(ruby, "bundle", "ruby_toolchains")
  1. Register Ruby toolchains:
# MODULE.bazel
register_toolchains("@ruby_toolchains//:all")
  1. Start defining your library, binary and test targets in BUILD files.

Documentation

  • See repository rules for the documentation of WORKSPACE rules.
  • See rules for the documentation of BUILD rules.

Examples

See examples directory for a comprehensive set of examples how to use the ruleset.

Toolchains

The following toolchains are known to work and tested on CI.

Ruby Linux macOS Windows
MRI 3.3 ๐ŸŸฉ ๐ŸŸฉ ๐ŸŸฉ
MRI 3.2 ๐ŸŸฉ ๐ŸŸฉ ๐ŸŸฉ
MRI 3.1 ๐ŸŸฉ ๐ŸŸฉ ๐ŸŸฉ
MRI 3.0 ๐ŸŸฉ ๐ŸŸฉ ๐ŸŸฉ
JRuby 9.4 ๐ŸŸฉ ๐ŸŸฉ ๐ŸŸฉ
TruffleRuby 23.0 ๐ŸŸฉ ๐ŸŸฉ ๐ŸŸฅ

The following toolchains were previously known to work but no longer tested on CI.

Ruby Linux macOS Windows
MRI 2.7 ๐ŸŸฉ ๐ŸŸฉ ๐ŸŸฉ
JRuby 9.3 ๐ŸŸฉ ๐ŸŸฉ ๐ŸŸฉ
TruffleRuby 22.0 ๐ŸŸฉ ๐ŸŸฉ ๐ŸŸฅ

MRI

On Linux and macOS, ruby-build is used to install MRI from sources. Keep in mind, that it takes some time for compilation to complete.

On Windows, RubyInstaller is used to install MRI.

JRuby

On all operating systems, JRuby is downloaded manually. It uses Bazel runtime Java toolchain as JDK. JRuby is currently the only toolchain that supports Remote Build Execution.

TruffleRuby

On Linux and macOS, ruby-build is used to install TruffleRuby. Windows is not supported.

Other

On Linux and macOS, you can potentially use any Ruby distribution that is supported by ruby-build. However, some are known not to work or work only partially (e.g. mRuby has no bundler support).

Known Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.