I wanted to integrate Elixir into our project, and the good old codes don't use rebar
, so I think writing the rules for building .ex
files into Emakefile
may be a good idea, yet the man page here didn't mention anything relevant.
Edit:
Our team works mainly in Windows environment, but the deployment will be done on Linux servers, so I need a cross-platform solution. Since Erlang itself is cross-platform, I wanted to do it with erl -make
command.
Of course I can write a Makefile
, but then I'll need a build.bat
or something alike to build the code in our developing environments, since we don't have make
command on our dev' machines.
Anyone have a better idea?
Update:
In case anyone wants to know, I'm doing it this way:
lib/elixir
directory in the Elixir source tree to our source dir, say some_project/src/tools/elixir
.some_project/src/tools/elixir/src/elixir_transform.erl
and some_project/src/tools/elixir/src/*
to the Emakefile
, in that order. Set the output dir to some_project/ebin
(All the other .beam
files are located there).src/elixir.app.src
in the Elixir source tree to some_project/ebin/elixir.app
, and edit it to fix the version code.erl -pa ebin -make
, in some_project
dir.erl -pa ebin -s elixir_compiler core -s erlang halt
.ex
files:%%! -pa ./ebin main(_) -> ExList = [ <<"source_1.ex">>, <<"source_2.ex">>, <<"source_3.ex">>], application:start(elixir), gen_server:call(elixir_code_server, {compiler_options, [{docs, true}, {debug_info, true}]}), [elixir_compiler:file_to_path(F, <<"./ebin">>) || F <- ExList], erlang:halt(0).
If you want to explicitly compile Elixir, I would go with the Makefile approach since it will always be supported by Elixir. However, I would recommend the precompiled binaries or even assume Elixir is installed in each developer machine. You can even add a task to your Emakefile to guarantee everyone is using the proper Elixir version.
Finally, about compiling your own Elixir code, I would recommend simply using mix
. mix
is a binary that ships with Elixir and you can simply do ./src/tools/elixir/bin/mix compile
from your Emakefile
.
In case using mix is not possible, you should use the parallel compiler, since it will compile files using all cores available in your machine and it will automatically detect and solve dependency in between files. Here is an example of calling the parallel compiler from erlang:
https://github.com/basho/rebar/pull/347/files#L1R62
The API is very simple. It expects a list of file names to compile as binary and the directory to output files to as another binary.