From d48f02dbc4f45b7e4d13e4ae847c44aad67dd873 Mon Sep 17 00:00:00 2001 From: James Fish Date: Sat, 31 Oct 2015 16:43:04 +0000 Subject: Rebuild PLT when beams no longer exist --- src/rebar_prv_dialyzer.erl | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/rebar_prv_dialyzer.erl') diff --git a/src/rebar_prv_dialyzer.erl b/src/rebar_prv_dialyzer.erl index 487e9d1..2e5728a 100644 --- a/src/rebar_prv_dialyzer.erl +++ b/src/rebar_prv_dialyzer.erl @@ -173,7 +173,7 @@ do_update_proj_plt(State, Plt, Output) -> case read_plt(State, Plt) of {ok, OldFiles} -> check_plt(State, Plt, Output, OldFiles, Files); - {error, no_such_file} -> + error -> build_proj_plt(State, Plt, Output, Files) end. @@ -252,14 +252,25 @@ read_plt(_State, Plt) -> case dialyzer:plt_info(Plt) of {ok, Info} -> Files = proplists:get_value(files, Info, []), - {ok, Files}; - {error, no_such_file} = Error -> - Error; + read_plt_files(Plt, Files); + {error, no_such_file} -> + error; {error, read_error} -> Error = io_lib:format("Could not read the PLT file ~p", [Plt]), throw({dialyzer_error, Error}) end. +%% If any file no longer exists dialyzer will fail when updating the PLT. +read_plt_files(Plt, Files) -> + case [File || File <- Files, not filelib:is_file(File)] of + [] -> + {ok, Files}; + Missing -> + ?INFO("Could not find ~p files in ~p...", [length(Missing), Plt]), + ?DEBUG("Could not find files: ~p", [Missing]), + error + end. + check_plt(State, Plt, Output, OldList, FilesList) -> Old = sets:from_list(OldList), Files = sets:from_list(FilesList), @@ -337,7 +348,7 @@ update_base_plt(State, BasePlt, Output, BaseFiles) -> case read_plt(State, BasePlt) of {ok, OldBaseFiles} -> check_plt(State, BasePlt, Output, OldBaseFiles, BaseFiles); - {error, no_such_file} -> + error -> _ = filelib:ensure_dir(BasePlt), build_plt(State, BasePlt, Output, BaseFiles) end. -- cgit v1.1 From b1c6c2fccfb24bb9294fdd09ba51adadca59fec1 Mon Sep 17 00:00:00 2001 From: James Fish Date: Tue, 2 Feb 2016 12:41:19 +0000 Subject: Ignore unknown warning when dialyzer < 2.8 --- src/rebar_prv_dialyzer.erl | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/rebar_prv_dialyzer.erl') diff --git a/src/rebar_prv_dialyzer.erl b/src/rebar_prv_dialyzer.erl index 2e5728a..834eb98 100644 --- a/src/rebar_prv_dialyzer.erl +++ b/src/rebar_prv_dialyzer.erl @@ -397,7 +397,7 @@ run_dialyzer(State, Opts, Output) -> case proplists:get_bool(get_warnings, Opts) of true -> WarningsList = get_config(State, warnings, []), - Opts2 = [{warnings, WarningsList}, + Opts2 = [{warnings, legacy_warnings(WarningsList)}, {check_plt, false} | Opts], ?DEBUG("Running dialyzer with options: ~p~n", [Opts2]), @@ -412,6 +412,14 @@ run_dialyzer(State, Opts, Output) -> {0, State} end. +legacy_warnings(Warnings) -> + case dialyzer_version() of + TupleVsn when TupleVsn < {2, 8, 0} -> + [Warning || Warning <- Warnings, Warning =/= unknown]; + _ -> + Warnings + end. + format_warnings(Output, Warnings) -> Warnings1 = rebar_dialyzer_format:format_warnings(Warnings), console_warnings(Warnings1), @@ -475,3 +483,16 @@ collect_nested_dependent_apps(App, Seen) -> end end end. + +dialyzer_version() -> + _ = application:load(dialyzer), + {ok, Vsn} = application:get_key(dialyzer, vsn), + case string:tokens(Vsn, ".") of + [Major, Minor] -> + version_tuple(Major, Minor, "0"); + [Major, Minor, Patch | _] -> + version_tuple(Major, Minor, Patch) + end. + +version_tuple(Major, Minor, Patch) -> + {list_to_integer(Major), list_to_integer(Minor), list_to_integer(Patch)}. -- cgit v1.1