Proposal to make Rebar more extensible for other Erlang VM languages

José Valim jose.valim at gmail.com
Wed May 30 04:53:16 EDT 2012


Hello everyone,

This is a proposal to make Rebar more extensible when it comes to other
Erlang VM languages.

The main goal here is to allow the "foreign" language (Joxa, LFE, Elixir,
etc) developer to configure Rebar using the "foreign" language itself,
without a need to write Erlang terms according to the `file:consult()`
behavior.

A simple solution to this problem is to add a configuration to rebar that
teaches it how to search and handle the expected files. For example, there
is logic spread in Rebar code to handle both *.config and *.config.script
files that could be wrapped in this solution. We could imagine this
configuration would look like:

    { rebar_config_formats, [
      { "rebar.config", fun file:consult/1 },
      { "rebar.config.script", fun rebar_utils:script_consult/1 },
      { "rebar.yaml", fun
just_an_example:not_sure_if_this_is_actually_possible/1 },
      { "rebar.jxa", fun joxa:consult/1 }
    ] }

By default, rebar.config and rebar.config.script would be available. This
configuration pattern should also be available to the other config files,
like reltool.config and so forth.

The only problem to this issue is the chicken-egg situation since we need
to first configure rebar in order to teach it how to use our
"rebar.custom_config". We already have the ~/rebar/config but the ideal
solution would be to expose an official Erlang API so these other languages
could simply wrap Rebar in their own build tools if they desire so.

This API would receive a list of arguments (the same as rebar:main/1) and
an optional configuration (the same we would get from ~/rebar/config). I
propose this API to be rebar:run/2 which seems to be straight-forward to
implement. There is just one part of rebar code that expects it to run as
an escript, which is list-templates in "rebar_templater.erl". But we can
easily modify it to handle both being invoked directly from Erlang and as a
script.

That said, I would like some early feedback from rebar maintainers before I
can go ahead and write some patches. :)

Thanks for reading,

*
José Valim
www.plataformatec.com.br
Founder and Lead Developer
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/rebar_lists.basho.com/attachments/20120530/53327f05/attachment.html>


More information about the rebar mailing list