Skip to content

Rebar3 plugin to build Rust crates

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

OtoloNetworks/rebar3_cargo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rebar3_rust

Build Status

This plugin for rebar3 enables the automatic building of Rust crates in an Erlang application. The plugin will build all crates in the crates directory and copy all binary outputs to priv/crates/<cratename>/<binary>. See the test application in this repository for an example of a port program and NIF module implemented in Rust.

Todo list

As of this writing rebar3_rust will build crates on linux and passes tests, however it is still under construction.

Todo:

  • allow cargo/rust compile flags
  • --target flag handling
  • Appveyor CI
  • maybe external crate support using cargo clone

Using the plugin

Use the plugin by adding the following to rebar.config:

{plugins, [
    { rebar3_rust, ".*", {git, "https://github.com/goertzenator/rebar3_rust", {branch, "master"}}}
]}.

{provider_hooks, [
    {post, [
        {compile, {rust, build}},
        {clean, {rust, clean}},
        {eunit, {rust, test}}
    ]}
]}.

This will automatically download and use rebar3_rust. Crates will be compiled whenever the containing app is compiled. The cargo --release switch will be used when the prod profile is active. For example:

rebar3 as prod compile

Application structure with Rust crates

To add crates to an Erlang application, place them in a crates/ folder. All crates found within will be built and resulting artifacts will be placed in the priv/crates/ folder.

The library application find_crate may be used to reliably find artifacts in priv/crates in a cross-platform manner.

Project structure:

myapp/
    rebar.config
    ebin/
        ...
    src/
         ...
    crates/
        foo_nif/
            Cargo.toml
            ...
        bar_port/
            Cargo.toml
             ...
    priv/
        crates/
            foo_nif/
                libfoo_nif.so
            bar_port/
                bar_port

About

Rebar3 plugin to build Rust crates

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Erlang 82.1%
  • Rust 17.9%