mirror of
https://github.com/correl/rebar.git
synced 2024-11-27 11:09:55 +00:00
Implement 'rebar help CMD1 CMD2' and extend common 'rebar help' msg
* allow plugins to print help message for implemented commands * append core rebar.config options to common 'rebar help' message
This commit is contained in:
parent
78fa8fc3d5
commit
4b8c81fb53
27 changed files with 570 additions and 33 deletions
|
@ -1,3 +1,3 @@
|
|||
|
||||
rebar_eunit.erl:351: Call to missing or unexported function eunit_test:function_wrapper/2
|
||||
rebar_eunit.erl:388: Call to missing or unexported function eunit_test:function_wrapper/2
|
||||
rebar_utils.erl:162: Call to missing or unexported function escript:foldl/3
|
||||
|
|
|
@ -213,9 +213,9 @@
|
|||
|
||||
%% Optional custom xref queries (xref manual has details) specified as
|
||||
%% {xref_queries, [{query_string(), expected_query_result()},...]}
|
||||
%% The following for example removes all references to ejabberd:*_msg/4
|
||||
%% The following for example removes all references to mod:*foo/4
|
||||
%% functions from undefined external function calls as those are in a
|
||||
%% generated module
|
||||
{xref_queries,
|
||||
[{"(XC - UC) || (XU - X - B"
|
||||
" - (\"ejabberd_logger\":\".*_msg\"/\"4\"))",[]}]}.
|
||||
" - (\"mod\":\".*foo\"/\"4\"))",[]}]}.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -47,6 +47,9 @@
|
|||
|
||||
-export([compile/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
%% ===================================================================
|
||||
|
@ -62,11 +65,23 @@ compile(Config, _AppFile) ->
|
|||
option(module_ext, DtlOpts) ++ ".erl",
|
||||
fun compile_abnfc/3).
|
||||
|
||||
|
||||
%% ===================================================================
|
||||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, compile) ->
|
||||
?CONSOLE(
|
||||
"Build ABNF (*.abnf) sources.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" ~p~n",
|
||||
[
|
||||
{abnfc_opts, [{doc_root, "src"},
|
||||
{out_dir, "src"},
|
||||
{source_ext, ".abnfc"},
|
||||
{module_ext, ""}]}
|
||||
]).
|
||||
|
||||
abnfc_opts(Config) ->
|
||||
rebar_config:get(Config, abnfc_opts, []).
|
||||
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
|
||||
-export(['generate-appups'/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-define(APPUPFILEFORMAT, "%% appup generated for ~p by rebar (~p)~n"
|
||||
"{~p, [{~p, ~p}], [{~p, []}]}.~n").
|
||||
|
||||
|
@ -82,6 +85,13 @@
|
|||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, 'generate-appups') ->
|
||||
?CONSOLE("Generate appup files.~n"
|
||||
"~n"
|
||||
"Valid command line options:~n"
|
||||
" previous_release=path~n",
|
||||
[]).
|
||||
|
||||
get_apps(Name, OldVerPath, NewVerPath) ->
|
||||
OldApps = rebar_rel_utils:get_rel_apps(Name, OldVerPath),
|
||||
?DEBUG("Old Version Apps: ~p~n", [OldApps]),
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
-export([compile/2,
|
||||
clean/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
%% ===================================================================
|
||||
|
@ -48,6 +51,23 @@ clean(_Config, _AppFile) ->
|
|||
ok = rebar_file_utils:delete_each(GeneratedFiles),
|
||||
ok.
|
||||
|
||||
%% ===================================================================
|
||||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, compile) ->
|
||||
info_help("Build ASN.1 (*.asn1) sources");
|
||||
info(help, clean) ->
|
||||
info_help("Delete ASN.1 (*.asn1) results").
|
||||
|
||||
info_help(Description) ->
|
||||
?CONSOLE(
|
||||
"~s.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" {asn1_opts, []} (see asn1ct:compile/2 documentation)~n",
|
||||
[Description]).
|
||||
|
||||
-spec compile_asn1(file:filename(), file:filename(),
|
||||
rebar_config:config()) -> ok.
|
||||
compile_asn1(Source, Target, Config) ->
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
|
||||
-export([clean/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
%% ===================================================================
|
||||
|
@ -37,3 +40,17 @@ clean(Config, _AppFile) ->
|
|||
%% Get a list of files to delete from config and remove them
|
||||
FilesToClean = rebar_config:get(Config, clean_files, []),
|
||||
lists:foreach(fun (F) -> rebar_file_utils:rm_rf(F) end, FilesToClean).
|
||||
|
||||
%% ===================================================================
|
||||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, clean) ->
|
||||
?CONSOLE(
|
||||
"Delete list of files.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" ~p~n",
|
||||
[
|
||||
{clean_files, ["file", "file2"]}
|
||||
]).
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
%% -------------------------------------------------------------------
|
||||
-module(rebar_core).
|
||||
|
||||
-export([process_commands/2]).
|
||||
-export([process_commands/2, help/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
|
@ -34,6 +34,35 @@
|
|||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
help(ParentConfig, Commands) ->
|
||||
%% get all core modules
|
||||
{ok, AnyDirModules} = application:get_env(rebar, any_dir_modules),
|
||||
{ok, RawCoreModules} = application:get_env(rebar, modules),
|
||||
AppDirModules = proplists:get_value(app_dir, RawCoreModules),
|
||||
RelDirModules = proplists:get_value(rel_dir, RawCoreModules),
|
||||
CoreModules = AnyDirModules ++ AppDirModules ++ RelDirModules,
|
||||
|
||||
%% get plugin modules
|
||||
Predirs = [],
|
||||
Dir = rebar_utils:get_cwd(),
|
||||
SubdirAssoc = remember_cwd_subdir(Dir, Predirs),
|
||||
Config = maybe_load_local_config(Dir, ParentConfig),
|
||||
{ok, PluginModules} = plugin_modules(Config, SubdirAssoc),
|
||||
|
||||
AllModules = CoreModules ++ PluginModules,
|
||||
|
||||
lists:foreach(
|
||||
fun(Cmd) ->
|
||||
?CONSOLE("==> help ~p~n~n", [Cmd]),
|
||||
CmdModules = select_modules(AllModules, Cmd, []),
|
||||
Modules = select_modules(CmdModules, info, []),
|
||||
lists:foreach(fun(M) ->
|
||||
?CONSOLE("=== ~p:~p ===~n", [M, Cmd]),
|
||||
M:info(help, Cmd),
|
||||
?CONSOLE("~n", [])
|
||||
end, Modules)
|
||||
end, Commands).
|
||||
|
||||
process_commands([], ParentConfig) ->
|
||||
AbortTrapped = rebar_config:get_xconf(ParentConfig, abort_trapped, false),
|
||||
case {get_operations(ParentConfig), AbortTrapped} of
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
|
||||
-export([ct/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
%% ===================================================================
|
||||
|
@ -53,6 +56,26 @@ ct(Config, File) ->
|
|||
%% ===================================================================
|
||||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, ct) ->
|
||||
?CONSOLE(
|
||||
"Run common_test suites.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
"Valid command line options:~n"
|
||||
" suites=foo,bar - run <test>/foo_SUITE and <test>/bar_SUITE~n"
|
||||
" case=\"mycase\" - run individual test case foo_SUITE:mycase~n",
|
||||
[
|
||||
{ct_dir, "itest"},
|
||||
{ct_log_dir, "test/logs"},
|
||||
{ct_extra_params, "-boot start_sasl -s myapp"},
|
||||
{ct_use_short_names, true}
|
||||
]).
|
||||
|
||||
run_test_if_present(TestDir, LogDir, Config, File) ->
|
||||
case filelib:is_dir(TestDir) of
|
||||
false ->
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
'delete-deps'/2,
|
||||
'list-deps'/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-record(dep, { dir,
|
||||
app,
|
||||
|
@ -203,6 +205,40 @@ do_check_deps(Config) ->
|
|||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, compile) ->
|
||||
info_help("Display to be fetched dependencies");
|
||||
info(help, 'check-deps') ->
|
||||
info_help("Display to be fetched dependencies");
|
||||
info(help, 'get-deps') ->
|
||||
info_help("Fetch dependencies");
|
||||
info(help, 'update-deps') ->
|
||||
info_help("Update fetched dependencies");
|
||||
info(help, 'delete-deps') ->
|
||||
info_help("Delete fetched dependencies");
|
||||
info(help, 'list-deps') ->
|
||||
info_help("List dependencies").
|
||||
|
||||
info_help(Description) ->
|
||||
?CONSOLE(
|
||||
"~s.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
"Valid command line options:~n"
|
||||
" deps_dir=\"deps\" (override default or rebar.config deps_dir)~n",
|
||||
[
|
||||
Description,
|
||||
{deps_dir, "deps"},
|
||||
{deps, [application_name,
|
||||
{application_name, "1.0.*"},
|
||||
{application_name, "1.0.*",
|
||||
{git, "git://github.com/basho/rebar.git", {branch, "master"}}},
|
||||
{application_name, "",
|
||||
{git, "git://github.com/basho/rebar.git", {branch, "master"}},
|
||||
[raw]}]}
|
||||
]).
|
||||
|
||||
%% Added because of trans deps,
|
||||
%% need all deps in same dir and should be the one set by the root rebar.config
|
||||
%% Sets a default if root config has no deps_dir set
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
|
||||
-export([compile/2, clean/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
%% ===================================================================
|
||||
|
@ -46,6 +49,23 @@ clean(_Config, _AppFile) ->
|
|||
ok = rebar_file_utils:delete_each(GeneratedFiles),
|
||||
ok.
|
||||
|
||||
%% ===================================================================
|
||||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, compile) ->
|
||||
info_help("Build Diameter (*.dia) sources");
|
||||
info(help, clean) ->
|
||||
info_help("Delete generated Diameter files").
|
||||
|
||||
info_help(Description) ->
|
||||
?CONSOLE(
|
||||
"~s.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" {dia_opts, []} (see diameter_codegen:from_dict/4 documentation)~n",
|
||||
[Description]).
|
||||
|
||||
-spec compile_dia(file:filename(), file:filename(),
|
||||
rebar_config:config()) -> ok.
|
||||
compile_dia(Source, Target, Config) ->
|
||||
|
|
|
@ -39,6 +39,9 @@
|
|||
|
||||
-export([doc/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
%% ===================================================================
|
||||
|
@ -71,6 +74,14 @@ doc(Config, File) ->
|
|||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, doc) ->
|
||||
?CONSOLE(
|
||||
"Generate Erlang program documentation.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" {edoc_opts, []} (see edoc:application/3 documentation)~n",
|
||||
[]).
|
||||
|
||||
setup_code_path() ->
|
||||
%% Setup code path prior to calling edoc so that edown, asciiedoc,
|
||||
%% and the like can work properly when generating their own
|
||||
|
|
|
@ -29,8 +29,9 @@
|
|||
-export([compile/2,
|
||||
clean/2]).
|
||||
|
||||
%% for internal use by only eunit and qc
|
||||
-export([test_compile/3]).
|
||||
%% for internal use only
|
||||
-export([test_compile/3,
|
||||
info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
|
@ -116,8 +117,6 @@ clean(_Config, _AppFile) ->
|
|||
|
||||
test_compile(Config, Cmd, OutDir) ->
|
||||
%% Obtain all the test modules for inclusion in the compile stage.
|
||||
%% Notice: this could also be achieved with the following
|
||||
%% rebar.config option: {test_compile_opts, [{src_dirs, ["src", "test"]}]}
|
||||
TestErls = rebar_utils:find_files("test", ".*\\.erl\$"),
|
||||
|
||||
%% Copy source files to eunit dir for cover in case they are not directly
|
||||
|
@ -165,6 +164,42 @@ test_compile(Config, Cmd, OutDir) ->
|
|||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, compile) ->
|
||||
info_help("Build *.erl, *.yrl, *.xrl, and *.mib sources");
|
||||
info(help, clean) ->
|
||||
info_help("Delete *.erl, *.yrl, *.xrl, and *.mib build results").
|
||||
|
||||
info_help(Description) ->
|
||||
?CONSOLE(
|
||||
"~s.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n",
|
||||
[
|
||||
Description,
|
||||
{erl_opts, [no_debug_info,
|
||||
{i, "myinclude"},
|
||||
{src_dirs, ["src", "src2", "src3"]},
|
||||
{platform_define,
|
||||
"(linux|solaris|freebsd|darwin)", 'HAVE_SENDFILE'},
|
||||
{platform_define, "(linux|freebsd)", 'BACKLOG', 128},
|
||||
{platform_define, "R13", 'old_inets'}]},
|
||||
{erl_first_files, ["mymib1", "mymib2"]},
|
||||
{mib_opts, []},
|
||||
{mib_first_files, []},
|
||||
{xrl_opts, []},
|
||||
{xrl_first_files, []},
|
||||
{yrl_opts, []},
|
||||
{yrl_first_files, []}
|
||||
]).
|
||||
|
||||
test_compile_config(Config, Cmd) ->
|
||||
{Config1, TriqOpts} = triq_opts(Config),
|
||||
{Config2, PropErOpts} = proper_opts(Config1),
|
||||
|
|
|
@ -96,6 +96,9 @@
|
|||
|
||||
-export([compile/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
%% ===================================================================
|
||||
|
@ -123,11 +126,24 @@ compile(Config, _AppFile) ->
|
|||
true = code:set_path(OrigPath),
|
||||
Result.
|
||||
|
||||
|
||||
%% ===================================================================
|
||||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, compile) ->
|
||||
?CONSOLE(
|
||||
"Build ErlyDtl (*.dtl) sources.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" ~p~n",
|
||||
[
|
||||
{erlydtl_opts, [{doc_root, "templates"},
|
||||
{out_dir, "ebin"},
|
||||
{source_ext, ".dtl"},
|
||||
{module_ext, "_dtl"},
|
||||
{recursive, true}]}
|
||||
]).
|
||||
|
||||
erlydtl_opts(Config) ->
|
||||
Opts = rebar_config:get(Config, erlydtl_opts, []),
|
||||
Tuples = [{K,V} || {K,V} <- Opts],
|
||||
|
@ -135,8 +151,11 @@ erlydtl_opts(Config) ->
|
|||
[] ->
|
||||
[lists:keysort(1, Tuples)];
|
||||
Lists ->
|
||||
lists:map(fun(L) ->
|
||||
lists:keysort(1, lists:foldl(fun({K,T}, Acc) ->
|
||||
lists:map(
|
||||
fun(L) ->
|
||||
lists:keysort(1,
|
||||
lists:foldl(
|
||||
fun({K,T}, Acc) ->
|
||||
lists:keystore(K, 1, Acc, {K, T})
|
||||
end, Tuples, L))
|
||||
end, Lists)
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
-export([escriptize/2,
|
||||
clean/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
-include_lib("kernel/include/file.hrl").
|
||||
|
||||
|
@ -108,6 +111,30 @@ clean(Config0, AppFile) ->
|
|||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, escriptize) ->
|
||||
info_help("Generate escript archive");
|
||||
info(help, clean) ->
|
||||
info_help("Delete generated escript archive").
|
||||
|
||||
info_help(Description) ->
|
||||
?CONSOLE(
|
||||
"~s.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n",
|
||||
[
|
||||
Description,
|
||||
{escript_name, "application"},
|
||||
{escript_incl_apps, []},
|
||||
{escript_shebang, "#!/usr/bin/env escript\n"},
|
||||
{escript_comment, "%%\n"},
|
||||
{escript_emu_args, "%%! -pa application/application/ebin\n"}
|
||||
]).
|
||||
|
||||
get_app_beams([], Acc) ->
|
||||
Acc;
|
||||
get_app_beams([App | Rest], Acc) ->
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
%% Additionally, for projects that have separate folders for the core
|
||||
%% implementation, and for the unit tests, then the following
|
||||
%% <code>rebar.config</code> option can be provided:
|
||||
%% <code>{test_compile_opts, [{src_dirs, ["dir"]}]}.</code>.
|
||||
%% <code>{eunit_compile_opts, [{src_dirs, ["src", "dir"]}]}.</code>.
|
||||
%% @copyright 2009, 2010 Dave Smith
|
||||
%% -------------------------------------------------------------------
|
||||
-module(rebar_eunit).
|
||||
|
@ -69,6 +69,9 @@
|
|||
-export([eunit/2,
|
||||
clean/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
-define(EUNIT_DIR, ".eunit").
|
||||
|
@ -100,6 +103,40 @@ clean(_Config, _File) ->
|
|||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, eunit) ->
|
||||
info_help("Run eunit tests");
|
||||
info(help, clean) ->
|
||||
Description = ?FMT("Delete eunit test dir (~s)", [?EUNIT_DIR]),
|
||||
info_help(Description).
|
||||
|
||||
info_help(Description) ->
|
||||
?CONSOLE(
|
||||
"~s.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
"Valid command line options:~n"
|
||||
" suites=\"foo,bar\" (Run tests in foo.erl, test/foo_tests.erl and~n"
|
||||
" tests in bar.erl, test/bar_tests.erl)~n"
|
||||
" tests=\"baz\" (For every existing suite, run the first test whose~n"
|
||||
" name starts with bar and, if no such test exists,~n"
|
||||
" run the test whose name starts with bar in the~n"
|
||||
" suite's _tests module)~n",
|
||||
[
|
||||
Description,
|
||||
{eunit_opts, []},
|
||||
{eunit_compile_opts, []},
|
||||
{eunit_first_files, []},
|
||||
{cover_enabled, false},
|
||||
{cover_print_enabled, false},
|
||||
{cover_export_enabled, false}
|
||||
]).
|
||||
|
||||
run_eunit(Config, CodePath, SrcErls) ->
|
||||
%% Build a list of all the .beams in ?EUNIT_DIR -- use this for
|
||||
%% cover and eunit testing. Normally you can just tell cover
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
|
||||
-export([compile/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
%% ===================================================================
|
||||
|
@ -45,6 +48,14 @@ compile(Config, _AppFile) ->
|
|||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, compile) ->
|
||||
?CONSOLE(
|
||||
"Build Lisp Flavoured Erlang (*.lfe) sources.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" erl_opts is reused.'~n",
|
||||
[]).
|
||||
|
||||
compile_lfe(Source, _Target, Config) ->
|
||||
case code:which(lfe_comp) of
|
||||
non_existing ->
|
||||
|
|
|
@ -42,6 +42,9 @@
|
|||
|
||||
-export([compile/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
%% ============================================================================
|
||||
|
@ -60,6 +63,19 @@ compile(Config, _AppFile) ->
|
|||
%% Internal functions
|
||||
%% ============================================================================
|
||||
|
||||
info(help, compile) ->
|
||||
?CONSOLE(
|
||||
"Build Neotoma (*.peg) sources.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" ~p~n",
|
||||
[
|
||||
{neotom_opts, [{doc_root, "src"},
|
||||
{out_dir, "src"},
|
||||
{source_ext, ".peg"},
|
||||
{module_ext, ""}]}
|
||||
]).
|
||||
|
||||
neotoma_opts(Config) ->
|
||||
rebar_config:get(Config, neotoma_opts, []).
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
-export([compile/2,
|
||||
clean/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
%% ===================================================================
|
||||
|
@ -82,11 +85,26 @@ clean(_Config, File) ->
|
|||
ok
|
||||
end.
|
||||
|
||||
|
||||
%% ===================================================================
|
||||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, compile) ->
|
||||
info_help("Validate .app file");
|
||||
info(help, clean) ->
|
||||
info_help("Delete .app file if generated from .app.src").
|
||||
|
||||
info_help(Description) ->
|
||||
?CONSOLE(
|
||||
"~s.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" ~p~n",
|
||||
[
|
||||
Description,
|
||||
{validate_app_modules, true}
|
||||
]).
|
||||
|
||||
preprocess(Config, AppSrcFile) ->
|
||||
case rebar_app_utils:load_app_file(Config, AppSrcFile) of
|
||||
{ok, Config1, AppName, AppData} ->
|
||||
|
|
|
@ -27,8 +27,11 @@
|
|||
-module(rebar_port_compiler).
|
||||
|
||||
-export([compile/2,
|
||||
clean/2,
|
||||
setup_env/1]).
|
||||
clean/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([setup_env/1,
|
||||
info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
|
@ -149,6 +152,27 @@ setup_env(Config) ->
|
|||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, compile) ->
|
||||
info_help("Build port sources");
|
||||
info(help, clean) ->
|
||||
info_help("Delete port build results").
|
||||
|
||||
info_help(Description) ->
|
||||
?CONSOLE(
|
||||
"~s.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" ~p~n"
|
||||
" ~p~n",
|
||||
[
|
||||
Description,
|
||||
{port_env, [{"CFLAGS", "$CFLAGS -Ifoo"},
|
||||
{"freebsd", "LDFLAGS", "$LDFLAGS -lfoo"}]},
|
||||
{port_specs, [{"priv/so_name.so", ["c_src/*.c"]},
|
||||
{"linux", "priv/hello_linux", ["c_src/hello_linux.c"]},
|
||||
{"linux", "priv/hello_linux", ["c_src/*.c"], [{env, []}]}]}
|
||||
]).
|
||||
|
||||
setup_env(Config, ExtraEnv) ->
|
||||
%% Extract environment values from the config (if specified) and
|
||||
%% merge with the default for this operating system. This enables
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
-export([compile/2,
|
||||
clean/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
%% ===================================================================
|
||||
|
@ -57,7 +60,6 @@ compile(Config, _AppFile) ->
|
|||
end
|
||||
end.
|
||||
|
||||
|
||||
clean(_Config, _AppFile) ->
|
||||
%% Get a list of generated .beam and .hrl files and then delete them
|
||||
Protos = rebar_utils:find_files("src", ".*\\.proto$"),
|
||||
|
@ -71,11 +73,24 @@ clean(_Config, _AppFile) ->
|
|||
delete_each(Targets)
|
||||
end.
|
||||
|
||||
|
||||
%% ===================================================================
|
||||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, compile) ->
|
||||
info_help("Build Protobuffs (*.proto) sources");
|
||||
info(help, clean) ->
|
||||
info_help("Delete Protobuffs (*.proto) build results").
|
||||
|
||||
info_help(Description) ->
|
||||
?CONSOLE(
|
||||
"~s.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" erl_opts is passed as compile_flags to "
|
||||
"protobuffs_compile:scan_file/2~n",
|
||||
[Description]).
|
||||
|
||||
protobuffs_is_present() ->
|
||||
code:which(protobuffs_compile) =/= non_existing.
|
||||
|
||||
|
@ -115,7 +130,7 @@ compile_each(Config, [{Proto, Beam, Hrl} | Rest]) ->
|
|||
ok = rebar_file_utils:mv(Hrl, "include"),
|
||||
ok;
|
||||
Other ->
|
||||
?ERROR("Protobuff compile of ~s failed: ~p\n",
|
||||
?ERROR("Protobuffs compile of ~s failed: ~p\n",
|
||||
[Proto, Other]),
|
||||
?FAIL
|
||||
end;
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
|
||||
-export([qc/2, triq/2, eqc/2, clean/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
-define(QC_DIR, ".qc").
|
||||
|
@ -57,6 +60,19 @@ clean(_Config, _File) ->
|
|||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, qc) ->
|
||||
?CONSOLE(
|
||||
"Test QuickCheck properties.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" {qc_opts, [{qc_mod, module()}, Options]}~n"
|
||||
" ~p~n"
|
||||
" ~p~n",
|
||||
[
|
||||
{qc_compile_opts, []},
|
||||
{qc_first_files, []}
|
||||
]).
|
||||
|
||||
-define(TRIQ_MOD, triq).
|
||||
-define(EQC_MOD, eqc).
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
overlay/2,
|
||||
clean/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
-include_lib("kernel/include/file.hrl").
|
||||
|
||||
|
@ -80,6 +83,32 @@ clean(Config, ReltoolFile) ->
|
|||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, generate) ->
|
||||
info_help("Build release with reltool");
|
||||
info(help, clean) ->
|
||||
info_help("Delete release");
|
||||
info(help, overlay) ->
|
||||
info_help("Run reltool overlays only").
|
||||
|
||||
info_help(Description) ->
|
||||
?CONSOLE(
|
||||
"~s.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" ~n"
|
||||
"Valid reltool.config options:~n"
|
||||
" {sys, []}~n"
|
||||
" {target_dir, \"target\"}~n"
|
||||
" {overlay_vars, \"overlay\"}~n"
|
||||
" {overlay, []}~n"
|
||||
"Valid command line options:~n"
|
||||
" target_dir=target~n"
|
||||
" overlay_vars=VarsFile~n"
|
||||
" dump_spec=1 (write reltool target spec to reltool.spec)~n",
|
||||
[
|
||||
Description
|
||||
]).
|
||||
|
||||
check_vsn() ->
|
||||
%% TODO: use application:load and application:get_key once we require
|
||||
%% R14A or newer. There's no reltool.app before R14A.
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
-export([compile/2,
|
||||
eunit/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
%% ===================================================================
|
||||
%% Public API
|
||||
%% ===================================================================
|
||||
|
@ -47,6 +50,25 @@ eunit(Config, _) ->
|
|||
%% Internal functions
|
||||
%% ====================================================================
|
||||
|
||||
info(help, compile) ->
|
||||
info_help();
|
||||
info(help, eunit) ->
|
||||
info_help().
|
||||
|
||||
info_help() ->
|
||||
?CONSOLE(
|
||||
"Check required ERTS or OTP release version.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n",
|
||||
[
|
||||
{require_erts_vsn, ".*"},
|
||||
{require_otp_vsn, ".*"},
|
||||
{require_min_otp_vsn, ".*"}
|
||||
]).
|
||||
|
||||
check_versions(Config) ->
|
||||
ErtsRegex = rebar_config:get(Config, require_erts_vsn, ".*"),
|
||||
ReOpts = [{capture, none}],
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
-export([resolve_variables/2,
|
||||
render/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
-define(TEMPLATE_RE, ".*\\.template\$").
|
||||
|
@ -98,6 +101,27 @@ render(Bin, Context) ->
|
|||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, create) ->
|
||||
?CONSOLE(
|
||||
"Create skel based on template and vars.~n"
|
||||
"~n"
|
||||
"Valid command line options:~n"
|
||||
" template= [var=foo,...]~n", []);
|
||||
info(help, 'create-app') ->
|
||||
?CONSOLE(
|
||||
"Create simple app skel.~n"
|
||||
"~n"
|
||||
"Valid command line options:~n"
|
||||
" [appid=myapp]~n", []);
|
||||
info(help, 'create-node') ->
|
||||
?CONSOLE(
|
||||
"Create simple node skel.~n"
|
||||
"~n"
|
||||
"Valid command line options:~n"
|
||||
" [nodeid=mynode]~n", []);
|
||||
info(help, 'list-templates') ->
|
||||
?CONSOLE("List available templates.~n", []).
|
||||
|
||||
create1(Config, TemplateId) ->
|
||||
{AvailTemplates, Files} = find_templates(Config),
|
||||
?DEBUG("Available templates: ~p\n", [AvailTemplates]),
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
|
||||
-export(['generate-upgrade'/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
-define(TMP, "_tmp").
|
||||
|
||||
%% ====================================================================
|
||||
|
@ -80,6 +83,13 @@
|
|||
%% Internal functions
|
||||
%% ==================================================================
|
||||
|
||||
info(help, 'generate-upgrade') ->
|
||||
?CONSOLE("Build an upgrade package.~n"
|
||||
"~n"
|
||||
"Valid command line options:~n"
|
||||
" previous_release=path~n",
|
||||
[]).
|
||||
|
||||
run_checks(Config, OldVerPath, ReltoolConfig) ->
|
||||
true = rebar_utils:prop_check(filelib:is_dir(OldVerPath),
|
||||
"Release directory doesn't exist (~p)~n",
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
|
||||
-export([xref/2]).
|
||||
|
||||
%% for internal use only
|
||||
-export([info/2]).
|
||||
|
||||
%% ===================================================================
|
||||
%% Public API
|
||||
%% ===================================================================
|
||||
|
@ -100,6 +103,22 @@ xref(Config, _) ->
|
|||
%% Internal functions
|
||||
%% ===================================================================
|
||||
|
||||
info(help, xref) ->
|
||||
?CONSOLE(
|
||||
"Run cross reference analysis.~n"
|
||||
"~n"
|
||||
"Valid rebar.config options:~n"
|
||||
" ~p~n"
|
||||
" ~p~n"
|
||||
" ~p~n",
|
||||
[
|
||||
{xref_warnings, false},
|
||||
{xref_checks, [exports_not_used, undefined_function_calls]},
|
||||
{xref_queries,
|
||||
[{"(xc - uc) || (xu - x - b"
|
||||
" - (\"mod\":\".*foo\"/\"4\"))",[]}]}
|
||||
]).
|
||||
|
||||
check_exports_not_used() ->
|
||||
{ok, UnusedExports0} = xref:analyze(xref, exports_not_used),
|
||||
UnusedExports = filter_away_ignored(UnusedExports0),
|
||||
|
|
Loading…
Reference in a new issue