How good is mix in compiling other languages when building an application? I am, of course, thinking of LFE, but Erlang or C are also interesting. Can someone point towards where this is documented?
And wouldn’t it be wonderful if I could write the mix spec file in another language, say why not LFE. Just teasing.
Mix task ‘compile’, documented at http://elixir-lang.org/docs/stable/mix/Mix.Tasks.Compile.html takes a list of compilers to compile with, defaulting internally with Elixir as far as I recall. But I have an extra compiler in my program, here is the relevant part of my Mix.exs file :
compilers: [:phoenix, :gettext] ++ Mix.compilers,
So that adds in some phoenix and gettext special compiler things. I have another project that made its own compiler to compile ASN1 files (using Erlang’s stock ASN1 compiler). It is pretty easy to make new compilers, just define the module and define it in the compiler list (such as a Mix.Tasks.Compiler.LFE or so).
But yes, LFE would be quite easy to add as a supported compiler in Mix, just depend on the dependency, have the compilers list add it in (:lfe!), and done for the user.
No clue about a Mix.lfe file though. ^.^
Hmm, actually you could probably make a call from a Mix file that includes a Mix.lfe file if you really wanted. ^.^
I’ve been curious about something, is there any way to use/compile elixir apps and/or hex dependencies in rebar and if so how? It would be nice to start integrating some elixir into some of my old servers.
Awesome, will have to upgrade rebar in those projects (still using the very first rebar as I recall, and Makefiles…, they are old…). Perhaps I should just make the jump and overhaul it all to Mix as it handles erlang fine too…
Yeah for whatever it’s worth, there is a Chocolatey Nuget package for
Rebar3 because at one point I needed R3 on my windows box. I try to keep it
up to date too.
A compiler is a task that implements the mix task behaviour [1] and returns :ok | :noop from the run/1 function depending on if the compiler compiled anything. You can take a look at other compilers, for example the erlang compiler [2].
It would be tricky to allow other languages for the mix.exs file because mix would have to know how to compile it out of the box. The project module registers itself with meta programming, so it would not be possible to write in Erlang, although LFE might be able to do it.