mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Deprecate fail_on_warning and refactor code
This commit is contained in:
parent
121d8f03f9
commit
055ac99d6f
7 changed files with 52 additions and 50 deletions
|
@ -10,3 +10,9 @@
|
||||||
-define(ERROR(Str, Args), rebar_log:log(error, Str, Args)).
|
-define(ERROR(Str, Args), rebar_log:log(error, Str, Args)).
|
||||||
|
|
||||||
-define(FMT(Str, Args), lists:flatten(io_lib:format(Str, Args))).
|
-define(FMT(Str, Args), lists:flatten(io_lib:format(Str, Args))).
|
||||||
|
|
||||||
|
-define(DEPRECATED(Old, New, Opts, When),
|
||||||
|
rebar_utils:deprecated(Old, New, Opts, When)).
|
||||||
|
|
||||||
|
-define(DEPRECATED(Old, New, When),
|
||||||
|
rebar_utils:deprecated(Old, New, When)).
|
||||||
|
|
|
@ -69,6 +69,10 @@
|
||||||
|
|
||||||
-spec compile(Config::rebar_config:config(), AppFile::file:filename()) -> 'ok'.
|
-spec compile(Config::rebar_config:config(), AppFile::file:filename()) -> 'ok'.
|
||||||
compile(Config, _AppFile) ->
|
compile(Config, _AppFile) ->
|
||||||
|
?DEPRECATED(fail_on_warning, warnings_as_errors,
|
||||||
|
rebar_config:get_list(Config, erl_opts, []),
|
||||||
|
"once OTP R15 is released"),
|
||||||
|
|
||||||
rebar_base_compiler:run(Config,
|
rebar_base_compiler:run(Config,
|
||||||
check_files(rebar_config:get_local(
|
check_files(rebar_config:get_local(
|
||||||
Config, xrl_first_files, [])),
|
Config, xrl_first_files, [])),
|
||||||
|
|
|
@ -37,6 +37,10 @@
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
|
|
||||||
compile(Config, _AppFile) ->
|
compile(Config, _AppFile) ->
|
||||||
|
?DEPRECATED(fail_on_warning, warnings_as_errors,
|
||||||
|
rebar_config:get_list(Config, lfe_opts, []),
|
||||||
|
"once OTP R15 is released"),
|
||||||
|
|
||||||
FirstFiles = rebar_config:get_list(Config, lfe_first_files, []),
|
FirstFiles = rebar_config:get_list(Config, lfe_first_files, []),
|
||||||
rebar_base_compiler:run(Config, FirstFiles, "src", ".lfe", "ebin", ".beam",
|
rebar_base_compiler:run(Config, FirstFiles, "src", ".lfe", "ebin", ".beam",
|
||||||
fun compile_lfe/3).
|
fun compile_lfe/3).
|
||||||
|
|
|
@ -182,15 +182,9 @@ run_precompile_hook(Config, Env) ->
|
||||||
undefined ->
|
undefined ->
|
||||||
ok;
|
ok;
|
||||||
{Script, BypassFileName} ->
|
{Script, BypassFileName} ->
|
||||||
?CONSOLE(
|
?DEPRECATED(port_pre_script,
|
||||||
<<
|
{pre_hooks, [{compile, "script"}]},
|
||||||
"WARNING: option deprecated~n"
|
"in a future build of rebar"),
|
||||||
"Config option 'port_pre_script' has been deprecated "
|
|
||||||
"in favor of ~n{pre_hooks, [{compile, \"script\"}]}."
|
|
||||||
"~nskipfile support has also been removed. Add skipfile"
|
|
||||||
" logic to the~nscript instead.~nFuture builds of rebar"
|
|
||||||
" will remove the option 'port_pre_script'.~n~n"
|
|
||||||
>>, []),
|
|
||||||
case filelib:is_regular(BypassFileName) of
|
case filelib:is_regular(BypassFileName) of
|
||||||
false ->
|
false ->
|
||||||
?CONSOLE("Running ~s\n", [Script]),
|
?CONSOLE("Running ~s\n", [Script]),
|
||||||
|
@ -207,14 +201,9 @@ run_cleanup_hook(Config) ->
|
||||||
undefined ->
|
undefined ->
|
||||||
ok;
|
ok;
|
||||||
Script ->
|
Script ->
|
||||||
?CONSOLE(
|
?DEPRECATED(port_cleanup_script,
|
||||||
<<
|
{post_hooks, [{clean, "script"}]},
|
||||||
"WARNING: option deprecated~n"
|
"in a future build of rebar"),
|
||||||
"Config option 'port_pre_script' has been deprecated "
|
|
||||||
"in favor of ~n{post_hooks, [{clean, \"script\"}]}."
|
|
||||||
"~nFuture builds of rebar will remove the option "
|
|
||||||
"'port_pre_script'.~n~n"
|
|
||||||
>>, []),
|
|
||||||
?CONSOLE("Running ~s\n", [Script]),
|
?CONSOLE("Running ~s\n", [Script]),
|
||||||
{ok, _} = rebar_utils:sh(Script, []),
|
{ok, _} = rebar_utils:sh(Script, []),
|
||||||
ok
|
ok
|
||||||
|
|
|
@ -56,19 +56,10 @@ execute_post_script(Config, Key) ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
deprecated(compile_post_script) ->
|
|
||||||
?CONSOLE(
|
deprecated(Key=compile_post_script) ->
|
||||||
<<
|
?DEPRECATED(Key, {post_hooks, [{compile, "script"}]},
|
||||||
"WARNING: option deprecated~n"
|
"in a future build of rebar");
|
||||||
"Config option 'compile_post_script' has been deprecated in favor"
|
deprecated(Key=clean_post_script) ->
|
||||||
" of ~noption {post_hooks, [{compile, \"script\"}]}.~nFuture builds "
|
?DEPRECATED(Key, {post_hooks, [{clean, "script"}]},
|
||||||
"of rebar will remove the option 'compile_post_script'.~n~n"
|
"in a future build of rebar").
|
||||||
>>, []);
|
|
||||||
deprecated(clean_post_script) ->
|
|
||||||
?CONSOLE(
|
|
||||||
<<
|
|
||||||
"WARNING: option deprecated~n"
|
|
||||||
"Config option 'clean_post_script' has been deprecated in favor"
|
|
||||||
" of ~noption {post_hooks, [{clean, \"script\"}]}.~nFuture builds "
|
|
||||||
"of rebar will remove the option 'clean_post_script'.~n~n"
|
|
||||||
>>, []).
|
|
||||||
|
|
|
@ -56,19 +56,9 @@ execute_pre_script(Config, Key) ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
deprecated(compile_pre_script) ->
|
deprecated(Key=compile_pre_script) ->
|
||||||
?CONSOLE(
|
?DEPRECATED(Key, {pre_hooks, [{compile, "script"}]},
|
||||||
<<
|
"in a future build of rebar");
|
||||||
"WARNING: option deprecated~n"
|
deprecated(Key=clean_pre_script) ->
|
||||||
"Config option 'compile_pre_script' has been deprecated in favor"
|
?DEPRECATED(Key, {pre_hooks, [{clean, "script"}]},
|
||||||
" of ~n{pre_hooks, [{compile, \"script\"}]}.~nFuture builds of"
|
"in a future build of rebar").
|
||||||
" rebar will remove the option 'compile_pre_script'.~n~n"
|
|
||||||
>>, []);
|
|
||||||
deprecated(clean_pre_script) ->
|
|
||||||
?CONSOLE(
|
|
||||||
<<
|
|
||||||
"WARNING: option deprecated~n"
|
|
||||||
"Config option 'clean_pre_script' has been deprecated in favor"
|
|
||||||
" of ~n{pre_hooks, [{clean, \"script\"}]}.~nFuture builds of"
|
|
||||||
" rebar will remove the option 'clean_pre_script'.~n~n"
|
|
||||||
>>, []).
|
|
||||||
|
|
|
@ -39,7 +39,8 @@
|
||||||
escript_foldl/3,
|
escript_foldl/3,
|
||||||
find_executable/1,
|
find_executable/1,
|
||||||
prop_check/3,
|
prop_check/3,
|
||||||
expand_code_path/0]).
|
expand_code_path/0,
|
||||||
|
deprecated/3, deprecated/4]).
|
||||||
|
|
||||||
-include("rebar.hrl").
|
-include("rebar.hrl").
|
||||||
|
|
||||||
|
@ -249,3 +250,20 @@ emulate_escript_foldl(Fun, Acc, File) ->
|
||||||
{error, _} = Error ->
|
{error, _} = Error ->
|
||||||
Error
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
deprecated(Old, New, Opts, When) ->
|
||||||
|
case lists:member(Old, Opts) of
|
||||||
|
true ->
|
||||||
|
deprecated(Old, New, When);
|
||||||
|
false ->
|
||||||
|
ok
|
||||||
|
end.
|
||||||
|
|
||||||
|
deprecated(Old, New, When) ->
|
||||||
|
io:format(
|
||||||
|
<<
|
||||||
|
"WARNING: option deprecated~n"
|
||||||
|
"Config option '~p' has been deprecated~n"
|
||||||
|
"in favor of '~p'.~n"
|
||||||
|
"'~p' will be removed ~s.~n~n"
|
||||||
|
>>, [Old, New, Old, When]).
|
||||||
|
|
Loading…
Reference in a new issue