diff options
-rw-r--r-- | src/rebar_hooks.erl | 18 | ||||
-rw-r--r-- | src/rebar_prv_clean.erl | 14 | ||||
-rw-r--r-- | src/rebar_prv_compile.erl | 16 |
3 files changed, 25 insertions, 23 deletions
diff --git a/src/rebar_hooks.erl b/src/rebar_hooks.erl index c3b17bb..bbb916d 100644 --- a/src/rebar_hooks.erl +++ b/src/rebar_hooks.erl @@ -9,11 +9,12 @@ -spec run_all_hooks(file:filename_all(), pre | post, atom() | {atom(), atom()} | string(), - [providers:t()], rebar_app_info:t(), rebar_state:t()) -> ok. + [providers:t()], rebar_app_info:t(), rebar_state:t()) -> rebar_app_info:t(). run_all_hooks(Dir, Type, Command, Providers, AppInfo, State) -> State1 = rebar_state:current_app(State, AppInfo), - run_provider_hooks(Dir, Type, Command, Providers, rebar_app_info:opts(AppInfo), State1), - run_hooks(Dir, Type, Command, rebar_app_info:opts(AppInfo), State1). + State2 = run_provider_hooks(Dir, Type, Command, Providers, rebar_app_info:opts(AppInfo), State1), + run_hooks(Dir, Type, Command, rebar_app_info:opts(AppInfo), State1), + rebar_state:current_app(State2). run_all_hooks(Dir, Type, Command, Providers, State) -> run_provider_hooks(Dir, Type, Command, Providers, rebar_state:opts(State), State), @@ -22,14 +23,14 @@ run_all_hooks(Dir, Type, Command, Providers, State) -> run_provider_hooks(Dir, Type, Command, Providers, Opts, State) -> case rebar_opts:get(Opts, provider_hooks, []) of [] -> - ok; + State; AllHooks -> TypeHooks = proplists:get_value(Type, AllHooks, []), run_provider_hooks_(Dir, Type, Command, Providers, TypeHooks, rebar_state:opts(State, Opts)) end. -run_provider_hooks_(_Dir, _Type, _Command, _Providers, [], _State) -> - ok; +run_provider_hooks_(_Dir, _Type, _Command, _Providers, [], State) -> + State; run_provider_hooks_(Dir, Type, Command, Providers, TypeHooks, State) -> PluginDepsPaths = rebar_state:code_paths(State, all_plugin_deps), code:add_pathsa(PluginDepsPaths), @@ -40,8 +41,9 @@ run_provider_hooks_(Dir, Type, Command, Providers, TypeHooks, State) -> {error, ProviderName} -> ?DEBUG(format_error({bad_provider, Type, Command, ProviderName}), []), throw(?PRV_ERROR({bad_provider, Type, Command, ProviderName})); - {ok, _} -> - rebar_utils:remove_from_code_path(PluginDepsPaths) + {ok, State2} -> + rebar_utils:remove_from_code_path(PluginDepsPaths), + State2 end. format_error({bad_provider, Type, Command, {Name, Namespace}}) -> diff --git a/src/rebar_prv_clean.erl b/src/rebar_prv_clean.erl index 503291d..8bdea4d 100644 --- a/src/rebar_prv_clean.erl +++ b/src/rebar_prv_clean.erl @@ -62,13 +62,13 @@ format_error(Reason) -> %% =================================================================== clean_apps(State, Providers, Apps) -> - lists:foreach(fun(AppInfo) -> - ?INFO("Cleaning out ~s...", [rebar_app_info:name(AppInfo)]), - AppDir = rebar_app_info:dir(AppInfo), - rebar_hooks:run_all_hooks(AppDir, pre, ?PROVIDER, Providers, AppInfo, State), - rebar_erlc_compiler:clean(State, rebar_app_info:out_dir(AppInfo)), - rebar_hooks:run_all_hooks(AppDir, post, ?PROVIDER, Providers, AppInfo, State) - end, Apps). + [begin + ?INFO("Cleaning out ~s...", [rebar_app_info:name(AppInfo)]), + AppDir = rebar_app_info:dir(AppInfo), + AppInfo1 = rebar_hooks:run_all_hooks(AppDir, pre, ?PROVIDER, Providers, AppInfo, State), + rebar_erlc_compiler:clean(State, rebar_app_info:out_dir(AppInfo1)), + rebar_hooks:run_all_hooks(AppDir, post, ?PROVIDER, Providers, AppInfo1, State) + end || AppInfo <- Apps]. handle_args(State) -> {Args, _} = rebar_state:command_parsed_args(State), diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index 56e5e84..89ea430 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -84,14 +84,14 @@ build_app(State, Providers, AppInfo) -> compile(State, Providers, AppInfo) -> ?INFO("Compiling ~s", [rebar_app_info:name(AppInfo)]), AppDir = rebar_app_info:dir(AppInfo), - rebar_hooks:run_all_hooks(AppDir, pre, ?PROVIDER, Providers, AppInfo, State), - - rebar_erlc_compiler:compile(AppInfo), - case rebar_otp_app:compile(State, AppInfo) of - {ok, AppInfo1} -> - rebar_hooks:run_all_hooks(AppDir, post, ?PROVIDER, Providers, AppInfo, State), - has_all_artifacts(AppInfo1), - AppInfo1; + 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; Error -> throw(Error) end. |