ninenines / erlang.mk

A build tool for Erlang that just works.
https://erlang.mk
ISC License
578 stars 241 forks source link

Add Elixir.mk - Allows for use of Elixir deps within an Erlang project. #979

Open artman41 opened 1 year ago

artman41 commented 1 year ago

This change introduces a new core plugin called elixir.mk.

This change accomplishes the following:

This change makes use of hex.mk

artman41 commented 1 year ago

Currently rebasing the change :)

artman41 commented 1 year ago

@essen I've added a test under test/core_elixir.mk though I've been testing locally with a sample project.

essen commented 1 year ago

Hello! I've not had a good look yet but I doubt this works with some Elixir NIFs since they often have a Makefile and thus wouldn't enter the elixir autopatch.

artman41 commented 1 year ago

Hello! I've not had a good look yet but I doubt this works with some Elixir NIFs since they often have a Makefile and thus wouldn't enter the elixir autopatch.

Damn, that's a good shout - any idea of an elixir lib which uses NIFs?

essen commented 1 year ago

There's a few in this search but gotta filter. Oftentimes if the page says mix + make as a build tool, that's an Elixir NIF. But not always.

https://hex.pm/packages?search=nif&sort=total_downloads

artman41 commented 1 year ago

There's a few in this search but gotta filter. Oftentimes if the page says mix + make as a build tool, that's an Elixir NIF. But not always.

https://hex.pm/packages?search=nif&sort=total_downloads

I've just commited a change which should now make it support Elixir Nifs (assuming they use elixir_make - I'm not 100% familiar with the Elixir NIF ecosystem so not quite sure if I've accounted for the right things there).

I've added an additional test which will attempt to compile libsalty2, though this depends on libsodium.

If you've any more suggestions @essen, I'm more than happy to add them 👍

artman41 commented 1 year ago

Any chance I could poke you to look this over @essen? 😄

essen commented 1 year ago

Does this work even if using local system installed Elixir?

artman41 commented 1 year ago

Does this work even if using local system installed Elixir?

In what sense @essen?

I'm expecting elixir to always be loaded as a dep of the project rather than as an installed version on the system - I can try and account for this though if you'd prefer that functionality to be in there.

I'll edit this for confirmation but the only thing I think that could be problematic with an installed version of elixir is if code:get_path() returned paths to the installed elixir version, though I wouldn't ever expect that to be the case with a standard install.

essen commented 1 year ago

I think we should take the dep Elixir if one is available as a dep, and the system Elixir otherwise. Basically the dep can be used as an override.

Most projects don't require a specific version of Elixir, and for example in RabbitMQ we explicitly use the system Elixir (we even build packages for it).

artman41 commented 1 year ago

@essen could you have a look over when you have chance?

Based on your feedback, I've updated the MR to default to using the System Install of Elixir if available. This can be manually overriden by a user-set var though (ELIXIR_USE_SYSTEM)

Let me know what you think :)

artman41 commented 1 year ago

@essen could you have a look over when you have chance?

Based on your feedback, I've updated the MR to default to using the System Install of Elixir if available. This can be manually overriden by a user-set var though (ELIXIR_USE_SYSTEM)

Let me know what you think :)

just poking you 😄

essen commented 1 year ago

I'll get to it no need to remind so often.

artman41 commented 1 year ago

@essen sorry to poke on this one again, any idea when you'll be able to get round to it? :)

essen commented 1 year ago

Is the thing that transforms paths like Elixir/MyApp/MyMod.ex into module name Elixir.MyApp.MyMod something the compiler does, or am I just blind and I missed it?