summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralisdair sullivan <alisdairsullivan@yahoo.ca>2015-03-08 09:55:30 -0700
committeralisdair sullivan <alisdairsullivan@yahoo.ca>2015-03-08 11:44:04 -0700
commitab84fc89ccf7fbbff8457afefdc301e37de6a6c9 (patch)
tree2b81916a49b1c7625277b4e4f940a481c9601d75 /src
parent5f61bd5b0610a2fd0d8f558fb84864133e625304 (diff)
compile source from the symlinked directories under `_build` to
get correct compile paths included in module info
Diffstat (limited to 'src')
-rw-r--r--src/rebar_erlc_compiler.erl10
-rw-r--r--src/rebar_prv_common_test.erl3
-rw-r--r--src/rebar_prv_compile.erl12
-rw-r--r--src/rebar_prv_eunit.erl3
4 files changed, 16 insertions, 12 deletions
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index a113fc4..0ea09dc 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -26,7 +26,8 @@
%% -------------------------------------------------------------------
-module(rebar_erlc_compiler).
--export([compile/3,
+-export([compile/2,
+ compile/3,
clean/2]).
-include("rebar.hrl").
@@ -79,6 +80,10 @@
%% 'old_inets'}]}.
%%
+-spec compile(rebar_state:t(), file:name()) -> 'ok'.
+compile(Config, Dir) ->
+ compile(Config, Dir, filename:join([Dir, "ebin"])).
+
-spec compile(rebar_state:t(), file:name(), file:name()) -> 'ok'.
compile(Config, Dir, OutDir) ->
rebar_base_compiler:run(Config,
@@ -133,8 +138,7 @@ doterl_compile(State, Dir, ODir) ->
ErlOpts = rebar_utils:erl_opts(State),
doterl_compile(State, Dir, ODir, [], ErlOpts).
-doterl_compile(Config, Dir, ODir, MoreSources, ErlOpts) ->
- OutDir = filename:join(ODir, "ebin"),
+doterl_compile(Config, Dir, OutDir, MoreSources, ErlOpts) ->
ErlFirstFilesConf = rebar_state:get(Config, erl_first_files, []),
?DEBUG("erl_opts ~p", [ErlOpts]),
%% Support the src_dirs option allowing multiple directories to
diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl
index bd799fa..2fa2e28 100644
--- a/src/rebar_prv_common_test.erl
+++ b/src/rebar_prv_common_test.erl
@@ -370,7 +370,6 @@ compile_tests(State, TestApps, InDirs) ->
AppState
end,
ok = rebar_erlc_compiler:compile(replace_src_dirs(S, InDirs),
- ec_cnv:to_list(rebar_app_info:dir(AppInfo)),
ec_cnv:to_list(rebar_app_info:out_dir(AppInfo)))
end,
lists:foreach(F, TestApps),
@@ -382,7 +381,7 @@ compile_bare_tests(State, TestApps, InDirs) ->
%% compile just the `test` directory of the base dir
[] -> rebar_erlc_compiler:compile(replace_src_dirs(State, InDirs),
rebar_dir:get_cwd(),
- rebar_dir:base_dir(State));
+ filename:join([rebar_dir:base_dir(State), "ebin"]));
%% already compiled `./test` so do nothing
_ -> ok
end.
diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl
index 7c6802d..937b9bf 100644
--- a/src/rebar_prv_compile.erl
+++ b/src/rebar_prv_compile.erl
@@ -71,7 +71,7 @@ build_app(State, AppInfo) ->
AppDir = rebar_app_info:dir(AppInfo),
OutDir = rebar_app_info:out_dir(AppInfo),
- copy_app_dirs(AppDir, OutDir),
+ copy_app_dirs(State, AppDir, OutDir),
S = case rebar_app_info:state(AppInfo) of
undefined ->
@@ -91,7 +91,7 @@ build_app(State, AppInfo) ->
compile(State, AppInfo) ->
?INFO("Compiling ~s", [rebar_app_info:name(AppInfo)]),
- rebar_erlc_compiler:compile(State, ec_cnv:to_list(rebar_app_info:dir(AppInfo)), ec_cnv:to_list(rebar_app_info:out_dir(AppInfo))),
+ rebar_erlc_compiler:compile(State, ec_cnv:to_list(rebar_app_info:out_dir(AppInfo))),
case rebar_otp_app:compile(State, AppInfo) of
{ok, AppInfo1} ->
AppInfo1;
@@ -108,7 +108,7 @@ handle_args(State) ->
Jobs = proplists:get_value(jobs, Args, ?DEFAULT_JOBS),
{ok, rebar_state:set(State, jobs, Jobs)}.
-copy_app_dirs(OldAppDir, AppDir) ->
+copy_app_dirs(State, OldAppDir, AppDir) ->
case ec_cnv:to_binary(filename:absname(OldAppDir)) =/=
ec_cnv:to_binary(filename:absname(AppDir)) of
true ->
@@ -123,8 +123,10 @@ copy_app_dirs(OldAppDir, AppDir) ->
ok
end,
filelib:ensure_dir(filename:join(AppDir, "dummy")),
- %% link to src to be adjacent to ebin is needed for R15 use of cover/xref
- [symlink_or_copy(OldAppDir, AppDir, Dir) || Dir <- ["priv", "include", "src", "test"]];
+ %% link to src_dirs to be adjacent to ebin is needed for R15 use of cover/xref
+ ErlOpts = rebar_utils:erl_opts(State),
+ SrcDirs = proplists:get_value(src_dirs, ErlOpts, ["src"]),
+ [symlink_or_copy(OldAppDir, AppDir, Dir) || Dir <- ["priv", "include", "test"] ++ SrcDirs];
false ->
ok
end.
diff --git a/src/rebar_prv_eunit.erl b/src/rebar_prv_eunit.erl
index 7ea5ced..1540471 100644
--- a/src/rebar_prv_eunit.erl
+++ b/src/rebar_prv_eunit.erl
@@ -137,7 +137,6 @@ compile_tests(State, TestApps) ->
AppState
end,
ok = rebar_erlc_compiler:compile(replace_src_dirs(S),
- ec_cnv:to_list(rebar_app_info:dir(AppInfo)),
ec_cnv:to_list(rebar_app_info:out_dir(AppInfo)))
end,
lists:foreach(F, TestApps),
@@ -149,7 +148,7 @@ compile_bare_tests(State, TestApps) ->
%% compile just the `test` directory of the base dir
[] -> rebar_erlc_compiler:compile(replace_src_dirs(State),
rebar_dir:get_cwd(),
- rebar_dir:base_dir(State));
+ filename:join([rebar_dir:base_dir(State), "ebin"]));
%% already compiled `./test` so do nothing
_ -> ok
end.