diff options
| author | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-04-07 20:49:23 +0200 | 
|---|---|---|
| committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-04-07 21:56:53 +0200 | 
| commit | 055ac99d6f473620d8cfad816ac39b86eeb21bbc (patch) | |
| tree | fc1a308d332ce883eae132bb53753b0e3ca26ad3 | |
| parent | 121d8f03f98b5d4e620aacfdfece2af4255efafe (diff) | |
Deprecate fail_on_warning and refactor code
| -rw-r--r-- | include/rebar.hrl | 6 | ||||
| -rw-r--r-- | src/rebar_erlc_compiler.erl | 4 | ||||
| -rw-r--r-- | src/rebar_lfe_compiler.erl | 4 | ||||
| -rw-r--r-- | src/rebar_port_compiler.erl | 23 | ||||
| -rw-r--r-- | src/rebar_post_script.erl | 23 | ||||
| -rw-r--r-- | src/rebar_pre_script.erl | 22 | ||||
| -rw-r--r-- | src/rebar_utils.erl | 20 | 
7 files changed, 52 insertions, 50 deletions
| diff --git a/include/rebar.hrl b/include/rebar.hrl index 0f4e90f..82821e6 100644 --- a/include/rebar.hrl +++ b/include/rebar.hrl @@ -10,3 +10,9 @@  -define(ERROR(Str, Args), rebar_log:log(error, 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)). diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index 21db366..b63c295 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -69,6 +69,10 @@  -spec compile(Config::rebar_config:config(), AppFile::file:filename()) -> 'ok'.  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,                              check_files(rebar_config:get_local(                                            Config, xrl_first_files, [])), diff --git a/src/rebar_lfe_compiler.erl b/src/rebar_lfe_compiler.erl index 06b0f08..8356ab8 100644 --- a/src/rebar_lfe_compiler.erl +++ b/src/rebar_lfe_compiler.erl @@ -37,6 +37,10 @@  %% ===================================================================  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, []),      rebar_base_compiler:run(Config, FirstFiles, "src", ".lfe", "ebin", ".beam",                              fun compile_lfe/3). diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl index a281b29..9f859e8 100644 --- a/src/rebar_port_compiler.erl +++ b/src/rebar_port_compiler.erl @@ -182,15 +182,9 @@ run_precompile_hook(Config, Env) ->          undefined ->              ok;          {Script, BypassFileName} -> -            ?CONSOLE( -               << -                 "WARNING: option deprecated~n" -                 "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" -               >>, []), +            ?DEPRECATED(port_pre_script, +                        {pre_hooks, [{compile, "script"}]}, +                        "in a future build of rebar"),              case filelib:is_regular(BypassFileName) of                  false ->                      ?CONSOLE("Running ~s\n", [Script]), @@ -207,14 +201,9 @@ run_cleanup_hook(Config) ->          undefined ->              ok;          Script -> -            ?CONSOLE( -               << -                 "WARNING: option deprecated~n" -                 "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" -               >>, []), +            ?DEPRECATED(port_cleanup_script, +                        {post_hooks, [{clean, "script"}]}, +                        "in a future build of rebar"),              ?CONSOLE("Running ~s\n", [Script]),              {ok, _} = rebar_utils:sh(Script, []),              ok diff --git a/src/rebar_post_script.erl b/src/rebar_post_script.erl index 39185a9..c254fb8 100644 --- a/src/rebar_post_script.erl +++ b/src/rebar_post_script.erl @@ -56,19 +56,10 @@ execute_post_script(Config, Key) ->              ok      end. -deprecated(compile_post_script) -> -    ?CONSOLE( -       << -         "WARNING: option deprecated~n" -         "Config option 'compile_post_script' has been deprecated in favor" -         " of ~noption {post_hooks, [{compile, \"script\"}]}.~nFuture builds " -         "of rebar will remove the option 'compile_post_script'.~n~n" -       >>, []); -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" -       >>, []). + +deprecated(Key=compile_post_script) -> +    ?DEPRECATED(Key, {post_hooks, [{compile, "script"}]}, +                "in a future build of rebar"); +deprecated(Key=clean_post_script) -> +    ?DEPRECATED(Key, {post_hooks, [{clean, "script"}]}, +                "in a future build of rebar"). diff --git a/src/rebar_pre_script.erl b/src/rebar_pre_script.erl index b23f469..d79d662 100644 --- a/src/rebar_pre_script.erl +++ b/src/rebar_pre_script.erl @@ -56,19 +56,9 @@ execute_pre_script(Config, Key) ->              ok      end. -deprecated(compile_pre_script) -> -    ?CONSOLE( -       << -         "WARNING: option deprecated~n" -         "Config option 'compile_pre_script' has been deprecated in favor" -         " of ~n{pre_hooks, [{compile, \"script\"}]}.~nFuture builds of" -         " 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" -       >>, []). +deprecated(Key=compile_pre_script) -> +    ?DEPRECATED(Key, {pre_hooks, [{compile, "script"}]}, +                "in a future build of rebar"); +deprecated(Key=clean_pre_script) -> +    ?DEPRECATED(Key, {pre_hooks, [{clean, "script"}]}, +                "in a future build of rebar"). diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 8898b8a..c65a99d 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -39,7 +39,8 @@           escript_foldl/3,           find_executable/1,           prop_check/3, -         expand_code_path/0]). +         expand_code_path/0, +         deprecated/3, deprecated/4]).  -include("rebar.hrl"). @@ -249,3 +250,20 @@ emulate_escript_foldl(Fun, Acc, File) ->          {error, _} = Error ->              Error      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]). | 
