|
@ -76,8 +76,18 @@ run(BaseConfig, Commands) -> |
|
|
%% Internal functions |
|
|
%% 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"]) -> |
|
|
run(["help"]) -> |
|
|
help(); |
|
|
help(); |
|
|
|
|
|
run(["info"|_]) -> |
|
|
|
|
|
help(); |
|
|
run(["version"]) -> |
|
|
run(["version"]) -> |
|
|
ok = load_rebar_app(), |
|
|
ok = load_rebar_app(), |
|
|
%% Display vsn and build time info |
|
|
%% Display vsn and build time info |
|
@ -138,6 +148,16 @@ init_config({Options, _NonOptArgs}) -> |
|
|
%% Initialize vsn cache |
|
|
%% Initialize vsn cache |
|
|
rebar_config:set_xconf(BaseConfig1, vsn_cache, dict:new()). |
|
|
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) -> |
|
|
run_aux(BaseConfig, Commands) -> |
|
|
%% Make sure crypto is running |
|
|
%% Make sure crypto is running |
|
|
case crypto:start() of |
|
|
case crypto:start() of |
|
@ -148,18 +168,10 @@ run_aux(BaseConfig, Commands) -> |
|
|
%% Convert command strings to atoms |
|
|
%% Convert command strings to atoms |
|
|
CommandAtoms = [list_to_atom(C) || C <- Commands], |
|
|
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 |
|
|
%% 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 |
|
|
%% print help/usage string |
|
@ -169,7 +181,29 @@ help() -> |
|
|
getopt:usage(OptSpecList, "rebar", |
|
|
getopt:usage(OptSpecList, "rebar", |
|
|
"[var=value,...] <command,...>", |
|
|
"[var=value,...] <command,...>", |
|
|
[{"var=value", "rebar global variables (e.g. force=1)"}, |
|
|
[{"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 |
|
|
%% Parse command line arguments using getopt and also filtering out any |
|
|