[][src]Crate aloxide

aloxide banner travis badge crates.io downloads API docs

Download, configure, compile, and link to Ruby.

Usage

This crate is available on crates.io and can be used by adding the following to your project's Cargo.toml:

[build-dependencies]
aloxide = "0.0.8"

or if you're mental and would like to be on the latest and... um greatest (?), then you can depend directly on the GitHub repository:

[build-dependencies]
aloxide = { git = "https://github.com/nvzqz/aloxide" }

and finally add this to your Cargo build script (build.rs):

extern crate aloxide;

Supported Platforms

Currently, aloxide only supports Linux and macOS. See issue #1 for more details.

Examples

Given a directory of sources, Ruby can be built as such:

use aloxide::Ruby;

// When necessary, `rustc` targets are made build-compatible for Ruby
let target = std::env::var("TARGET").unwrap();

let src_dir = "path/to/sources";
let out_dir = "path/to/build";

let ruby = Ruby::src(src_dir)
    .builder(out_dir, target)
    .configure()      // Change what happens when running `configure`
        .inherit_cc() // Use the `CC` environment variable
    .make()           // Change what happens when running `make`
        .force()      // Always run `make` regardless if sources built
    .build()          // Run all build steps
    .unwrap();

let hello_world = ruby.run("puts 'Hello, World!").unwrap();
assert_eq!(hello_world, "Hello, World!\n");

Ruby can linked to the current crate very easily:

// Link Ruby statically
if let Err(error) = ruby.link(true) {
    // Handle `error`
}

Modules

src

Utilities for Ruby's source code.

version

Ruby versions.

Structs

Ruby

An existing Ruby installation

RubySrc

A path to Ruby's source code.

Version

A simple Ruby version.

Enums

RubyExecError

The error returned when running ruby fails.

RubyLinkError

The error returned when linking to the Ruby library and its dependencies fails.

Traits

Archive

A type that contains the contents of a .tar.bz2 archive.