mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 11:06:20 +00:00
Support settable plt dir for dialyzer
Allow rebar to use dialyzer plt files from an alternate directory through the use of the REBAR_PLT_DIR environment variable.
This commit is contained in:
parent
67af251d52
commit
447417098a
1 changed files with 26 additions and 11 deletions
|
@ -34,7 +34,8 @@
|
||||||
%% A single option <code>plt</code> can be presented in the
|
%% A single option <code>plt</code> can be presented in the
|
||||||
%% <code>dialyzer_opts</code> options in <code>rebar.config</code>. If it
|
%% <code>dialyzer_opts</code> options in <code>rebar.config</code>. If it
|
||||||
%% is present, it is used as the PLT for the supported commands. Should it
|
%% is present, it is used as the PLT for the supported commands. Should it
|
||||||
%% not be present, then the default is <code>$HOME/.dialyzer_plt</code>.
|
%% not be present, then the default is <code>$HOME/.dialyzer_plt</code> or
|
||||||
|
%% <code>$REBAR_PLT_DIR/.dialyzer_plt</code> if $REBAR_PLT_DIR is defined.
|
||||||
%%
|
%%
|
||||||
%% @reference <a href="http://user.it.uu.se/~kostis/Papers/bugs05.pdf">
|
%% @reference <a href="http://user.it.uu.se/~kostis/Papers/bugs05.pdf">
|
||||||
%% Experience from developing the Dialyzer: A static analysis tool detecting
|
%% Experience from developing the Dialyzer: A static analysis tool detecting
|
||||||
|
@ -153,7 +154,7 @@ output_warnings(Warnings) ->
|
||||||
end, Warnings).
|
end, Warnings).
|
||||||
|
|
||||||
%% @doc If the plt option is present in rebar.config return its value,
|
%% @doc If the plt option is present in rebar.config return its value,
|
||||||
%% otherwise return $HOME/.dialyzer_plt.
|
%% otherwise return $HOME/.dialyzer_plt or $REBAR_PLT_DIR/.dialyzer_plt.
|
||||||
-spec new_plt_path(Config::rebar_config:config(),
|
-spec new_plt_path(Config::rebar_config:config(),
|
||||||
File::file:filename()) -> file:filename().
|
File::file:filename()) -> file:filename().
|
||||||
new_plt_path(Config, File) ->
|
new_plt_path(Config, File) ->
|
||||||
|
@ -161,33 +162,47 @@ new_plt_path(Config, File) ->
|
||||||
DialyzerOpts = rebar_config:get(Config, dialyzer_opts, []),
|
DialyzerOpts = rebar_config:get(Config, dialyzer_opts, []),
|
||||||
case proplists:get_value(plt, DialyzerOpts) of
|
case proplists:get_value(plt, DialyzerOpts) of
|
||||||
undefined ->
|
undefined ->
|
||||||
|
case os:getenv("REBAR_PLT_DIR") of
|
||||||
|
false ->
|
||||||
filename:join(os:getenv("HOME"),
|
filename:join(os:getenv("HOME"),
|
||||||
"." ++ atom_to_list(AppName) ++ "_dialyzer_plt");
|
"." ++ atom_to_list(AppName)
|
||||||
|
++ "_dialyzer_plt");
|
||||||
|
PltDir ->
|
||||||
|
filename:join(PltDir, "." ++ atom_to_list(AppName)
|
||||||
|
++ "_dialyzer_plt")
|
||||||
|
end;
|
||||||
Plt ->
|
Plt ->
|
||||||
Plt
|
Plt
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @doc If the plt option is present in rebar.config and the file exists
|
%% @doc If the plt option is present in rebar.config and the file exists
|
||||||
%% return its value or if ~/.AppName_dialyzer_plt exists return that.
|
%% return its value or if $HOME/.AppName_dialyzer_plt exists return that.
|
||||||
%% Otherwise return ~/.dialyzer_plt if it exists or abort.
|
%% Otherwise return $HOME/.dialyzer_plt if it exists or abort.
|
||||||
|
%% If $REBAR_PLT_DIR is defined, it is used instead of $HOME.
|
||||||
-spec existing_plt_path(Config::rebar_config:config(),
|
-spec existing_plt_path(Config::rebar_config:config(),
|
||||||
File::file:filename()) -> file:filename().
|
File::file:filename()) -> file:filename().
|
||||||
existing_plt_path(Config, File) ->
|
existing_plt_path(Config, File) ->
|
||||||
AppName = rebar_app_utils:app_name(File),
|
AppName = rebar_app_utils:app_name(File),
|
||||||
DialyzerOpts = rebar_config:get(Config, dialyzer_opts, []),
|
DialyzerOpts = rebar_config:get(Config, dialyzer_opts, []),
|
||||||
Home = os:getenv("HOME"),
|
Home = os:getenv("HOME"),
|
||||||
|
Base = case os:getenv("REBAR_PLT_DIR") of
|
||||||
|
false ->
|
||||||
|
Home;
|
||||||
|
PltDir ->
|
||||||
|
PltDir
|
||||||
|
end,
|
||||||
case proplists:get_value(plt, DialyzerOpts) of
|
case proplists:get_value(plt, DialyzerOpts) of
|
||||||
undefined ->
|
undefined ->
|
||||||
AppPlt = filename:join(Home, "." ++ atom_to_list(AppName)
|
AppPlt = filename:join(Base, "." ++ atom_to_list(AppName)
|
||||||
++ "_dialyzer_plt"),
|
++ "_dialyzer_plt"),
|
||||||
case filelib:is_regular(AppPlt) of
|
case filelib:is_regular(AppPlt) of
|
||||||
true ->
|
true ->
|
||||||
AppPlt;
|
AppPlt;
|
||||||
false ->
|
false ->
|
||||||
HomePlt = filename:join(Home, ".dialyzer_plt"),
|
BasePlt = filename:join(Base, ".dialyzer_plt"),
|
||||||
case filelib:is_regular(HomePlt) of
|
case filelib:is_regular(BasePlt) of
|
||||||
true ->
|
true ->
|
||||||
HomePlt;
|
BasePlt;
|
||||||
false ->
|
false ->
|
||||||
?ABORT("No PLT found~n", [])
|
?ABORT("No PLT found~n", [])
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue