cargo-erlangapp

Crates.iocargo-erlangapp
lib.rscargo-erlangapp
version0.1.4
sourcesrc
created_at2016-07-21 15:09:56.594318
updated_at2016-10-06 14:26:18.569508
descriptionBuild Rust crates embedded in an Erlang application
homepage
repositoryhttps://github.com/goertzenator/cargo-erlangapp
max_upload_size
id5740
size21,452
Daniel Goertzen (goertzenator)

documentation

README

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.
Commit count: 24

cargo fmt