diff options
author | Dave Smith <dizzyd@dizzyd.com> | 2010-04-23 09:27:50 -0600 |
---|---|---|
committer | Dave Smith <dizzyd@dizzyd.com> | 2010-04-23 09:27:50 -0600 |
commit | 0add7acdbfa368d33a821789470228895561fbfc (patch) | |
tree | 3858e1deb5b1ee0626126aae2b81558f7463b155 /src | |
parent | 8f85d708974efae9dd153b70cf76fb2ed7409d9d (diff) |
Make sure to add ebin/ to the code path as well so that xref can properly determine source/line of code.
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_xref.erl | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/rebar_xref.erl b/src/rebar_xref.erl index b5e6d8a..c93995b 100644 --- a/src/rebar_xref.erl +++ b/src/rebar_xref.erl @@ -48,6 +48,10 @@ xref(Config, _) -> {verbose, rebar_config:is_verbose()}]), {ok, _} = xref:add_directory(xref, "ebin"), + %% Save the code path prior to doing anything + OrigPath = code:get_path(), + code:add_path(filename:join(rebar_utils:get_cwd(), "ebin")), + %% Get list of xref checks we want to run XrefChecks = rebar_config:get(Config, xref_checks, [exports_not_used, undefined_function_calls]), @@ -68,6 +72,9 @@ xref(Config, _) -> ok end, + %% Restore the original code path + code:set_path(OrigPath), + ok. foobar() -> @@ -87,7 +94,6 @@ check_exports_not_used(_Config) -> check_undefined_function_calls(_Config) -> {ok, UndefinedCalls0} = xref:analyze(xref, undefined_function_calls), - UndefinedCalls = [{find_mfa_source(Caller), format_fa(Caller), format_mfa(Target)} || {Caller, Target} <- UndefinedCalls0], [?CONSOLE("~s:~w: Warning ~s calls undefined function ~s\n", @@ -98,7 +104,7 @@ check_undefined_function_calls(_Config) -> code_path() -> [P || P <- code:get_path(), - filelib:is_dir(P)]. + filelib:is_dir(P)] ++ [filename:join(rebar_utils:get_cwd(), "ebin")]. %% %% Ignore behaviour functions, and explicitly marked functions @@ -182,3 +188,4 @@ find_mfa_source({M, F, A}) -> Source = abstract_code_source_file(Code), Line = abstract_code_function_line(Code, F, A), {Source, Line}. + |