mirror of
https://github.com/correl/rebar.git
synced 2024-11-27 19:19:53 +00:00
Merge pull request #111 from tuncer/nox-erlydtl-compile
Always return the errors and warnings from erlydtl
This commit is contained in:
commit
72247281a2
1 changed files with 15 additions and 17 deletions
|
@ -116,8 +116,8 @@ compile(Config, _AppFile) ->
|
||||||
option(source_ext, DtlOpts),
|
option(source_ext, DtlOpts),
|
||||||
option(out_dir, DtlOpts),
|
option(out_dir, DtlOpts),
|
||||||
option(module_ext, DtlOpts) ++ ".beam",
|
option(module_ext, DtlOpts) ++ ".beam",
|
||||||
fun(S, T, _C) ->
|
fun(S, T, C) ->
|
||||||
compile_dtl(S, T, DtlOpts)
|
compile_dtl(C, S, T, DtlOpts)
|
||||||
end,
|
end,
|
||||||
[{check_last_mod, false},
|
[{check_last_mod, false},
|
||||||
{recursive, option(recursive, DtlOpts)}])
|
{recursive, option(recursive, DtlOpts)}])
|
||||||
|
@ -169,10 +169,10 @@ default(out_dir) -> "ebin";
|
||||||
default(source_ext) -> ".dtl";
|
default(source_ext) -> ".dtl";
|
||||||
default(module_ext) -> "_dtl";
|
default(module_ext) -> "_dtl";
|
||||||
default(custom_tags_dir) -> "";
|
default(custom_tags_dir) -> "";
|
||||||
default(compiler_options) -> [report, return];
|
default(compiler_options) -> [return];
|
||||||
default(recursive) -> true.
|
default(recursive) -> true.
|
||||||
|
|
||||||
compile_dtl(Source, Target, DtlOpts) ->
|
compile_dtl(Config, Source, Target, DtlOpts) ->
|
||||||
case code:which(erlydtl) of
|
case code:which(erlydtl) of
|
||||||
non_existing ->
|
non_existing ->
|
||||||
?ERROR("~n===============================================~n"
|
?ERROR("~n===============================================~n"
|
||||||
|
@ -185,13 +185,13 @@ compile_dtl(Source, Target, DtlOpts) ->
|
||||||
_ ->
|
_ ->
|
||||||
case needs_compile(Source, Target, DtlOpts) of
|
case needs_compile(Source, Target, DtlOpts) of
|
||||||
true ->
|
true ->
|
||||||
do_compile(Source, Target, DtlOpts);
|
do_compile(Config, Source, Target, DtlOpts);
|
||||||
false ->
|
false ->
|
||||||
skipped
|
skipped
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_compile(Source, Target, DtlOpts) ->
|
do_compile(Config, Source, Target, DtlOpts) ->
|
||||||
%% TODO: Check last mod on target and referenced DTLs here..
|
%% TODO: Check last mod on target and referenced DTLs here..
|
||||||
|
|
||||||
%% ensure that doc_root and out_dir are defined,
|
%% ensure that doc_root and out_dir are defined,
|
||||||
|
@ -208,19 +208,17 @@ do_compile(Source, Target, DtlOpts) ->
|
||||||
case erlydtl:compile(Source,
|
case erlydtl:compile(Source,
|
||||||
module_name(Target),
|
module_name(Target),
|
||||||
Opts) of
|
Opts) of
|
||||||
ok -> ok;
|
ok ->
|
||||||
{error, {File, [{Pos, _Mod, Err}]}} ->
|
ok;
|
||||||
?ERROR("Compiling template ~p failed:~n (~s): ~p~n",
|
error ->
|
||||||
[File, err_location(Pos), Err]);
|
rebar_base_compiler:error_tuple(Config, Source, [], [], Opts);
|
||||||
Reason ->
|
{error, {_File, _Msgs} = Error} ->
|
||||||
?ERROR("Compiling template ~s failed:~n ~p~n",
|
rebar_base_compiler:error_tuple(Config, Source, [Error], [], Opts);
|
||||||
[Source, Reason]),
|
{error, Msg} ->
|
||||||
?FAIL
|
Es = [{Source, [{erlydtl_parser, Msg}]}],
|
||||||
|
rebar_base_compiler:error_tuple(Config, Source, Es, [], Opts)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
err_location({L,C}) -> io_lib:format("line:~w, col:~w", [L, C]);
|
|
||||||
err_location(L) -> io_lib:format("line:~w", [L]).
|
|
||||||
|
|
||||||
module_name(Target) ->
|
module_name(Target) ->
|
||||||
F = filename:basename(Target),
|
F = filename:basename(Target),
|
||||||
string:substr(F, 1, length(F)-length(".beam")).
|
string:substr(F, 1, length(F)-length(".beam")).
|
||||||
|
|
Loading…
Reference in a new issue