diff options
Diffstat (limited to 'src/rebar_prv_compile.erl')
-rw-r--r-- | src/rebar_prv_compile.erl | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index c4cca16..2d11596 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(rebar_app_info:name(AppInfo), 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,23 @@ 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(AppName, OldAppDir, AppDir) -> + case ec_cnv:to_binary(filename:absname(OldAppDir)) =/= + ec_cnv:to_binary(filename:absname(AppDir)) of + true -> + Name = ec_cnv:to_list(AppName), + AppFile = filename:join([OldAppDir, "ebin", Name++".app"]), + case filelib:is_file(AppFile) of + true -> + file:copy(AppFile, + filename:join([AppDir, "ebin", Name++".app"])); + false -> + ok + end, + filelib:ensure_dir(filename:join(AppDir, "dummy")), + [file:make_symlink(filename:join(OldAppDir, Dir), filename:join(AppDir, Dir)) + || Dir <- ["priv", "include"]]; + false -> + ok + end. |