diff options
author | Tristan Sloughter <t@crashfast.com> | 2018-11-23 14:56:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-23 14:56:03 -0700 |
commit | 37fdc7e515bd3db197cec92fa476923d19ec283a (patch) | |
tree | 6275dd5121b8a1bebb75482af4ee586c9d2aa447 /src | |
parent | 84d48ac09bfab62d50b8c4a2046a04ae1218f25a (diff) |
fix base path used for yrl/xrl includefile configs (#1952)
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_compiler_xrl.erl | 30 | ||||
-rw-r--r-- | src/rebar_compiler_yrl.erl | 14 |
2 files changed, 28 insertions, 16 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). diff --git a/src/rebar_compiler_yrl.erl b/src/rebar_compiler_yrl.erl index 9c1767e..8e52d0e 100644 --- a/src/rebar_compiler_yrl.erl +++ b/src/rebar_compiler_yrl.erl @@ -25,24 +25,24 @@ needed_files(_, FoundFiles, Mappings, AppInfo) -> rebar_compiler:needs_compile(Source, ".erl", Mappings)], Opts = rebar_opts:get(rebar_app_info:opts(AppInfo), yrl_opts, []), - {{FirstFiles, Opts}, {RestFiles, Opts}}. + Opts1 = rebar_compiler_xrl:update_opts(Opts, AppInfo), + + {{FirstFiles, Opts1}, {RestFiles, Opts1}}. dependencies(_, _, _) -> []. compile(Source, [{_, OutDir}], _, Opts) -> - BaseName = filename:basename(Source), + BaseName = filename:basename(Source, ".yrl"), Target = filename:join([OutDir, BaseName]), - AllOpts = [{parserfile, Target} | Opts], - AllOpts1 = [{includefile, filename:join(OutDir, I)} || {includefile, I} <- AllOpts, - filename:pathtype(I) =:= relative], - case yecc:file(Source, AllOpts1 ++ [{return, true}]) of + AllOpts = [{parserfile, Target}, {return, true} | Opts], + case yecc:file(Source, AllOpts) 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, AllOpts) end. clean(YrlFiles, _AppInfo) -> |