diff options
author | Tristan Sloughter <tristan.sloughter@gmail.com> | 2014-11-22 16:26:39 -0600 |
---|---|---|
committer | Tristan Sloughter <tristan.sloughter@gmail.com> | 2014-11-22 16:26:39 -0600 |
commit | c50bbc88e5933d42008b73de1717acf27e57b704 (patch) | |
tree | ab23d36ca311c31401300df28a3903187843ea63 /src/rebar_prv_dialyzer.erl | |
parent | a24f4019ed6f9b8441b24cef227d5900312a3874 (diff) | |
parent | e90219cb14f89704772321b548c1553a49da5163 (diff) |
Merge pull request #17 from fishcakez/dialyzer2
Fix rebar dialyzer to work on applications in rebar archive
Diffstat (limited to 'src/rebar_prv_dialyzer.erl')
-rw-r--r-- | src/rebar_prv_dialyzer.erl | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/rebar_prv_dialyzer.erl b/src/rebar_prv_dialyzer.erl index 61b25e1..6bff26b 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}]} -> @@ -331,7 +354,7 @@ app_to_files(App) -> run_dialyzer(State, Opts) -> Warnings = rebar_state:get(State, dialyzer_warnings, default_warnings()), Opts2 = [{warnings, Warnings} | Opts], - _ = [?CONSOLE(format_warning(Warning), []) + _ = [?CONSOLE("~s", [format_warning(Warning)]) || Warning <- dialyzer:run(Opts2)], {ok, State}. |