summaryrefslogtreecommitdiff
path: root/src/rebar_compiler_xrl.erl
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2018-11-23 14:56:03 -0700
committerGitHub <noreply@github.com>2018-11-23 14:56:03 -0700
commit37fdc7e515bd3db197cec92fa476923d19ec283a (patch)
tree6275dd5121b8a1bebb75482af4ee586c9d2aa447 /src/rebar_compiler_xrl.erl
parent84d48ac09bfab62d50b8c4a2046a04ae1218f25a (diff)
fix base path used for yrl/xrl includefile configs (#1952)
Diffstat (limited to 'src/rebar_compiler_xrl.erl')
-rw-r--r--src/rebar_compiler_xrl.erl30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/rebar_compiler_xrl.erl b/src/rebar_compiler_xrl.erl
index 23ed1eb..35447ed 100644
--- a/src/rebar_compiler_xrl.erl
+++ b/src/rebar_compiler_xrl.erl
@@ -8,6 +8,8 @@
compile/4,
clean/2]).
+-export([update_opts/2]).
+
context(AppInfo) ->
Dir = rebar_app_info:dir(AppInfo),
Mappings = [{".erl", filename:join([Dir, "src"])}],
@@ -25,28 +27,38 @@ needed_files(_, FoundFiles, Mappings, AppInfo) ->
rebar_compiler:needs_compile(Source, ".erl", Mappings)],
Opts = rebar_opts:get(rebar_app_info:opts(AppInfo), xrl_opts, []),
+ Opts1 = update_opts(Opts, AppInfo),
- {{FirstFiles, Opts}, {RestFiles, Opts}}.
+ {{FirstFiles, Opts1}, {RestFiles, Opts1}}.
dependencies(_, _, _) ->
[].
-compile(Source, [{_, OutDir}], _, Opts) ->
- BaseName = filename:basename(Source),
- Target = filename:join([OutDir, BaseName]),
- AllOpts = [{parserfile, Target} | Opts],
- AllOpts1 = [{includefile, filename:join(OutDir, I)} || {includefile, I} <- AllOpts,
- filename:pathtype(I) =:= relative],
- case leex:file(Source, AllOpts1 ++ [{return, true}]) of
+compile(Source, [{_, _}], _, Opts) ->
+ case leex:file(Source, [{return, true} | Opts]) of
{ok, _} ->
ok;
{ok, _Mod, Ws} ->
rebar_compiler:ok_tuple(Source, Ws);
{error, Es, Ws} ->
- rebar_compiler:error_tuple(Source, Es, Ws, AllOpts1)
+ rebar_compiler:error_tuple(Source, Es, Ws, Opts)
end.
clean(XrlFiles, _AppInfo) ->
rebar_file_utils:delete_each(
[rebar_utils:to_list(re:replace(F, "\\.xrl$", ".erl", [unicode]))
|| F <- XrlFiles]).
+
+%% make includefile options absolute paths
+update_opts(Opts, AppInfo) ->
+ OutDir = rebar_app_info:out_dir(AppInfo),
+ lists:map(fun({includefile, I}) ->
+ case filename:pathtype(I) =:= relative of
+ true ->
+ {includefile, filename:join(OutDir, I)};
+ false ->
+ {includefile, I}
+ end;
+ (O) ->
+ O
+ end, Opts).