Question

I have a rebar dependency which needs a "./configure" command to be run before the application can be compiled (it actually generates the Makefile). Is it possible to tell rebar how to build a specific dependency?

Was it helpful?

Solution

After discussing the issue in the Rebar mailing list, I've ended up by creating a Rebar plugin. Here it is, in case someone needs to do something similar. The final 'ok' is required by the current Rebar plugins API.

-module(rebar_compiledeps_plugin).
-export([pre_compile/2]).

pre_compile(_, _) ->
    Cwd = rebar_utils:get_cwd(),
    case lists:suffix("my_dep", Cwd) of
        true ->
            Opts = [{cwd, Cwd}],
            case filelib:is_regular(filename:join([Cwd, "Makefile"])) of
                true ->
                    rebar_utils:sh("make [OPTIONS]", Opts);
                false ->
                    rebar_utils:sh("./configure && make [OPTIONS]", Opts)
            end;
        false ->
            ok
    end,
    ok.

OTHER TIPS

In your rebar.config file, you can define a pre compile hook. It's basically a shell command/script that's run before the actual compile.

{pre_hooks, [
    {compile, "path/to/dep/configure"
]}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top