diff options
Diffstat (limited to 'src/rebar_prv_compile.erl')
-rw-r--r-- | src/rebar_prv_compile.erl | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index 2996aee..effc763 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -13,6 +13,8 @@ -include("rebar.hrl"). -define(PROVIDER, compile). +-define(ERLC_HOOK, erlc_compile). +-define(APP_HOOK, app_compile). -define(DEPS, [lock]). %% =================================================================== @@ -116,12 +118,17 @@ compile(State, Providers, AppInfo) -> AppDir = rebar_app_info:dir(AppInfo), AppInfo1 = rebar_hooks:run_all_hooks(AppDir, pre, ?PROVIDER, Providers, AppInfo, State), - rebar_erlc_compiler:compile(AppInfo1), - case rebar_otp_app:compile(State, AppInfo1) of - {ok, AppInfo2} -> - AppInfo3 = rebar_hooks:run_all_hooks(AppDir, post, ?PROVIDER, Providers, AppInfo2, State), - has_all_artifacts(AppInfo3), - AppInfo3; + AppInfo2 = rebar_hooks:run_all_hooks(AppDir, pre, ?ERLC_HOOK, Providers, AppInfo1, State), + rebar_erlc_compiler:compile(AppInfo2), + AppInfo3 = rebar_hooks:run_all_hooks(AppDir, post, ?ERLC_HOOK, Providers, AppInfo2, State), + + AppInfo4 = rebar_hooks:run_all_hooks(AppDir, pre, ?APP_HOOK, Providers, AppInfo3, State), + case rebar_otp_app:compile(State, AppInfo4) of + {ok, AppInfo5} -> + AppInfo6 = rebar_hooks:run_all_hooks(AppDir, post, ?APP_HOOK, Providers, AppInfo5, State), + AppInfo7 = rebar_hooks:run_all_hooks(AppDir, post, ?PROVIDER, Providers, AppInfo6, State), + has_all_artifacts(AppInfo5), + AppInfo7; Error -> throw(Error) end. @@ -143,7 +150,7 @@ paths_for_apps([App|Rest], Acc) -> Paths = [filename:join([rebar_app_info:out_dir(App), Dir]) || Dir <- ["ebin"|ExtraDirs]], FilteredPaths = lists:filter(fun ec_file:is_dir/1, Paths), paths_for_apps(Rest, Acc ++ FilteredPaths). - + paths_for_extras(State, Apps) -> F = fun(App) -> rebar_app_info:dir(App) == rebar_state:dir(State) end, %% check that this app hasn't already been dealt with @@ -217,6 +224,10 @@ copy(OldAppDir, AppDir, Dir) -> %% TODO: use ec_file:copy/2 to do this, it preserves timestamps and %% may prevent recompilation of files in extra dirs +copy(Source, Source) -> + %% allow users to specify a directory in _build as a directory + %% containing additional source/tests + ok; copy(Source, Target) -> %% important to do this so no files are copied onto themselves %% which truncates them to zero length on some platforms @@ -243,6 +254,21 @@ resolve_src_dirs(Opts) -> %% in src_dirs also exist in extra_src_dirs normalize_src_dirs(SrcDirs, ExtraDirs) -> S = lists:usort(SrcDirs), - E = lists:usort(ExtraDirs), - {S, lists:subtract(E, S)}. + E = lists:subtract(lists:usort(ExtraDirs), S), + ok = warn_on_problematic_directories(S ++ E), + {S, E}. + +%% warn when directories called `eunit' and `ct' are added to compile dirs +warn_on_problematic_directories(AllDirs) -> + F = fun(Dir) -> + case is_a_problem(Dir) of + true -> ?WARN("Possible name clash with directory ~p.", [Dir]); + false -> ok + end + end, + lists:foreach(F, AllDirs). + +is_a_problem("eunit") -> true; +is_a_problem("common_test") -> true; +is_a_problem(_) -> false. |