3

我有一个 rebar 依赖项,需要在编译应用程序之前运行“./configure”命令(它实际上生成 Makefile)。是否可以告诉 rebar 如何构建特定的依赖项?

4

2 回答 2

4

在 Rebar 邮件列表中讨论了这个问题后,我最终创建了一个 Rebar 插件。在这里,以防有人需要做类似的事情。当前的 Rebar 插件 API 需要最后的“ok”。

-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.
于 2011-08-15T08:45:19.960 回答
1

在你的 rebar.config 文件中,你可以定义一个预编译钩子。它基本上是在实际编译之前运行的 shell 命令/脚本。

{pre_hooks, [
    {compile, "path/to/dep/configure"
]}
于 2011-08-11T22:32:21.207 回答