diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_core.erl | 12 | ||||
-rw-r--r-- | src/rebar_deps.erl | 26 | ||||
-rw-r--r-- | src/rebar_eunit.erl | 9 | ||||
-rw-r--r-- | src/rebar_port_compiler.erl | 17 | ||||
-rw-r--r-- | src/rebar_post_script.erl | 18 | ||||
-rw-r--r-- | src/rebar_pre_script.erl | 18 |
6 files changed, 82 insertions, 18 deletions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl index d92af34..42f301f 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -223,7 +223,7 @@ execute(Command, Modules, Config, ModuleFile) -> case select_modules(Modules, Command, []) of [] -> ?WARN("'~p' command does not apply to directory ~s\n", - [Command, rebar_utils:get_cwd()]); + [Command, rebar_utils:get_cwd()]); TargetModules -> %% Provide some info on where we are @@ -235,9 +235,11 @@ execute(Command, Modules, Config, ModuleFile) -> erlang:put(operations, erlang:get(operations) + 1), %% Run the available modules + apply_hooks(pre_hooks, Config, Command), case catch(run_modules(TargetModules, Command, Config, ModuleFile)) of ok -> + apply_hooks(post_hooks, Config, Command), ok; {error, failed} -> ?FAIL; @@ -302,6 +304,14 @@ run_modules([Module | Rest], Command, Config, File) -> {Module, Error} end. +apply_hooks(Mode, Config, Command) -> + Hooks = rebar_config:get_local(Config, Mode, []), + lists:foreach(fun apply_hook/1, + [Hook || Hook <- Hooks, element(1, Hook) =:= Command]). + +apply_hook({Command, Hook}) -> + Msg = lists:flatten(io_lib:format("Command [~p] failed!~n", [Command])), + rebar_utils:sh(Hook, [{abort_on_error, Msg}]). acc_modules(Modules, Command, Config, File) -> acc_modules(select_modules(Modules, Command, []), diff --git a/src/rebar_deps.erl b/src/rebar_deps.erl index 22ef09e..01cfad3 100644 --- a/src/rebar_deps.erl +++ b/src/rebar_deps.erl @@ -162,9 +162,9 @@ get_deps_dir(App) -> {true, filename:join([BaseDir, DepsDir, App])}. get_lib_dir(App) -> - % Find App amongst the reachable lib directories - % Returns either the found path or a tagged tuple with a boolean - % to match get_deps_dir's return type + %% Find App amongst the reachable lib directories + %% Returns either the found path or a tagged tuple with a boolean + %% to match get_deps_dir's return type case code:lib_dir(App) of {error, bad_name} -> {false, bad_name}; Path -> {true, Path} @@ -208,23 +208,23 @@ find_deps(_Mode, [Other | _Rest], _Acc) -> [Other, rebar_utils:get_cwd()]). find_dep(Dep) -> - % Find a dep based on its source, - % e.g. {git, "https://github.com/mochi/mochiweb.git", "HEAD"} - % Deps with a source must be found (or fetched) locally. - % Those without a source may be satisfied from lib directories (get_lib_dir). + %% Find a dep based on its source, + %% e.g. {git, "https://github.com/mochi/mochiweb.git", "HEAD"} + %% Deps with a source must be found (or fetched) locally. + %% Those without a source may be satisfied from lib dir (get_lib_dir). find_dep(Dep, Dep#dep.source). find_dep(Dep, undefined) -> - % 'source' is undefined. If Dep is not satisfied locally, - % go ahead and find it amongst the lib_dir's. + %% 'source' is undefined. If Dep is not satisfied locally, + %% go ahead and find it amongst the lib_dir's. case find_dep_in_dir(Dep, get_deps_dir(Dep#dep.app)) of - {avail, Dir} -> {avail, Dir}; + {avail, _Dir} = Avail -> Avail; {missing, _} -> find_dep_in_dir(Dep, get_lib_dir(Dep#dep.app)) end; find_dep(Dep, _Source) -> - % _Source is defined. Regardless of what it is, we must find it - % locally satisfied or fetch it from the original source - % into the project's deps + %% _Source is defined. Regardless of what it is, we must find it + %% locally satisfied or fetch it from the original source + %% into the project's deps find_dep_in_dir(Dep, get_deps_dir(Dep#dep.app)). find_dep_in_dir(_Dep, {false, Dir}) -> diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl index aee487c..d4ebe0c 100644 --- a/src/rebar_eunit.erl +++ b/src/rebar_eunit.erl @@ -191,11 +191,12 @@ eunit_config(Config) -> eqc_opts() -> - define_if('PROPER', is_lib_avail(is_eqc_avail, eqc, - "eqc.hrl", "QuickCheck")). + define_if('EQC', is_lib_avail(is_eqc_avail, eqc, + "eqc.hrl", "QuickCheck")). + proper_opts() -> - define_if('EQC', is_lib_avail(is_proper_avail, proper, - "proper.hrl", "PropEr")). + define_if('PROPER', is_lib_avail(is_proper_avail, proper, + "proper.hrl", "PropEr")). define_if(Def, true) -> [{d, Def}]; define_if(_Def, false) -> []. diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl index b230af1..a281b29 100644 --- a/src/rebar_port_compiler.erl +++ b/src/rebar_port_compiler.erl @@ -182,6 +182,15 @@ run_precompile_hook(Config, Env) -> undefined -> ok; {Script, BypassFileName} -> + ?CONSOLE( + << + "WARNING: option deprecated~n" + "Config option 'port_pre_script' has been deprecated " + "in favor of ~n{pre_hooks, [{compile, \"script\"}]}." + "~nskipfile support has also been removed. Add skipfile" + " logic to the~nscript instead.~nFuture builds of rebar" + " will remove the option 'port_pre_script'.~n~n" + >>, []), case filelib:is_regular(BypassFileName) of false -> ?CONSOLE("Running ~s\n", [Script]), @@ -198,6 +207,14 @@ run_cleanup_hook(Config) -> undefined -> ok; Script -> + ?CONSOLE( + << + "WARNING: option deprecated~n" + "Config option 'port_pre_script' has been deprecated " + "in favor of ~n{post_hooks, [{clean, \"script\"}]}." + "~nFuture builds of rebar will remove the option " + "'port_pre_script'.~n~n" + >>, []), ?CONSOLE("Running ~s\n", [Script]), {ok, _} = rebar_utils:sh(Script, []), ok diff --git a/src/rebar_post_script.erl b/src/rebar_post_script.erl index c7f2d01..39185a9 100644 --- a/src/rebar_post_script.erl +++ b/src/rebar_post_script.erl @@ -51,6 +51,24 @@ execute_post_script(Config, Key) -> undefined -> ok; Script -> + deprecated(Key), {ok, _} = rebar_utils:sh(Script, []), ok end. + +deprecated(compile_post_script) -> + ?CONSOLE( + << + "WARNING: option deprecated~n" + "Config option 'compile_post_script' has been deprecated in favor" + " of ~noption {post_hooks, [{compile, \"script\"}]}.~nFuture builds " + "of rebar will remove the option 'compile_post_script'.~n~n" + >>, []); +deprecated(clean_post_script) -> + ?CONSOLE( + << + "WARNING: option deprecated~n" + "Config option 'clean_post_script' has been deprecated in favor" + " of ~noption {post_hooks, [{clean, \"script\"}]}.~nFuture builds " + "of rebar will remove the option 'clean_post_script'.~n~n" + >>, []). diff --git a/src/rebar_pre_script.erl b/src/rebar_pre_script.erl index 9097807..b23f469 100644 --- a/src/rebar_pre_script.erl +++ b/src/rebar_pre_script.erl @@ -51,6 +51,24 @@ execute_pre_script(Config, Key) -> undefined -> ok; Script -> + deprecated(Key), {ok, _} = rebar_utils:sh(Script, []), ok end. + +deprecated(compile_pre_script) -> + ?CONSOLE( + << + "WARNING: option deprecated~n" + "Config option 'compile_pre_script' has been deprecated in favor" + " of ~n{pre_hooks, [{compile, \"script\"}]}.~nFuture builds of" + " rebar will remove the option 'compile_pre_script'.~n~n" + >>, []); +deprecated(clean_pre_script) -> + ?CONSOLE( + << + "WARNING: option deprecated~n" + "Config option 'clean_pre_script' has been deprecated in favor" + " of ~n{pre_hooks, [{clean, \"script\"}]}.~nFuture builds of" + " rebar will remove the option 'clean_pre_script'.~n~n" + >>, []). |