From 21ed404df9b353bafe328fb0c69cf1134ae14d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 16 May 2015 15:27:23 +0300 Subject: Initial rebar2 plugins support We do nothing more than what is necessary to make riak_pb work. It's possible other plugins will not work, however this is the only plugin that I have seen to be required so far, and hook plugins seem to have been removed from rebar3, so it should be fine. --- core/deps.mk | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'core/deps.mk') diff --git a/core/deps.mk b/core/deps.mk index dfbe5ce..820f72a 100644 --- a/core/deps.mk +++ b/core/deps.mk @@ -260,6 +260,26 @@ define dep_autopatch_rebar.erl Write("\n\nCFLAGS := $$$$\(filter-out -std=c99 -Wmissing-prototypes,$$$$\(CFLAGS\)\)\n") end end(), + fun() -> + case lists:keyfind(plugins, 1, Conf) of + {_, [Plugin]} when is_atom(Plugin) -> + ErlFile = "$(DEPS_DIR)/$(1)/plugins/" ++ atom_to_list(Plugin) ++ ".erl", + try + {ok, PF} = file:read_file(ErlFile), + PF2 = re:replace(PF, "rebar_utils:find_files", "find_files", [global, {return, list}]), + PF3 = PF2 ++ "find_files(Dir, Regex) -> + filelib:fold_files(Dir, Regex, true, fun(F, Acc) -> [F|Acc] end, []).", + ok = file:write_file(ErlFile, PF3), + {ok, Mod, Bin} = compile:file(ErlFile, [binary]), + {module, Mod} = code:load_binary(Mod, ErlFile, Bin), + c:cd("$(DEPS_DIR)/$(1)/"), + ok = Mod:pre_compile(Conf, undefined) + catch _:_ -> + ok + end; + _ -> ok + end + end(), halt() endef -- cgit v1.2.3