[erlang-questions] Configuring rebar across directories

Juan Jose Comellas juanjo@REDACTED
Tue Jun 18 17:02:35 CEST 2013


Tuncer, is there a reason why the rebar lib_dirs configuration setting only
allows relative paths? Right now the function that expands these paths
looks like this:

    expand_lib_dirs([], _Root, Acc) ->
        Acc;
    expand_lib_dirs([Dir | Rest], Root, Acc) ->
        Apps = filelib:wildcard(filename:join([Dir, "*", "ebin"])),
        FqApps = [filename:join([Root, A]) || A <- Apps],
        expand_lib_dirs(Rest, Root, Acc ++ FqApps).

Changing it to something like this would resolve this problem:

    expand_lib_dirs([], _Root, Acc) ->
        Acc;
    expand_lib_dirs([Dir | Rest], Root, Acc) ->
        Apps = filelib:wildcard(filename:join([Dir, "*", "ebin"])),
        FqApps = case filename:pathtype(Dir) of
                     absolute -> Apps;
                     relative -> [filename:join([Root, A]) || A <- Apps]
                 end,
        expand_lib_dirs(Rest, Root, Acc ++ FqApps).

Would this addition be accepted into rebar? I haven't created a pull
request for this because I don't know what the rationale was for making
these paths relative.

Juanjo




On Tue, Jun 18, 2013 at 8:40 AM, Tuncer Ayaz <tuncer.ayaz@REDACTED> wrote:

> On Wed, May 29, 2013 at 3:58 PM,  <yashgt@REDACTED> wrote:
> > I have
> > myapp
> > /src
> > myapp.erl
> > myapp_sup.erl
> > /include
> > and
> > mymodule
> > /src
> > mymodule.erl
> > /include
> > mymodule.hrl
> >
> > As you can see, I have developed a module which is outside the
> > structure of the myapp. If a module in myapp has to use the header
> > files of mymodule, what do I need to do in the rebar.config of
> > myapp?
> >
> > Currently, when I compile myapp, it gives an error that the
> > mymoduel.hrl cannot be found.
> >
> > My intention is to develop mymodule as a shared module across
> > several apps.
>
> The usual way is to make mymodule part of ERL_LIBS and then
> -include_lib("mymodule/include/mymodule.hrl").
>
> You can either configure the ERL_LIBS env var or {lib_dirs, []} in
> rebar.config. Many projects put libs or apps in a separate apps/
> directory and configure the top level rebar.config accordingly.
> In your case that would be:
> {lib_dirs, ["apps"]}.
> {sub_dirs, ["apps/myapp", "apps/mymodule"]}.
>
> Alternatively you can modify erl_opts (.erl compile opts) in
> rebar.config to add extra include paths as follows, but this would be
> unconventional and might be less flexible:
> {erl_opts, [{i, "../mymodule/include"}]}.
>
> For more help see compile(3)[1] or run 'rebar help compile'.
>
> [1] http://www.erlang.org/doc/man/compile.html
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130618/05dbaef4/attachment.htm>


More information about the erlang-questions mailing list