Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rebar3 integration? #85

Closed
benoitc opened this issue Feb 21, 2017 · 29 comments
Closed

rebar3 integration? #85

benoitc opened this issue Feb 21, 2017 · 29 comments

Comments

@benoitc
Copy link

benoitc commented Feb 21, 2017

Do you know about any rebar3 plugin to compile nifs built with rustler?

@hansihe
Copy link
Member

hansihe commented Feb 21, 2017

I know @goertzenator has been working on some stuff related to that, namely cargo-erlangapp.

I am fairly sure this could be used relatively easily with rustler, and it would be worth having a look.

@goertzenator
Copy link
Contributor

Did you try this one?

@benoitc
Copy link
Author

benoitc commented Feb 26, 2017

@goertzenator nope i didn't find it at first time. Thanks for the link :)

@fbernier
Copy link

Just for rerefence for people looking at this issue, rebar3-rust works on linux, but is missing some logic to pass specific compile options on macos. cargo-erlangapp works on both linux and osx.

@tsloughter
Copy link

I just use hooks for now https://github.com/tsloughter/rebar3_run/tree/rust

@fbernier
Copy link

fbernier commented Mar 1, 2017

@tsloughter Neat. Unfortunately this looks like it's working only on linux.

It should be slightly more complicated to get it to work on linux, macos and windows. See https://github.com/goertzenator/cargo-erlangapp/blob/master/src/lib.rs#L166 and https://github.com/goertzenator/cargo-erlangapp/blob/master/src/lib.rs#L19.

@tsloughter
Copy link

Ah yea, it takes architecture patterns to match on in the hooks it can use for that. Not sure if that'd be enough to do whatever is needed though. So yea, nm, hopefully one of the plugins fills in the gaps :).

@goertzenator
Copy link
Contributor

And it needs to parse JSON provided by cargo to discover all the binary artifacts.

An Erlang port of cargo-erlangapp would put us a stone's throw from having a portable Rust plugin for rebar3.

@fbernier
Copy link

fbernier commented Mar 1, 2017

@goertzenator I'm just starting erlang but I would work toward shipping a rust NIF in production eventually. Could you elaborate on your though on the best process we should build?

You wish someone would rewrite cargo-erlangapp in erlang, or just write an erlang wrapper around it?

@goertzenator
Copy link
Contributor

Thinking about this a little more, a good way forward is to fork https://github.com/sdwolf/rebar3_rust and then port in the capabilities of cargo-erlangapp. I'll eventually get to this myself, but I'll happily help if somebody starts this before me.

The main problem with cargo-erlangapp is that it takes a while (30-60 sec?) to compile on account of having to bring in JSON crates. Managing the installation would also be a hassle. There's nothing in cargo-erlangapp that can't be easily done in Erlang.

@hansihe
Copy link
Member

hansihe commented Mar 1, 2017

It would be nice if rustler_mix and the rebar3 plugin could share the same logic for compilation. If something gets implemented in erlang, I would be very interested in making rustler_mix use that.

@goertzenator
Copy link
Contributor

I've got a good start on a rebar3 plugin. It does compile crates on linux, but definitely needs a little more work.

@hansihe : Is rustler_mix a generic crate builder or is it coupled to the rest of Rustler in some way?

@hansihe
Copy link
Member

hansihe commented Mar 7, 2017

@goertzenator There is a boilerplate generator for Rustler in there, but the crate builder itself should be fully generic.

@goertzenator
Copy link
Contributor

Ok, good. I'll make a point of getting this plugin tidy and well documented so that it's logic can be ported more easily to rustler_mix. I'll give you heads up when I think it is ready for that.

@fbernier
Copy link

fbernier commented Mar 7, 2017

@goertzenator Great work. I had started something but what you have seems better I think. I'll check it out more and try to help.

@Jxck
Copy link

Jxck commented Oct 22, 2018

any updates ?

@filmor
Copy link
Member

filmor commented Oct 13, 2019

I've started work on updating goertzenator's project here: https://github.com/filmor/rebar3_rust/tree/update.

It works slightly differently now than before, but I'm so far very content with the new behaviour. It's used in https://github.com/filmor/faster_xml and https://github.com/filmor/arrow-erlang. The plugin is still agnostic to whether you use rustler or rustler_sys (or erlang_nif-sys) and does away with the need of something like find_crate. Documentation will follow as soon as it's ready for public consumption, and I'll probably upload it to Hex then.

@benoitc
Copy link
Author

benoitc commented Oct 14, 2019

awesome. thanks!

@scrogson
Copy link
Member

Just thinking about naming...does it make more sense to call it rebar3_cargo?

@filmor
Copy link
Member

filmor commented Oct 14, 2019

It could make more sense, yes. I think that the current name is a bit more googleable and it's more obvious for non-Rust BEAM users what it's about.

@scrogson
Copy link
Member

Seems that non-Rust BEAM users wouldn't be using it directly right? It would be NIF devs that would configure their lib to use the rebar3 plugin?

@tsloughter
Copy link

I just upgraded my simple app to use rustler 0.22 rc.0 and loving it. code is now just:

mod atoms {
    rustler::atoms! { ok }
}

#[rustler::nif]
fn console(path: String) -> NifResult<Atom> {
    // Run release with console
    let _ = Command::new(path).arg("console").exec();

    Ok(atoms::ok())
}

rustler::init!("rebar3_run", [console]);

But I'm still using the rebar3 hooks and want to get a good plugin done before using this for any real projects.

@filmor are you still maintaining? And is @goertzenator still around so updates can be upstreamed?

And then what about having the plugin as part of the @rusterlium org? :)

After all that I can worry about poking @lpil about it generating typed functions for NIFs used from @gleam-lang :)

@filmor
Copy link
Member

filmor commented Mar 8, 2020

I'm still working on it, I forked goertzenator's work as rebar3_cargo depending on a new cargo package for Erlang. I'm currently working on getting Rustler's Elixir tooling use that as well s.t. we have a common base. Moving it to rusterlium when releasing to Hex is a good idea.

@lpil
Copy link

lpil commented Mar 8, 2020

After all that I can worry about poking @lpil about it generating typed functions for NIFs used from @gleam-lang :)

That would be so cool!

@goertzenator
Copy link
Contributor

I don't see myself doing any more work on https://github.com/goertzenator/rebar3_rust . I will happily hand the repo over to someone else if they want it.

@scrogson
Copy link
Member

scrogson commented Mar 9, 2020

what about having the plugin as part of the @rusterlium org?

Yes, that would be excellent 👍

@filmor
Copy link
Member

filmor commented Mar 10, 2020

I've transferred erlang-cargo and rebar3_cargo into the rusterlium org.

@filmor
Copy link
Member

filmor commented May 3, 2020

rebar3_cargo is nearly done, the only functionality missing is handling of executables. As soon as that is done, I'll publish things to Hex.

@tsloughter
Copy link

Sweet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants