From 0bcec763ba3865eccaf5e6f21598c1d1136d7386 Mon Sep 17 00:00:00 2001 From: James Fish Date: Sat, 22 Nov 2014 17:44:29 +0000 Subject: Fix dialyzer to work on rebar code:lib_dir/1,2 can return archive directory for rebar escript archive applications, rather than the application's directory in the project. Add dependencies not listed in `applications` to `dialyzer_plt_apps`. --- rebar.config | 2 ++ src/rebar_prv_dialyzer.erl | 33 ++++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/rebar.config b/rebar.config index 177037f..abbb3fb 100644 --- a/rebar.config +++ b/rebar.config @@ -40,3 +40,5 @@ {erlydtl_opts, [{doc_root, "priv/templates"}, {compiler_options, [report, return, debug_info]}]}. + +{dialyzer_plt_apps, [common_test, dialyzer, erlydtl, eunit, snmp]}. diff --git a/src/rebar_prv_dialyzer.erl b/src/rebar_prv_dialyzer.erl index 61b25e1..0ede475 100644 --- a/src/rebar_prv_dialyzer.erl +++ b/src/rebar_prv_dialyzer.erl @@ -160,16 +160,39 @@ app_member(AppName, Apps) -> end. app_name_to_info(AppName) -> - case code:lib_dir(AppName) of + case app_name_to_ebin(AppName) of {error, _} -> ?CONSOLE("Unknown application ~s", [AppName]), {[], []}; - AppDir -> - app_dir_to_info(AppDir, AppName) + EbinDir -> + ebin_to_info(EbinDir, AppName) end. -app_dir_to_info(AppDir, AppName) -> - EbinDir = filename:join(AppDir, "ebin"), +app_name_to_ebin(AppName) -> + case code:lib_dir(AppName, ebin) of + {error, bad_name} -> + search_ebin(AppName); + EbinDir -> + check_ebin(EbinDir, AppName) + end. + +check_ebin(EbinDir, AppName) -> + case filelib:is_dir(EbinDir) of + true -> + EbinDir; + false -> + search_ebin(AppName) + end. + +search_ebin(AppName) -> + case code:where_is_file(atom_to_list(AppName) ++ ".app") of + non_existing -> + {error, bad_name}; + AppFile -> + filename:dirname(AppFile) + end. + +ebin_to_info(EbinDir, AppName) -> AppFile = filename:join(EbinDir, atom_to_list(AppName) ++ ".app"), case file:consult(AppFile) of {ok, [{application, AppName, AppDetails}]} -> -- cgit v1.1