summaryrefslogtreecommitdiff
path: root/src/rebar.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar.erl')
-rw-r--r--src/rebar.erl56
1 files changed, 45 insertions, 11 deletions
diff --git a/src/rebar.erl b/src/rebar.erl
index c872ade..ded5ebe 100644
--- a/src/rebar.erl
+++ b/src/rebar.erl
@@ -76,8 +76,18 @@ run(BaseConfig, Commands) ->
%% Internal functions
%% ====================================================================
+run(["help"|RawCmds]) when RawCmds =/= [] ->
+ ok = load_rebar_app(),
+ Cmds = unabbreviate_command_names(RawCmds),
+ Args = parse_args(Cmds),
+ BaseConfig = init_config(Args),
+ {BaseConfig1, _} = save_options(BaseConfig, Args),
+ BaseConfig2 = init_config1(BaseConfig1),
+ rebar_core:help(BaseConfig2, [list_to_atom(C) || C <- Cmds]);
run(["help"]) ->
help();
+run(["info"|_]) ->
+ help();
run(["version"]) ->
ok = load_rebar_app(),
%% Display vsn and build time info
@@ -138,6 +148,16 @@ init_config({Options, _NonOptArgs}) ->
%% Initialize vsn cache
rebar_config:set_xconf(BaseConfig1, vsn_cache, dict:new()).
+init_config1(BaseConfig) ->
+ %% Determine the location of the rebar executable; important for pulling
+ %% resources out of the escript
+ ScriptName = filename:absname(escript:script_name()),
+ BaseConfig1 = rebar_config:set_xconf(BaseConfig, escript, ScriptName),
+ ?DEBUG("Rebar location: ~p\n", [ScriptName]),
+ %% Note the top-level directory for reference
+ AbsCwd = filename:absname(rebar_utils:get_cwd()),
+ rebar_config:set_xconf(BaseConfig1, base_dir, AbsCwd).
+
run_aux(BaseConfig, Commands) ->
%% Make sure crypto is running
case crypto:start() of
@@ -148,18 +168,10 @@ run_aux(BaseConfig, Commands) ->
%% 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
- ScriptName = filename:absname(escript:script_name()),
- BaseConfig1 = rebar_config:set_xconf(BaseConfig, escript, ScriptName),
- ?DEBUG("Rebar location: ~p\n", [ScriptName]),
-
- %% Note the top-level directory for reference
- AbsCwd = filename:absname(rebar_utils:get_cwd()),
- BaseConfig2 = rebar_config:set_xconf(BaseConfig1, base_dir, AbsCwd),
+ BaseConfig1 = init_config1(BaseConfig),
%% Process each command, resetting any state between each one
- rebar_core:process_commands(CommandAtoms, BaseConfig2).
+ rebar_core:process_commands(CommandAtoms, BaseConfig1).
%%
%% print help/usage string
@@ -169,7 +181,29 @@ help() ->
getopt:usage(OptSpecList, "rebar",
"[var=value,...] <command,...>",
[{"var=value", "rebar global variables (e.g. force=1)"},
- {"command", "Command to run (e.g. compile)"}]).
+ {"command", "Command to run (e.g. compile)"}]),
+ ?CONSOLE(
+ "Core rebar.config options:~n"
+ " ~p~n"
+ " ~p~n"
+ " ~p~n"
+ " ~p~n"
+ " ~p~n"
+ " ~p~n",
+ [
+ {lib_dirs, []},
+ {sub_dirs, ["dir1", "dir2"]},
+ {plugins, [plugin1, plugin2]},
+ {plugin_dir, "some_other_directory"},
+ {pre_hooks, [{clean, "./prepare_package_files.sh"},
+ {"linux", compile, "c_src/build_linux.sh"},
+ {compile, "escript generate_headers"},
+ {compile, "escript check_headers"}]},
+ {post_hooks, [{clean, "touch file1.out"},
+ {"freebsd", compile, "c_src/freebsd_tweaks.sh"},
+ {eunit, "touch file2.out"},
+ {compile, "touch postcompile.out"}]}
+ ]).
%%
%% Parse command line arguments using getopt and also filtering out any