summaryrefslogtreecommitdiff
path: root/src/rebar_prv_compile.erl
diff options
context:
space:
mode:
authorTristan Sloughter <tristan.sloughter@gmail.com>2015-03-02 19:04:03 -0600
committerTristan Sloughter <tristan.sloughter@gmail.com>2015-03-02 19:04:03 -0600
commitbaf46a861b18086131707d056ee106c9fba8da3d (patch)
treec0bc1de343e52f8385d9f1740e32df5e85dfa234 /src/rebar_prv_compile.erl
parent8affde1c37ba746df41343a52fd8e239ebfe2db3 (diff)
parentaf0f4bb20a66f1464fa25d31f9b69784f3119493 (diff)
Merge pull request #187 from tsloughter/profiles_dir
make base_dir for a run include the profiles in path, link to shared dep
Diffstat (limited to 'src/rebar_prv_compile.erl')
-rw-r--r--src/rebar_prv_compile.erl36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl
index c4cca16..bce4aab 100644
--- a/src/rebar_prv_compile.erl
+++ b/src/rebar_prv_compile.erl
@@ -69,6 +69,10 @@ build_apps(State, Apps) ->
build_app(State, AppInfo) ->
AppDir = rebar_app_info:dir(AppInfo),
+ OutDir = rebar_app_info:out_dir(AppInfo),
+
+ copy_app_dirs(AppDir, OutDir),
+
S = case rebar_app_info:state(AppInfo) of
undefined ->
C = rebar_config:consult(AppDir),
@@ -81,12 +85,13 @@ build_app(State, AppInfo) ->
rebar_hooks:run_compile_hooks(AppDir, pre_hooks, compile, S),
AppInfo1 = compile(S, AppInfo),
rebar_hooks:run_compile_hooks(AppDir, post_hooks, compile, S),
- true = code:add_patha(filename:join(AppDir, "ebin")),
+
+ true = code:add_patha(rebar_app_info:ebin_dir(AppInfo1)),
AppInfo1.
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))),
+ rebar_erlc_compiler:compile(State, ec_cnv:to_list(rebar_app_info:dir(AppInfo)), ec_cnv:to_list(rebar_app_info:out_dir(AppInfo))),
case rebar_otp_app:compile(State, AppInfo) of
{ok, AppInfo1} ->
AppInfo1;
@@ -94,7 +99,6 @@ compile(State, AppInfo) ->
throw(Error)
end.
-
%% ===================================================================
%% Internal functions
%% ===================================================================
@@ -103,3 +107,29 @@ handle_args(State) ->
{Args, _} = rebar_state:command_parsed_args(State),
Jobs = proplists:get_value(jobs, Args, ?DEFAULT_JOBS),
{ok, rebar_state:set(State, jobs, Jobs)}.
+
+copy_app_dirs(OldAppDir, AppDir) ->
+ case ec_cnv:to_binary(filename:absname(OldAppDir)) =/=
+ ec_cnv:to_binary(filename:absname(AppDir)) of
+ true ->
+ EbinDir = filename:join([OldAppDir, "ebin"]),
+ %% copy all files from ebin if it exists
+ case filelib:is_dir(EbinDir) of
+ true ->
+ OutEbin = filename:join(AppDir, "ebin"),
+ filelib:ensure_dir(filename:join(OutEbin, "dummy.beam")),
+ rebar_file_utils:cp_r(filelib:wildcard(filename:join(EbinDir, "*")), OutEbin);
+ false ->
+ 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"]];
+ false ->
+ ok
+ end.
+
+symlink_or_copy(OldAppDir, AppDir, Dir) ->
+ Source = filename:join(OldAppDir, Dir),
+ Target = filename:join(AppDir, Dir),
+ rebar_file_utils:symlink_or_copy(Source, Target).