erlang.mk icon indicating copy to clipboard operation
erlang.mk copied to clipboard

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

Open artman41 opened this issue 1 year ago • 17 comments

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

This change accomplishes the following:

  • Converts mix.exs projects to use erlang.mk
  • Compiles .ex files, allowing for a project to use either Erlang, Elixir or a combination of both
  • Properly configures paths so that Elixir dependencies are added to the $(PROJECT).app
  • Treats Elixir as a dependency & fetches it as such, rather than relying on a system installation

This change makes use of hex.mk

artman41 avatar Jun 04 '23 17:06 artman41

Currently rebasing the change :)

artman41 avatar Jun 04 '23 17:06 artman41

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

artman41 avatar Jun 04 '23 17:06 artman41

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.

essen avatar Jun 05 '23 06:06 essen

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?

artman41 avatar Jun 05 '23 08:06 artman41

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

essen avatar Jun 05 '23 08:06 essen

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 avatar Jun 05 '23 22:06 artman41

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

artman41 avatar Jun 21 '23 12:06 artman41

Does this work even if using local system installed Elixir?

essen avatar Jun 26 '23 10:06 essen

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.

artman41 avatar Jun 26 '23 17:06 artman41

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

essen avatar Jun 27 '23 07:06 essen

@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 avatar Jul 02 '23 23:07 artman41

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

artman41 avatar Jul 05 '23 10:07 artman41

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

essen avatar Jul 05 '23 10:07 essen

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

artman41 avatar Sep 02 '23 17:09 artman41

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?

essen avatar Sep 04 '23 13:09 essen