[erlang-questions] Getting Dependencies for Erlang Files

Ciprian Dorin, Craciun <>
Fri Dec 18 09:20:27 CET 2009


2009/12/18 Björn Gustavsson <>:
> On Thu, Dec 17, 2009 at 7:07 PM, Jayson Vantuyl <> wrote:
>> Not content to wait for an answer, I wrote a rough escript that will use the same functions the compiler uses to extract dependencies.  Well, at least it gets .hrl files for .erl files.  I was surprising to discover is not everything the compiler can compile, but that's another story.
>>
>
> There is currently a topic branch in the git reposiotory by
> Jean-Sébastien Pédron
> to generate dependencies:
>
> http://github.com/erlang/otp/commit/c0734e8a85270d08beda34c4e28aed21b350fb18
>
> Feedback would be welcome, both positive ("I have tested it, and it
> does everything I expect it to do") and negative ("It does not correctly handle
> the following..."), or suggestions for improvements.
>
> --
> Björn Gustavsson, Erlang/OTP, Ericsson AB


    Hy all!

    It seems that lately there was a lot of discussions on this
mailing list about Erlang or Erlang related build systems... It just
happens that I've also made my own (very simple and still in an alpha
version). :)

    But back to the problem... My solution to extracting include
dependencies in Erlang .erl source files was much simpler (and maybe
quicker), and that is using sed:

~~~~~ (part of my makefile generator)

                        cat "${_file}" \
                        | grep -E -e
'^\s*-include\s*\(\s*"\s*[^"]+\s*"\s*\)\s*.' \
                        | sed -E -e
's|^.*"\s*([^"]+)\s*".*$|'"${application__outputs__ebin__path}/${_beam_name}
: "'applications__hrl__\1|' \
                        || true
~~~~~

    It spits out something like:
~~~~~
$(json__outputs__ebin__path)/json.beam : applications__hrl__json.hrl
$(json__outputs__ebin__path)/json.beam : applications__hrl__transcript.hrl
~~~~~

   The `hrl__something.hrl` target is generated by another part of my
build system, like:
~~~~~
applications__hrl__json.hrl :: $(json__outputs__src__path)/json.hrl
applications__hrl__json.hrl :: $(json__outputs__include__path)/json.hrl
~~~~~

    Ciprian.


More information about the erlang-questions mailing list