Giter Site home page Giter Site logo

rebar3 integration? about rustler HOT 29 CLOSED

rusterlium avatar rusterlium commented on April 27, 2024 1
rebar3 integration?

from rustler.

Comments (29)

filmor avatar filmor commented on April 27, 2024 4

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.

from rustler.

hansihe avatar hansihe commented on April 27, 2024 2

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.

from rustler.

filmor avatar filmor commented on April 27, 2024 2

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.

from rustler.

tsloughter avatar tsloughter commented on April 27, 2024 1

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 :)

from rustler.

hansihe avatar hansihe commented on April 27, 2024

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.

from rustler.

goertzenator avatar goertzenator commented on April 27, 2024

Did you try this one?

from rustler.

benoitc avatar benoitc commented on April 27, 2024

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

from rustler.

fbernier avatar fbernier commented on April 27, 2024

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.

from rustler.

tsloughter avatar tsloughter commented on April 27, 2024

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

from rustler.

fbernier avatar fbernier commented on April 27, 2024

@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.

from rustler.

tsloughter avatar tsloughter commented on April 27, 2024

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 :).

from rustler.

goertzenator avatar goertzenator commented on April 27, 2024

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.

from rustler.

fbernier avatar fbernier commented on April 27, 2024

@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?

from rustler.

goertzenator avatar goertzenator commented on April 27, 2024

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.

from rustler.

goertzenator avatar goertzenator commented on April 27, 2024

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?

from rustler.

hansihe avatar hansihe commented on April 27, 2024

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

from rustler.

goertzenator avatar goertzenator commented on April 27, 2024

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.

from rustler.

fbernier avatar fbernier commented on April 27, 2024

@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.

from rustler.

Jxck avatar Jxck commented on April 27, 2024

any updates ?

from rustler.

benoitc avatar benoitc commented on April 27, 2024

awesome. thanks!

from rustler.

scrogson avatar scrogson commented on April 27, 2024

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

from rustler.

filmor avatar filmor commented on April 27, 2024

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.

from rustler.

scrogson avatar scrogson commented on April 27, 2024

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?

from rustler.

filmor avatar filmor commented on April 27, 2024

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.

from rustler.

lpil avatar lpil commented on April 27, 2024

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!

from rustler.

goertzenator avatar goertzenator commented on April 27, 2024

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.

from rustler.

scrogson avatar scrogson commented on April 27, 2024

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

Yes, that would be excellent 👍

from rustler.

filmor avatar filmor commented on April 27, 2024

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

from rustler.

tsloughter avatar tsloughter commented on April 27, 2024

Sweet!

from rustler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.