# Installation

## Ruby

To build `bevy_scriptum` with Ruby support a Ruby installation is needed to be
present on your development machine.

### Linux

#### Requirements

- clang
- Ruby installation compiled with clang

#### Clang installation

For `clang` installation instruction consult your
OS vendor provided documentation or [clang official webiste](https://clang.llvm.org).

#### Ruby installation

The easiest way to produce a compatible Ruby installation is to use [rbenv](https://rbenv.org/).

After installing `rbenv` along with its `ruby-build` plugin you can build and
install a Ruby installation that will work with `bevy_scriptum` by executing:

```sh
CC=clang rbenv install 3.4.4
```

Above assumes that you also have `clang` installed on your system.

If you rather not use `rbenv` you are free to supply your own installation of
Ruby provided the following is true about it:

- it is compiled with `clang`
- it is compiled as a static library
- it is accessible as `ruby` within `PATH` or `RUBY` environment variable is set
  to path of desired `ruby` binary.

### Windows

#### Requirements

- clang
- Ruby

#### Clang installation

Clang can be installed on Windows using `Visual Studio Installer`(select `Desktop
Development With C++ ->> C++ Clang tool for Windows` package).

`LIBCLANG_PATH` environment variable also has to be set to clang installation `bin`
directory when compiling. This typically is `C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\x64\lib`.

#### Ruby installation

On Windows Ruby can be installed using [RubyInstaller](https://rubyinstaller.org/) among others.

## bevy_scriptum

Add the following to your `Cargo.toml`:

```toml
[dependencies]
bevy = "0.16"
bevy_scriptum = { version = "0.9", features = ["ruby"] }
```

If you need a different version of bevy you need to use a matching bevy_scriptum
version according to the [bevy support matrix](../bevy_support_matrix.md)

Ruby also needs dynamic symbol resolution and since `bevy_scriptum` links Ruby
statically the following `build.rs` file is needed to be present in project
root directory.

```rust
fn main() {
    println!("cargo:rustc-link-arg=-rdynamic");
}
```
