我有一个 rebar 依赖项,需要在编译应用程序之前运行“./configure”命令(它实际上生成 Makefile)。是否可以告诉 rebar 如何构建特定的依赖关系?
在 Rebar 邮件列表中讨论了这个问题后,我最终创建了一个 Rebar 插件。就在这里,以防有人需要做类似的事情。最后的“ok”是当前 Rebar 插件 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.
Run Code Online (Sandbox Code Playgroud)