summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Fish <james@fishcakez.com>2014-11-22 17:44:29 +0000
committerJames Fish <james@fishcakez.com>2014-11-22 21:23:19 +0000
commit0bcec763ba3865eccaf5e6f21598c1d1136d7386 (patch)
tree7a74b09baafbbc3fe85e3382d29e5aa2451369de
parenta24f4019ed6f9b8441b24cef227d5900312a3874 (diff)
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`.
-rw-r--r--rebar.config2
-rw-r--r--src/rebar_prv_dialyzer.erl33
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}]} ->