summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar_erlc_compiler.erl19
-rw-r--r--src/rebar_prv_common_test.erl14
-rw-r--r--src/rebar_prv_edoc.erl2
-rw-r--r--src/rebar_prv_xref.erl20
4 files changed, 45 insertions, 10 deletions
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index f7244dc..9157aba 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -279,7 +279,7 @@ gather_src(Opts, BaseDirParts, [Dir|Rest], Srcs, CompileOpts) ->
end,
DirRecursive = dir_recursive(Opts, RelDir, CompileOpts),
gather_src(Opts, BaseDirParts, Rest, Srcs ++ rebar_utils:find_files(Dir, ?RE_PREFIX".*\\.erl\$", DirRecursive), CompileOpts).
-
+
%% Get files which need to be compiled first, i.e. those specified in erl_first_files
%% and parse_transform options. Also produce specific erl_opts for these first
%% files, so that yet to be compiled parse transformations are excluded from it.
@@ -351,10 +351,25 @@ opts_changed(NewOpts, Target) ->
false -> NewOpts
end,
case compile_info(Target) of
- {ok, Opts} -> lists:sort(Opts) =/= lists:sort(TotalOpts);
+ {ok, Opts} -> lists:any(fun effects_code_generation/1, lists:usort(TotalOpts) -- lists:usort(Opts));
_ -> true
end.
+effects_code_generation(Option) ->
+ case Option of
+ beam -> false;
+ report_warnings -> false;
+ report_errors -> false;
+ return_errors-> false;
+ return_warnings-> false;
+ warnings_as_errors -> false;
+ binary -> false;
+ verbose -> false;
+ {cwd,_} -> false;
+ {outdir, _} -> false;
+ _ -> true
+ end.
+
compile_info(Target) ->
case beam_lib:chunks(Target, [compile_info]) of
{ok, {_mod, Chunks}} ->
diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl
index 3df8b75..dfade77 100644
--- a/src/rebar_prv_common_test.erl
+++ b/src/rebar_prv_common_test.erl
@@ -41,7 +41,14 @@ do(State) ->
Tests = prepare_tests(State),
case compile(State, Tests) of
%% successfully compiled apps
- {ok, S} -> do(S, Tests);
+ {ok, S} ->
+ {RawOpts, _} = rebar_state:command_parsed_args(S),
+ case proplists:get_value(compile_only, RawOpts, false) of
+ true ->
+ {ok, S};
+ false ->
+ do(S, Tests)
+ end;
%% this should look like a compiler error, not a ct error
Error -> Error
end.
@@ -743,9 +750,12 @@ ct_opts(_State) ->
{name, undefined, "name", atom, help(name)},
{sname, undefined, "sname", atom, help(sname)},
{setcookie, undefined, "setcookie", atom, help(setcookie)},
- {sys_config, undefined, "sys_config", string, help(sys_config)} %% comma-separated list
+ {sys_config, undefined, "sys_config", string, help(sys_config)}, %% comma-separated list
+ {compile_only, undefined, "compile_only", boolean, help(compile_only)}
].
+help(compile_only) ->
+ "Compile modules in the project with the test configuration but do not run the tests";
help(dir) ->
"List of additional directories containing test suites";
help(suite) ->
diff --git a/src/rebar_prv_edoc.erl b/src/rebar_prv_edoc.erl
index 97f70a9..d663b0c 100644
--- a/src/rebar_prv_edoc.erl
+++ b/src/rebar_prv_edoc.erl
@@ -89,4 +89,4 @@ add_to_paths([], Path) ->
add_to_paths([{doc_path, Paths}|T], Path) ->
[{doc_path, [Path | Paths]} | T];
add_to_paths([H|T], Path) ->
- [H | add_to_paths(Path, T)].
+ [H | add_to_paths(T, Path)].
diff --git a/src/rebar_prv_xref.erl b/src/rebar_prv_xref.erl
index e6a074f..f358787 100644
--- a/src/rebar_prv_xref.erl
+++ b/src/rebar_prv_xref.erl
@@ -36,6 +36,7 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
+ OldPath = code:get_path(),
code:add_pathsa(rebar_state:code_paths(State, all_deps)),
XrefChecks = prepare(State),
XrefIgnores = rebar_state:get(State, xref_ignores, []),
@@ -47,7 +48,7 @@ do(State) ->
QueryChecks = rebar_state:get(State, xref_queries, []),
QueryResults = lists:foldl(fun check_query/2, [], QueryChecks),
stopped = xref:stop(xref),
- rebar_utils:cleanup_code_path(rebar_state:code_paths(State, default)),
+ rebar_utils:cleanup_code_path(OldPath),
case XrefResults =:= [] andalso QueryResults =:= [] of
true ->
{ok, State};
@@ -280,12 +281,21 @@ find_mfa_source({M, F, A}) ->
end.
find_function_source(M, F, A, Bin) ->
- AbstractCode = beam_lib:chunks(Bin, [abstract_code]),
- {ok, {M, [{abstract_code, {raw_abstract_v1, Code}}]}} = AbstractCode,
+ ChunksLookup = beam_lib:chunks(Bin, [abstract_code]),
+ {ok, {M, [{abstract_code, AbstractCodeLookup}]}} = ChunksLookup,
+ case AbstractCodeLookup of
+ no_abstract_code ->
+ % There isn't much else we can do at this point
+ {module_not_found, function_not_found};
+ {raw_abstract_v1, AbstractCode} ->
+ find_function_source_in_abstract_code(F, A, AbstractCode)
+ end.
+
+find_function_source_in_abstract_code(F, A, AbstractCode) ->
%% Extract the original source filename from the abstract code
- [{attribute, _, file, {Source, _}} | _] = Code,
+ [{attribute, _, file, {Source, _}} | _] = AbstractCode,
%% Extract the line number for a given function def
- Fn = [E || E <- Code,
+ Fn = [E || E <- AbstractCode,
safe_element(1, E) == function,
safe_element(3, E) == F,
safe_element(4, E) == A],