From ff56b5a89e2574915ef00f637d69da34fe31b570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 6 Jun 2015 15:35:10 +0300 Subject: Improve parse_transform and import detection Necessary changes for the alog application. --- core/deps.mk | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/deps.mk b/core/deps.mk index c86621a..dc5e6e6 100644 --- a/core/deps.mk +++ b/core/deps.mk @@ -214,8 +214,13 @@ define dep_autopatch_rebar.erl end(), FindFirst = fun(F, Fd) -> case io:parse_erl_form(Fd, undefined) of - {ok, {attribute, _,compile, {parse_transform, PT}}, _} -> + {ok, {attribute, _, compile, {parse_transform, PT}}, _} -> [PT, F(F, Fd)]; + {ok, {attribute, _, compile, CompileOpts}, _} when is_list(CompileOpts) -> + case proplists:get_value(parse_transform, CompileOpts) of + undefined -> [F(F, Fd)]; + PT -> [PT, F(F, Fd)] + end; {ok, {attribute, _, include, Hrl}, _} -> case file:open("$(DEPS_DIR)/$(1)/include/" ++ Hrl, [read]) of {ok, HrlFd} -> [F(F, HrlFd), F(F, Fd)]; @@ -228,6 +233,11 @@ define dep_autopatch_rebar.erl {ok, {attribute, _, include_lib, "$(1)/include/" ++ Hrl}, _} -> {ok, HrlFd} = file:open("$(DEPS_DIR)/$(1)/include/" ++ Hrl, [read]), [F(F, HrlFd), F(F, Fd)]; + {ok, {attribute, _, include_lib, Hrl}, _} -> + case file:open("$(DEPS_DIR)/$(1)/include/" ++ Hrl, [read]) of + {ok, HrlFd} -> [F(F, HrlFd), F(F, Fd)]; + _ -> [F(F, Fd)] + end; {ok, {attribute, _, import, {Imp, _}}, _} -> case file:open("$(DEPS_DIR)/$(1)/src/" ++ atom_to_list(Imp) ++ ".erl", [read]) of {ok, ImpFd} -> [Imp, F(F, ImpFd), F(F, Fd)]; -- cgit v1.2.3