Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling external libs with rebar

I want to use some libs in my application, like https://github.com/Panmind/erlang-ruby-marshal. That repo holds an src dir, but has no .app file (because it's not an application), so I can't use get-deps.

I tried another approach, adding a libs dir in sub_dirs and added the repo as a git submodule, but rebar won't compile any of its files. I guess that rebar only compiles otp applications, but not just .erl files that aren't tied to an application.

How do you manage those kind of dependencies? I would like to avoid copying the files to my app dir, because I don't think they belong there, and I kind of like the git submodule approach, that allows me to keep track of the lib version I am using.

like image 460
Papipo Avatar asked Apr 01 '11 07:04

Papipo


2 Answers

Recent rebar supports raw option for dependencies. When this option is specific, rebar does not require the dependency to have a standard Erlang/OTP layout which assumes the presence of either "src/dependency_name.app.src" or "ebin/dependency_name.app" files (see more details here).

For example:

{deps, [
  {erlang_ruby_marshal, "",
    {git, "https://github.com/Panmind/erlang-ruby-marshal", {branch, master}},
    [raw]}
]}.

Note that rebar will now be able to fetch it, but it still won't compile it. As other commenters pointed out, there's no reason why this dependency should not have an .app file. I would fork the repository and add the .app file to it.

like image 58
alavrik Avatar answered Oct 14 '22 18:10

alavrik


This article goes through the bigger process of creating applications and releases with rebar.

More specifically, I think this option in rebar.config might be what you're looking for. The only way I've found so far is to have one entry for each application:

{sub_dirs, ["libs/app1",
            "libs/app2",
            ...]}.

This requires a bit more manual work. Unfortunately rebar is very structured around the concept of one app only, and would need some better support for caring for a repository with a bunch of equally worth applications instead of a single application.

like image 32
Adam Lindberg Avatar answered Oct 14 '22 16:10

Adam Lindberg