mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Fix circular dependency
This commit is contained in:
parent
a8066b35a9
commit
3fd3bfc89a
2 changed files with 45 additions and 45 deletions
|
@ -38,7 +38,7 @@
|
||||||
%% ====================================================================
|
%% ====================================================================
|
||||||
|
|
||||||
main(Args) ->
|
main(Args) ->
|
||||||
case catch(rebar_core:run(Args)) of
|
case catch(run(Args)) of
|
||||||
ok ->
|
ok ->
|
||||||
ok;
|
ok;
|
||||||
{error, failed} ->
|
{error, failed} ->
|
||||||
|
@ -49,6 +49,48 @@ main(Args) ->
|
||||||
halt(1)
|
halt(1)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
%% ====================================================================
|
||||||
|
%% Internal functions
|
||||||
|
%% ====================================================================
|
||||||
|
|
||||||
|
run(RawArgs) ->
|
||||||
|
%% Pre-load the rebar app so that we get default configuration
|
||||||
|
ok = application:load(rebar),
|
||||||
|
%% Parse out command line arguments -- what's left is a list of commands to
|
||||||
|
%% run -- and start running commands
|
||||||
|
run_aux(parse_args(RawArgs)).
|
||||||
|
|
||||||
|
run_aux(["help"]) ->
|
||||||
|
help(),
|
||||||
|
ok;
|
||||||
|
run_aux(["version"]) ->
|
||||||
|
%% Display vsn and build time info
|
||||||
|
version(),
|
||||||
|
ok;
|
||||||
|
run_aux(Commands) ->
|
||||||
|
%% Make sure crypto is running
|
||||||
|
ok = crypto:start(),
|
||||||
|
|
||||||
|
%% Initialize logging system
|
||||||
|
rebar_log:init(),
|
||||||
|
|
||||||
|
%% Convert command strings to atoms
|
||||||
|
CommandAtoms = [list_to_atom(C) || C <- Commands],
|
||||||
|
|
||||||
|
%% Determine the location of the rebar executable; important for pulling
|
||||||
|
%% resources out of the escript
|
||||||
|
rebar_config:set_global(escript, filename:absname(escript:script_name())),
|
||||||
|
?DEBUG("Rebar location: ~p\n", [rebar_config:get_global(escript, undefined)]),
|
||||||
|
|
||||||
|
%% Note the top-level directory for reference
|
||||||
|
rebar_config:set_global(base_dir, filename:absname(rebar_utils:get_cwd())),
|
||||||
|
|
||||||
|
%% Keep track of how many operations we do, so we can detect bad commands
|
||||||
|
erlang:put(operations, 0),
|
||||||
|
|
||||||
|
%% Process each command, resetting any state between each one
|
||||||
|
rebar_core:process_commands(CommandAtoms).
|
||||||
|
|
||||||
%%
|
%%
|
||||||
%% print help/usage string
|
%% print help/usage string
|
||||||
%%
|
%%
|
||||||
|
@ -94,7 +136,7 @@ parse_args(Args) ->
|
||||||
|
|
||||||
{error, {Reason, Data}} ->
|
{error, {Reason, Data}} ->
|
||||||
?ERROR("Error: ~s ~p~n~n", [Reason, Data]),
|
?ERROR("Error: ~s ~p~n~n", [Reason, Data]),
|
||||||
rebar:help(),
|
help(),
|
||||||
halt(1)
|
halt(1)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -106,10 +148,6 @@ version() ->
|
||||||
?CONSOLE("rebar version: ~s date: ~s vcs: ~s\n", [Vsn, ?BUILD_TIME, ?VCS_INFO]).
|
?CONSOLE("rebar version: ~s date: ~s vcs: ~s\n", [Vsn, ?BUILD_TIME, ?VCS_INFO]).
|
||||||
|
|
||||||
|
|
||||||
%% ====================================================================
|
|
||||||
%% Internal functions
|
|
||||||
%% ====================================================================
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
%% set global flag based on getopt option boolean value
|
%% set global flag based on getopt option boolean value
|
||||||
%%
|
%%
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
%% -------------------------------------------------------------------
|
%% -------------------------------------------------------------------
|
||||||
-module(rebar_core).
|
-module(rebar_core).
|
||||||
|
|
||||||
-export([run/1,
|
-export([process_commands/1,
|
||||||
skip_dir/1,
|
skip_dir/1,
|
||||||
is_skip_dir/1,
|
is_skip_dir/1,
|
||||||
skip_dirs/0]).
|
skip_dirs/0]).
|
||||||
|
@ -46,44 +46,6 @@
|
||||||
%% Public API
|
%% Public API
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
|
|
||||||
run(RawArgs) ->
|
|
||||||
%% Pre-load the rebar app so that we get default configuration
|
|
||||||
ok = application:load(rebar),
|
|
||||||
%% Parse out command line arguments -- what's left is a list of commands to
|
|
||||||
%% run -- and start running commands
|
|
||||||
run_aux(rebar:parse_args(RawArgs)).
|
|
||||||
|
|
||||||
run_aux(["help"]) ->
|
|
||||||
rebar:help(),
|
|
||||||
ok;
|
|
||||||
run_aux(["version"]) ->
|
|
||||||
%% Display vsn and build time info
|
|
||||||
rebar:version(),
|
|
||||||
ok;
|
|
||||||
run_aux(Commands) ->
|
|
||||||
%% Make sure crypto is running
|
|
||||||
ok = crypto:start(),
|
|
||||||
|
|
||||||
%% Initialize logging system
|
|
||||||
rebar_log:init(),
|
|
||||||
|
|
||||||
%% Convert command strings to atoms
|
|
||||||
CommandAtoms = [list_to_atom(C) || C <- Commands],
|
|
||||||
|
|
||||||
%% Determine the location of the rebar executable; important for pulling
|
|
||||||
%% resources out of the escript
|
|
||||||
rebar_config:set_global(escript, filename:absname(escript:script_name())),
|
|
||||||
?DEBUG("Rebar location: ~p\n", [rebar_config:get_global(escript, undefined)]),
|
|
||||||
|
|
||||||
%% Note the top-level directory for reference
|
|
||||||
rebar_config:set_global(base_dir, filename:absname(rebar_utils:get_cwd())),
|
|
||||||
|
|
||||||
%% Keep track of how many operations we do, so we can detect bad commands
|
|
||||||
erlang:put(operations, 0),
|
|
||||||
|
|
||||||
%% Process each command, resetting any state between each one
|
|
||||||
process_commands(CommandAtoms).
|
|
||||||
|
|
||||||
skip_dir(Dir) ->
|
skip_dir(Dir) ->
|
||||||
SkipDir = {skip_dir, Dir},
|
SkipDir = {skip_dir, Dir},
|
||||||
case erlang:get(SkipDir) of
|
case erlang:get(SkipDir) of
|
||||||
|
|
Loading…
Reference in a new issue