5 releases

Uses old Rust 2015

0.1.4 Oct 6, 2016
0.1.3 Aug 12, 2016
0.1.2 Jul 26, 2016
0.1.1 Jul 21, 2016
0.1.0 Jul 21, 2016

#18 in #cargo-clean

25 downloads per month
Used in erlang_nif-sys

MIT license

17KB
345 lines

cargo-erlangapp

A cargo subcommand for building Rust crates embedded in an Erlang application. All crates in the crates directory get compiled and placed into priv/crates. Below is an example of an Erlang application with the artifacts from two crates placed into priv/crates:

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

cargo-erlangapp is intended to be installed and used automatically by Erlang build system like erlang.mk and rebar3, but may also be used manually.

The Erlang application find_crate assists in locating Rust artifacts in priv/crates.

Installation

cargo install cargo-erlangapp

Usage

Usage:
        cargo-erlangapp build [cargo rustc args]
        cargo-erlangapp clean [cargo clean args]
        cargo-erlangapp test [cargo test args]

Under the Hood

cargo-erlangapp takes care of a few wrinkles when compiling Rust code for Erlang:

  • OS X requires special link flags when compiling dylibs (ie, NIF modules) for Erlang. To do that, cargo-erlangapp has to read the JSON manifest to identify all the targets and compile each individually and applying special flags to just dylibs.
  • On OS X, the Erlang dylib loader requires files named differently than what Rust produces.

Dependencies

~1.5MB
~28K SLoC