Papipo
Papipo

Reputation: 2811

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.

Upvotes: 8

Views: 5384

Answers (4)

alavrik
alavrik

Reputation: 2161

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.

Upvotes: 3

Asier Azkuenaga
Asier Azkuenaga

Reputation: 1189

If you are using Linux, you can add the required modules as hard links, into the src directory of your application.

This is far from optimal but I have yet to find a better way to do this.

Upvotes: 1

mwt
mwt

Reputation: 669

Ask the Agner guys to add it to their package management system. In the process they will create a fork and convert to make the project rebar compatible. Also, the original maintainer will quite possibly integrate the changes.

Upvotes: 0

Adam Lindberg
Adam Lindberg

Reputation: 16577

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.

Upvotes: 2

Related Questions