Skip to content

Commit

Permalink
Cleanup deprecations now that R14B03 is released
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuncer Ayaz committed May 31, 2011
1 parent 7013729 commit 3a8b4d5
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 200 deletions.
6 changes: 1 addition & 5 deletions ebin/rebar.app
Expand Up @@ -29,8 +29,6 @@
rebar_protobuffs_compiler,
rebar_neotoma_compiler,
rebar_port_compiler,
rebar_post_script,
rebar_pre_script,
rebar_rel_utils,
rebar_reltool,
rebar_require_vsn,
Expand Down Expand Up @@ -64,7 +62,6 @@
%% Dir specific processing modules
{modules, [
{app_dir, [
rebar_pre_script,
rebar_abnfc_compiler,
rebar_protobuffs_compiler,
rebar_neotoma_compiler,
Expand All @@ -79,8 +76,7 @@
rebar_dialyzer,
rebar_escripter,
rebar_edoc,
rebar_xref,
rebar_post_script
rebar_xref
]},

{rel_dir, [
Expand Down
26 changes: 10 additions & 16 deletions src/rebar_erlc_compiler.erl
Expand Up @@ -70,9 +70,13 @@

-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 R14B03 is released"),
%% TODO: enable as soon as OTP patch has been accepted
%% ?DEPRECATED(fail_on_warning, warnings_as_errors,
%% rebar_config:get_list(Config, xrl_opts, []),
%% "once R15 is released"),
%% ?DEPRECATED(fail_on_warning, warnings_as_errors,
%% rebar_config:get_list(Config, yrl_opts, []),
%% "once R15 is released"),

rebar_base_compiler:run(Config,
check_files(rebar_config:get_local(
Expand Down Expand Up @@ -252,17 +256,6 @@ internal_erl_compile(Source, Config, Outdir, ErlOpts) ->
case compile:file(Source, Opts) of
{ok, _, []} ->
ok;
{ok, _, _Warnings} ->

This comment has been minimized.

Copy link
@benoitc

benoitc Jun 1, 2011

with this change, compiling a code with warnings will always fail.

Applying this diff fix the issue:

diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index 6567f06..01b3629 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -256,6 +256,17 @@ internal_erl_compile(Source, Config, Outdir, ErlOpts) ->
             case compile:file(Source, Opts) of
                 {ok, _, []} ->
                     ok;
+                {ok, _, _Warnings} ->
+                    %% We got at least one warning -- if fail_on_warning
+                    %% is in options, fail
+                    case lists:member(fail_on_warning, Opts) of
+                        true ->
+                            %% remove target to prevent overlooking this failure
+                            ok = file:delete(Target),
+                            ?FAIL;
+                        false ->
+                            ok
+                    end;
                 _ ->
                     ?FAIL
             end;
%% We got at least one warning -- if fail_on_warning
%% is in options, fail
case lists:member(fail_on_warning, Opts) of
true ->
%% remove target to prevent overlooking this failure
ok = file:delete(Target),
?FAIL;
false ->
ok
end;
_ ->
?FAIL
end;
Expand All @@ -287,14 +280,14 @@ compile_mib(Source, Target, Config) ->
Config::rebar_config:config()) -> 'ok'.
compile_xrl(Source, Target, Config) ->
Opts = [{scannerfile, Target}, {return, true}
|rebar_config:get(Config, xrl_opts, [])],
| rebar_config:get(Config, xrl_opts, [])],
compile_xrl_yrl(Source, Target, Opts, leex).

-spec compile_yrl(Source::file:filename(), Target::file:filename(),
Config::rebar_config:config()) -> 'ok'.
compile_yrl(Source, Target, Config) ->
Opts = [{parserfile, Target}, {return, true}
|rebar_config:get(Config, yrl_opts, [])],
| rebar_config:get(Config, yrl_opts, [])],
compile_xrl_yrl(Source, Target, Opts, yecc).

-spec compile_xrl_yrl(Source::file:filename(), Target::file:filename(),
Expand All @@ -306,6 +299,7 @@ compile_xrl_yrl(Source, Target, Opts, Mod) ->
{ok, _, []} ->
ok;
{ok, _, _Warnings} ->
%% TODO: remove once R15 is released
case lists:member(fail_on_warning, Opts) of
true ->
?FAIL;
Expand Down
10 changes: 1 addition & 9 deletions src/rebar_lfe_compiler.erl
Expand Up @@ -45,7 +45,7 @@ compile(Config, _AppFile) ->
%% Internal functions
%% ===================================================================

compile_lfe(Source, Target, Config) ->
compile_lfe(Source, _Target, Config) ->
case code:which(lfe_comp) of
non_existing ->
?CONSOLE(<<
Expand All @@ -66,14 +66,6 @@ compile_lfe(Source, Target, Config) ->
case lfe_comp:file(Source, Opts) of
{ok, _, []} ->
ok;
{ok, _, _Warnings} ->

This comment has been minimized.

Copy link
@benoitc

benoitc Jun 1, 2011

it may have same results as above;

case lists:member(fail_on_warning, Opts) of
true ->
ok = file:delete(Target),
?FAIL;
false ->
ok
end;
_ ->
?FAIL
end
Expand Down
42 changes: 1 addition & 41 deletions src/rebar_port_compiler.erl
Expand Up @@ -97,10 +97,6 @@ compile(Config, AppFile) ->
_ ->
Env = setup_env(Config),

%% One or more files are available for building.
%% Run the pre-compile hook, if necessary.
ok = run_precompile_hook(Config, Env),

%% Compile each of the sources
{NewBins, ExistingBins} = compile_each(Sources, Config, Env,
[], []),
Expand Down Expand Up @@ -142,10 +138,7 @@ clean(Config, AppFile) ->
ExtractSoName = fun({SoName, _}) -> SoName end,
rebar_file_utils:delete_each([ExtractSoName(S)
|| S <- so_specs(Config, AppFile,
expand_objects(Sources))]),

%% Run the cleanup script, if it exists
run_cleanup_hook(Config).
expand_objects(Sources))]).

setup_env(Config) ->
%% Extract environment values from the config (if specified) and
Expand Down Expand Up @@ -179,39 +172,6 @@ expand_objects(Sources) ->
[filename:join([filename:dirname(F), filename:basename(F) ++ ".o"])
|| F <- Sources].

run_precompile_hook(Config, Env) ->
case rebar_config:get(Config, port_pre_script, undefined) of
undefined ->
ok;
{Script, BypassFileName} ->
?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]),
{ok, _} = rebar_utils:sh(Script, [{env, Env}]),
ok;
true ->
?INFO("~s exists; not running ~s\n",
[BypassFileName, Script])
end
end.

run_cleanup_hook(Config) ->
case rebar_config:get(Config, port_cleanup_script, undefined) of
undefined ->
ok;
Script ->
?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
end.


compile_each([], _Config, _Env, NewBins, ExistingBins) ->
{lists:reverse(NewBins), lists:reverse(ExistingBins)};
compile_each([Source | Rest], Config, Env, NewBins, ExistingBins) ->
Expand Down
65 changes: 0 additions & 65 deletions src/rebar_post_script.erl

This file was deleted.

64 changes: 0 additions & 64 deletions src/rebar_pre_script.erl

This file was deleted.

0 comments on commit 3a8b4d5

Please sign in to comment.