summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar.erl65
-rw-r--r--src/rebar_config.erl5
-rw-r--r--src/rebar_core.erl4
-rw-r--r--src/rebar_ct.erl4
-rw-r--r--src/rebar_deps.erl157
-rw-r--r--src/rebar_dia_compiler.erl4
-rw-r--r--src/rebar_erlc_compiler.erl6
-rw-r--r--src/rebar_eunit.erl2
-rw-r--r--src/rebar_lfe_compiler.erl4
-rw-r--r--src/rebar_log.erl37
-rw-r--r--src/rebar_templater.erl11
-rw-r--r--src/rebar_upgrade.erl27
-rw-r--r--src/rebar_utils.erl14
-rw-r--r--src/rebar_xref.erl2
14 files changed, 212 insertions, 130 deletions
diff --git a/src/rebar.erl b/src/rebar.erl
index 1902f14..00505be 100644
--- a/src/rebar.erl
+++ b/src/rebar.erl
@@ -258,13 +258,27 @@ save_options(Config, {Options, NonOptArgs}) ->
%% set log level based on getopt option
%%
set_log_level(Config, Options) ->
- LogLevel = case proplists:get_all_values(verbose, Options) of
- [] ->
- rebar_log:default_level();
- Verbosities ->
- lists:last(Verbosities)
- end,
- rebar_config:set_global(Config, verbose, LogLevel).
+ {IsVerbose, Level} =
+ case proplists:get_bool(quiet, Options) of
+ true ->
+ {false, rebar_log:error_level()};
+ false ->
+ DefaultLevel = rebar_log:default_level(),
+ case proplists:get_all_values(verbose, Options) of
+ [] ->
+ {false, DefaultLevel};
+ Verbosities ->
+ {true, DefaultLevel + lists:last(Verbosities)}
+ end
+ end,
+
+ case IsVerbose of
+ true ->
+ Config1 = rebar_config:set_xconf(Config, is_verbose, true),
+ rebar_config:set_global(Config1, verbose, Level);
+ false ->
+ rebar_config:set_global(Config, verbose, Level)
+ end.
%%
%% show version information and halt
@@ -324,6 +338,7 @@ escriptize Generate escript archive
create template= [var=foo,...] Create skel based on template and vars
create-app [appid=myapp] Create simple app skel
+create-lib [libid=mylib] Create simple lib skel
create-node [nodeid=mynode] Create simple node skel
list-templates List available templates
@@ -375,12 +390,12 @@ option_spec_list() ->
JobsHelp = io_lib:format(
"Number of concurrent workers a command may use. Default: ~B",
[Jobs]),
- VerboseHelp = "Verbosity level (-v, -vv, -vvv, --verbose 3). Default: 0",
[
%% {Name, ShortOpt, LongOpt, ArgSpec, HelpMsg}
{help, $h, "help", undefined, "Show the program options"},
{commands, $c, "commands", undefined, "Show available commands"},
- {verbose, $v, "verbose", integer, VerboseHelp},
+ {verbose, $v, "verbose", integer, "Verbosity level (-v, -vv)"},
+ {quiet, $q, "quiet", boolean, "Quiet, only print error messages"},
{version, $V, "version", undefined, "Show version information"},
{force, $f, "force", undefined, "Force"},
{defines, $D, undefined, string, "Define compiler macro"},
@@ -417,11 +432,33 @@ filter_flags(Config, [Item | Rest], Commands) ->
end.
command_names() ->
- ["check-deps", "clean", "compile", "create", "create-app", "create-node",
- "ct", "delete-deps", "doc", "eunit", "escriptize", "generate",
- "generate-appups", "generate-upgrade", "get-deps", "help", "list-deps",
- "list-templates", "qc", "update-deps", "overlay", "shell", "version",
- "xref"].
+ [
+ "check-deps",
+ "clean",
+ "compile",
+ "create",
+ "create-app",
+ "create-lib",
+ "create-node",
+ "ct",
+ "delete-deps",
+ "doc",
+ "eunit",
+ "escriptize",
+ "generate",
+ "generate-appups",
+ "generate-upgrade",
+ "get-deps",
+ "help",
+ "list-deps",
+ "list-templates",
+ "qc",
+ "update-deps",
+ "overlay",
+ "shell",
+ "version",
+ "xref"
+ ].
unabbreviate_command_names([]) ->
[];
diff --git a/src/rebar_config.erl b/src/rebar_config.erl
index 461de5d..9b58d4f 100644
--- a/src/rebar_config.erl
+++ b/src/rebar_config.erl
@@ -31,7 +31,6 @@
get_all/2,
set/3,
set_global/3, get_global/3,
- is_verbose/1,
save_env/3, get_env/2, reset_envs/1,
set_skip_dir/2, is_skip_dir/2, reset_skip_dirs/1,
clean_config/2,
@@ -110,10 +109,6 @@ get_global(Config, Key, Default) ->
Value
end.
-is_verbose(Config) ->
- DefaulLevel = rebar_log:default_level(),
- get_global(Config, verbose, DefaulLevel) > DefaulLevel.
-
consult_file(File) ->
case filename:extension(File) of
".script" ->
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index 6c4f5c5..631cef2 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -181,7 +181,7 @@ skip_or_process_dir1(AppFile, ModuleSet, Config, CurrentCodePath,
process_dir1(Dir, Command, DirSet, Config, CurrentCodePath,
{DirModules, ModuleSetFile}) ->
- Config0 = rebar_config:set(Config, current_command, Command),
+ Config0 = rebar_config:set_xconf(Config, current_command, Command),
%% Get the list of modules for "any dir". This is a catch-all list
%% of modules that are processed in addition to modules associated
%% with this directory type. These any_dir modules are processed
@@ -411,7 +411,7 @@ restore_code_path(no_change) ->
restore_code_path({added, Paths}) ->
%% Verify that all of the paths still exist -- some dynamically
%% added paths can get blown away during clean.
- [code:del_path(F) || F <- Paths, erl_prim_loader_is_file(F)],
+ _ = [code:del_path(F) || F <- Paths, erl_prim_loader_is_file(F)],
ok.
erl_prim_loader_is_file(File) ->
diff --git a/src/rebar_ct.erl b/src/rebar_ct.erl
index 74ae618..91d763b 100644
--- a/src/rebar_ct.erl
+++ b/src/rebar_ct.erl
@@ -101,7 +101,7 @@ run_test(TestDir, LogDir, Config, _File) ->
{Cmd, RawLog} = make_cmd(TestDir, LogDir, Config),
?DEBUG("ct_run cmd:~n~p~n", [Cmd]),
clear_log(LogDir, RawLog),
- Output = case rebar_config:is_verbose(Config) of
+ Output = case rebar_log:is_verbose(Config) of
false ->
" >> " ++ RawLog ++ " 2>&1";
true ->
@@ -172,7 +172,7 @@ check_log(Config,RawLog,Fun) ->
%% Show the log if it hasn't already been shown because verbose was on
show_log(Config, RawLog) ->
?CONSOLE("Showing log\n", []),
- case rebar_config:is_verbose(Config) of
+ case rebar_log:is_verbose(Config) of
false ->
{ok, Contents} = file:read_file(RawLog),
?CONSOLE("~s", [Contents]);
diff --git a/src/rebar_deps.erl b/src/rebar_deps.erl
index 5e69709..2e305d5 100644
--- a/src/rebar_deps.erl
+++ b/src/rebar_deps.erl
@@ -72,43 +72,49 @@ preprocess(Config, _) ->
%% deps-related can be executed on their directories.
NonRawAvailableDeps = [D || D <- AvailableDeps, not D#dep.is_raw],
- case rebar_config:get(Config, current_command, undefined) of
+ case rebar_config:get_xconf(Config, current_command, undefined) of
'update-deps' ->
%% Skip ALL of the dep folders, we do this because we don't want
%% any other calls to preprocess() for update-deps beyond the
%% toplevel directory. They aren't actually harmful, but they slow
%% things down unnecessarily.
- NewConfig = lists:foldl(fun(D, Acc) ->
- rebar_config:set_skip_dir(Acc, D#dep.dir)
- end, Config3, collect_deps(rebar_utils:get_cwd(), Config3)),
+ NewConfig = lists:foldl(
+ fun(D, Acc) ->
+ rebar_config:set_skip_dir(Acc, D#dep.dir)
+ end,
+ Config3,
+ collect_deps(rebar_utils:get_cwd(), Config3)),
%% Return the empty list, as we don't want anything processed before
%% us.
{ok, NewConfig, []};
_ ->
- %% If skip_deps=true, mark each dep dir as a skip_dir w/ the core so that
- %% the current command doesn't run on the dep dir. However, pre/postprocess
- %% WILL run (and we want it to) for transitivity purposes.
+ %% If skip_deps=true, mark each dep dir as a skip_dir w/ the core
+ %% so that the current command doesn't run on the dep dir.
+ %% However, pre/postprocess WILL run (and we want it to) for
+ %% transitivity purposes.
%%
%% Also, if skip_deps=comma,separated,app,list, then only the given
%% dependencies are skipped.
- NewConfig = case rebar_config:get_global(Config3, skip_deps, false) of
- "true" ->
- lists:foldl(
- fun(#dep{dir = Dir}, C) ->
- rebar_config:set_skip_dir(C, Dir)
- end, Config3, AvailableDeps);
- Apps when is_list(Apps) ->
- SkipApps = [list_to_atom(App) || App <- string:tokens(Apps, ",")],
- lists:foldl(
- fun(#dep{dir = Dir, app = App}, C) ->
- case lists:member(App, SkipApps) of
- true -> rebar_config:set_skip_dir(C, Dir);
- false -> C
- end
- end, Config3, AvailableDeps);
- _ ->
- Config3
- end,
+ NewConfig =
+ case rebar_config:get_global(Config3, skip_deps, false) of
+ "true" ->
+ lists:foldl(
+ fun(#dep{dir = Dir}, C) ->
+ rebar_config:set_skip_dir(C, Dir)
+ end, Config3, AvailableDeps);
+ Apps when is_list(Apps) ->
+ SkipApps = [list_to_atom(App) ||
+ App <- string:tokens(Apps, ",")],
+ lists:foldl(
+ fun(#dep{dir = Dir, app = App}, C) ->
+ case lists:member(App, SkipApps) of
+ true -> rebar_config:set_skip_dir(C, Dir);
+ false -> C
+ end
+ end, Config3, AvailableDeps);
+ _ ->
+ Config3
+ end,
%% Return all the available dep directories for process
{ok, NewConfig, dep_dirs(NonRawAvailableDeps)}
@@ -183,19 +189,20 @@ do_check_deps(Config) ->
{ok, save_dep_dirs(Config2, lists:reverse(PulledDeps))}.
'update-deps'(Config, _) ->
- {Config2, UpdatedDeps} = update_deps_int(rebar_config:set(Config, depowner, dict:new()), []),
- DepOwners = rebar_config:get(Config2, depowner, dict:new()),
+ Config1 = rebar_config:set_xconf(Config, depowner, dict:new()),
+ {Config2, UpdatedDeps} = update_deps_int(Config1, []),
+ DepOwners = rebar_config:get_xconf(Config2, depowner, dict:new()),
%% check for conflicting deps
- [?ERROR("Conflicting dependencies for ~p: ~p~n", [K,
- [{"From: " ++ string:join(dict:fetch(D,
- DepOwners),
- ", "),
- {D#dep.vsn_regex,
- D#dep.source}} || D <- V]]) ||
- {K, V} <- dict:to_list(lists:foldl(fun(Dep, Acc) ->
- dict:append(Dep#dep.app, Dep, Acc)
- end, dict:new(), UpdatedDeps)), length(V) > 1],
+ _ = [?ERROR("Conflicting dependencies for ~p: ~p~n",
+ [K, [{"From: " ++ string:join(dict:fetch(D, DepOwners), ", "),
+ {D#dep.vsn_regex, D#dep.source}} || D <- V]])
+ || {K, V} <- dict:to_list(
+ lists:foldl(
+ fun(Dep, Acc) ->
+ dict:append(Dep#dep.app, Dep, Acc)
+ end, dict:new(), UpdatedDeps)),
+ length(V) > 1],
%% Add each updated dep to our list of dirs for post-processing. This yields
%% the necessary transitivity of the deps
@@ -250,13 +257,27 @@ info_help(Description) ->
[
Description,
{deps_dir, "deps"},
- {deps, [application_name,
- {application_name, "1.0.*"},
- {application_name, "1.0.*",
- {git, "git://github.com/rebar/rebar.git", {branch, "master"}}},
- {application_name, "",
- {git, "git://github.com/rebar/rebar.git", {branch, "master"}},
- [raw]}]}
+ {deps,
+ [app_name,
+ {rebar, "1.0.*"},
+ {rebar, ".*",
+ {git, "git://github.com/rebar/rebar.git"}},
+ {rebar, ".*",
+ {git, "git://github.com/rebar/rebar.git", "Rev"}},
+ {rebar, "1.0.*",
+ {git, "git://github.com/rebar/rebar.git", {branch, "master"}}},
+ {rebar, "1.0.0",
+ {git, "git://github.com/rebar/rebar.git", {tag, "1.0.0"}}},
+ {rebar, "",
+ {git, "git://github.com/rebar/rebar.git", {branch, "master"}},
+ [raw]},
+ {app_name, ".*", {hg, "https://www.example.org/url"}},
+ {app_name, ".*", {rsync, "Url"}},
+ {app_name, ".*", {svn, "https://www.example.org/url"}},
+ {app_name, ".*", {svn, "svn://svn.example.org/url"}},
+ {app_name, ".*", {bzr, "https://www.example.org/url", "Rev"}},
+ {app_name, ".*", {fossil, "https://www.example.org/url"}},
+ {app_name, ".*", {fossil, "https://www.example.org/url", "Vsn"}}]}
]).
%% Added because of trans deps,
@@ -439,7 +460,8 @@ is_app_available(Config, App, VsnRegex, Path, _IsRaw = false) ->
{Config, {false, {missing_app_file, Path}}}
end;
is_app_available(Config, App, _VsnRegex, Path, _IsRaw = true) ->
- ?DEBUG("is_app_available, looking for Raw Depencency ~p with Path ~p~n", [App, Path]),
+ ?DEBUG("is_app_available, looking for Raw Depencency ~p with Path ~p~n",
+ [App, Path]),
case filelib:is_dir(Path) of
true ->
%% TODO: look for version string in <Path>/VERSION file? Not clear
@@ -462,8 +484,8 @@ use_source(Config, Dep, Count) ->
case filelib:is_dir(Dep#dep.dir) of
true ->
%% Already downloaded -- verify the versioning matches the regex
- case is_app_available(Config, Dep#dep.app,
- Dep#dep.vsn_regex, Dep#dep.dir, Dep#dep.is_raw) of
+ case is_app_available(Config, Dep#dep.app, Dep#dep.vsn_regex,
+ Dep#dep.dir, Dep#dep.is_raw) of
{Config1, {true, _}} ->
Dir = filename:join(Dep#dep.dir, "ebin"),
ok = filelib:ensure_dir(filename:join(Dir, "dummy")),
@@ -524,8 +546,6 @@ download_source(AppDir, {rsync, Url}) ->
rebar_utils:sh(?FMT("rsync -az --delete ~s/ ~s", [Url, AppDir]), []);
download_source(AppDir, {fossil, Url}) ->
download_source(AppDir, {fossil, Url, ""});
-download_source(AppDir, {fossil, Url, latest}) ->
- download_source(AppDir, {fossil, Url, ""});
download_source(AppDir, {fossil, Url, Version}) ->
Repository = filename:join(AppDir, filename:basename(AppDir) ++ ".fossil"),
ok = filelib:ensure_dir(Repository),
@@ -561,7 +581,8 @@ update_source1(AppDir, {git, _Url, {branch, Branch}}) ->
ShOpts = [{cd, AppDir}],
rebar_utils:sh("git fetch origin", ShOpts),
rebar_utils:sh(?FMT("git checkout -q ~s", [Branch]), ShOpts),
- rebar_utils:sh(?FMT("git pull --ff-only --no-rebase -q origin ~s", [Branch]), ShOpts);
+ rebar_utils:sh(
+ ?FMT("git pull --ff-only --no-rebase -q origin ~s", [Branch]),ShOpts);
update_source1(AppDir, {git, _Url, {tag, Tag}}) ->
ShOpts = [{cd, AppDir}],
rebar_utils:sh("git fetch origin", ShOpts),
@@ -580,8 +601,6 @@ update_source1(AppDir, {rsync, Url}) ->
rebar_utils:sh(?FMT("rsync -az --delete ~s/ ~s",[Url,AppDir]),[]);
update_source1(AppDir, {fossil, Url}) ->
update_source1(AppDir, {fossil, Url, ""});
-update_source1(AppDir, {fossil, Url, latest}) ->
- update_source1(AppDir, {fossil, Url, ""});
update_source1(AppDir, {fossil, _Url, Version}) ->
ok = file:set_cwd(AppDir),
rebar_utils:sh("fossil pull", [{cd, AppDir}]),
@@ -607,24 +626,27 @@ update_deps_int(Config0, UDD) ->
lists:foldl(fun(Dep, {Config, Updated}) ->
{true, AppDir} = get_deps_dir(Config, Dep#dep.app),
- Config2 = case has_vcs_dir(element(1, Dep#dep.source), AppDir) of
- false ->
- %% If the dep did not exist (maybe it was added)
- %% clone it. We'll traverse ITS deps below. and
- %% clone them if needed.
- {C1, _D1} = use_source(Config, Dep),
- C1;
- true ->
- Config
- end,
+ Config2 = case has_vcs_dir(element(1, Dep#dep.source),
+ AppDir) of
+ false ->
+ %% If the dep did not exist (maybe it
+ %% was added), clone it.
+ %% We'll traverse ITS deps below and
+ %% clone them if needed.
+ {C1, _D1} = use_source(Config, Dep),
+ C1;
+ true ->
+ Config
+ end,
ok = file:set_cwd(AppDir),
Config3 = rebar_config:new(Config2),
%% track where a dep comes from...
- Config4 = rebar_config:set(Config3, depowner,
- dict:append(Dep, ConfDir,
- rebar_config:get(Config3,
- depowner,
- dict:new()))),
+ DepOwner = dict:append(
+ Dep, ConfDir,
+ rebar_config:get_xconf(Config3, depowner,
+ dict:new())),
+ Config4 = rebar_config:set_xconf(Config3, depowner,
+ DepOwner),
{Config5, Res} = update_deps_int(Config4, Updated),
{Config5, lists:umerge(lists:sort(Res),
@@ -655,7 +677,8 @@ collect_deps(Dir, C) ->
{Config1, Deps} = find_deps(Config, read, RawDeps),
lists:flatten(Deps ++ [begin
- {true, AppDir} = get_deps_dir(Config1, Dep#dep.app),
+ {true, AppDir} = get_deps_dir(
+ Config1, Dep#dep.app),
collect_deps(AppDir, C)
end || Dep <- Deps]);
_ ->
diff --git a/src/rebar_dia_compiler.erl b/src/rebar_dia_compiler.erl
index f81c734..ba9d159 100644
--- a/src/rebar_dia_compiler.erl
+++ b/src/rebar_dia_compiler.erl
@@ -75,8 +75,8 @@ compile_dia(Source, Target, Config) ->
case diameter_dict_util:parse({path, Source}, []) of
{ok, Spec} ->
FileName = dia_filename(Source, Spec),
- diameter_codegen:from_dict(FileName, Spec, Opts, erl),
- diameter_codegen:from_dict(FileName, Spec, Opts, hrl),
+ _ = diameter_codegen:from_dict(FileName, Spec, Opts, erl),
+ _ = diameter_codegen:from_dict(FileName, Spec, Opts, hrl),
HrlFile = filename:join("src", FileName ++ ".hrl"),
case filelib:is_regular(HrlFile) of
true ->
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index 4157ba4..dbefa4a 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -157,7 +157,8 @@ test_compile(Config, Cmd, OutDir) ->
%% Compile erlang code to OutDir, using a tweaked config
%% with appropriate defines for eunit, and include all the test modules
%% as well.
- ok = doterl_compile(test_compile_config(Config, Cmd), OutDir, TestErls),
+ ok = doterl_compile(test_compile_config(Config, ErlOpts, Cmd),
+ OutDir, TestErls),
{ok, SrcErls}.
@@ -201,12 +202,11 @@ info_help(Description) ->
{yrl_first_files, []}
]).
-test_compile_config(Config, Cmd) ->
+test_compile_config(Config, ErlOpts, Cmd) ->
{Config1, TriqOpts} = triq_opts(Config),
{Config2, PropErOpts} = proper_opts(Config1),
{Config3, EqcOpts} = eqc_opts(Config2),
- ErlOpts = rebar_config:get_list(Config3, erl_opts, []),
OptsAtom = list_to_atom(Cmd ++ "_compile_opts"),
EunitOpts = rebar_config:get_list(Config3, OptsAtom, []),
Opts0 = [{d, 'TEST'}] ++
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl
index d39b1a2..6ea28f7 100644
--- a/src/rebar_eunit.erl
+++ b/src/rebar_eunit.erl
@@ -408,7 +408,7 @@ perform_eunit(Config, Tests) ->
get_eunit_opts(Config) ->
%% Enable verbose in eunit if so requested..
- BaseOpts = case rebar_config:is_verbose(Config) of
+ BaseOpts = case rebar_log:is_verbose(Config) of
true ->
[verbose];
false ->
diff --git a/src/rebar_lfe_compiler.erl b/src/rebar_lfe_compiler.erl
index 2a047d8..8488b0f 100644
--- a/src/rebar_lfe_compiler.erl
+++ b/src/rebar_lfe_compiler.erl
@@ -70,8 +70,8 @@ compile_lfe(Source, _Target, Config) ->
"~n", []),
?FAIL;
_ ->
- Opts = [{i, "include"}, {outdir, "ebin"}, return]
- ++ rebar_config:get_list(Config, erl_opts, []),
+ ErlOpts = rebar_utils:erl_opts(Config),
+ Opts = [{i, "include"}, {outdir, "ebin"}, return] ++ ErlOpts,
case lfe_comp:file(Source, Opts) of
{ok, _Mod, Ws} ->
rebar_base_compiler:ok_tuple(Config, Source, Ws);
diff --git a/src/rebar_log.erl b/src/rebar_log.erl
index 4108c9c..ba25332 100644
--- a/src/rebar_log.erl
+++ b/src/rebar_log.erl
@@ -27,8 +27,17 @@
-module(rebar_log).
-export([init/1,
- set_level/1, default_level/0,
- log/3]).
+ set_level/1,
+ error_level/0,
+ default_level/0,
+ log/3,
+ log/4,
+ is_verbose/1]).
+
+-define(ERROR_LEVEL, 0).
+-define(WARN_LEVEL, 1).
+-define(INFO_LEVEL, 2).
+-define(DEBUG_LEVEL, 3).
%% ===================================================================
%% Public API
@@ -37,35 +46,39 @@
init(Config) ->
Verbosity = rebar_config:get_global(Config, verbose, default_level()),
case valid_level(Verbosity) of
- 0 -> set_level(error);
- 1 -> set_level(warn);
- 2 -> set_level(info);
- 3 -> set_level(debug)
+ ?ERROR_LEVEL -> set_level(error);
+ ?WARN_LEVEL -> set_level(warn);
+ ?INFO_LEVEL -> set_level(info);
+ ?DEBUG_LEVEL -> set_level(debug)
end.
set_level(Level) ->
ok = application:set_env(rebar, log_level, Level).
log(Level, Str, Args) ->
+ log(standard_io, Level, Str, Args).
+
+log(Device, Level, Str, Args) ->
{ok, LogLevel} = application:get_env(rebar, log_level),
case should_log(LogLevel, Level) of
true ->
- io:format(log_prefix(Level) ++ Str, Args);
+ io:format(Device, log_prefix(Level) ++ Str, Args);
false ->
ok
end.
-default_level() -> error_level().
+error_level() -> ?ERROR_LEVEL.
+default_level() -> ?WARN_LEVEL.
+
+is_verbose(Config) ->
+ rebar_config:get_xconf(Config, is_verbose, false).
%% ===================================================================
%% Internal functions
%% ===================================================================
valid_level(Level) ->
- erlang:max(error_level(), erlang:min(Level, debug_level())).
-
-error_level() -> 0.
-debug_level() -> 3.
+ erlang:max(?ERROR_LEVEL, erlang:min(Level, ?DEBUG_LEVEL)).
should_log(debug, _) -> true;
should_log(info, debug) -> false;
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
index b8f7087..c21daa3 100644
--- a/src/rebar_templater.erl
+++ b/src/rebar_templater.erl
@@ -27,6 +27,7 @@
-module(rebar_templater).
-export(['create-app'/2,
+ 'create-lib'/2,
'create-node'/2,
'list-templates'/2,
create/2]).
@@ -50,6 +51,10 @@
%% Alias for create w/ template=simpleapp
create1(Config, "simpleapp").
+'create-lib'(Config, _File) ->
+ %% Alias for create w/ template=simplelib
+ create1(Config, "simplelib").
+
'create-node'(Config, _File) ->
%% Alias for create w/ template=simplenode
create1(Config, "simplenode").
@@ -116,6 +121,12 @@ info(help, 'create-app') ->
"~n"
"Valid command line options:~n"
" [appid=myapp]~n", []);
+info(help, 'create-lib') ->
+ ?CONSOLE(
+ "Create simple lib skel.~n"
+ "~n"
+ "Valid command line options:~n"
+ " [libid=mylib]~n", []);
info(help, 'create-node') ->
?CONSOLE(
"Create simple node skel.~n"
diff --git a/src/rebar_upgrade.erl b/src/rebar_upgrade.erl
index 17676fb..3a38a08 100644
--- a/src/rebar_upgrade.erl
+++ b/src/rebar_upgrade.erl
@@ -183,21 +183,22 @@ boot_files(TargetDir, Ver, Name) ->
filename:join([".", ?TMP, "releases", Ver, "start_clean.boot"])),
SysConfig = filename:join([TargetDir, "releases", Ver, "sys.config"]),
- case filelib:is_regular(SysConfig) of
- true ->
- {ok, _} = file:copy(
- SysConfig,
- filename:join([".", ?TMP, "releases", Ver, "sys.config"]));
- false -> ok
- end,
+ _ = case filelib:is_regular(SysConfig) of
+ true ->
+ {ok, _} = file:copy(
+ SysConfig,
+ filename:join([".", ?TMP, "releases", Ver,
+ "sys.config"]));
+ false -> ok
+ end,
VmArgs = filename:join([TargetDir, "releases", Ver, "vm.args"]),
- case filelib:is_regular(VmArgs) of
- true ->
- {ok, _} = file:copy(
- VmArgs,
- filename:join([".", ?TMP, "releases", Ver, "vm.args"]));
- false -> {ok, 0}
+ case filelib:is_regular(VmArgs) of
+ true ->
+ {ok, _} = file:copy(
+ VmArgs,
+ filename:join([".", ?TMP, "releases", Ver, "vm.args"]));
+ false -> {ok, 0}
end.
make_tar(NameVer, NewVer, NewName) ->
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 4a74661..618427f 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -200,12 +200,12 @@ expand_env_variable(InStr, VarName, RawVarValue) ->
re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts)
end.
-vcs_vsn(Config, Vcs, Dir) ->
- Key = {Vcs, Dir},
+vcs_vsn(Config, Vsn, Dir) ->
+ Key = {Vsn, Dir},
Cache = rebar_config:get_xconf(Config, vsn_cache),
case dict:find(Key, Cache) of
error ->
- VsnString = vcs_vsn_1(Vcs, Dir),
+ VsnString = vcs_vsn_1(Vsn, Dir),
Cache1 = dict:store(Key, VsnString, Cache),
Config1 = rebar_config:set_xconf(Config, vsn_cache, Cache1),
{Config1, VsnString};
@@ -441,11 +441,12 @@ emulate_escript_foldl(Fun, Acc, File) ->
vcs_vsn_1(Vcs, Dir) ->
case vcs_vsn_cmd(Vcs) of
- {unknown, VsnString} ->
- ?DEBUG("vcs_vsn: Unknown VCS atom in vsn field: ~p\n", [Vcs]),
+ {plain, VsnString} ->
VsnString;
{cmd, CmdString} ->
vcs_vsn_invoke(CmdString, Dir);
+ unknown ->
+ ?ABORT("vcs_vsn: Unknown vsn format: ~p\n", [Vcs]);
Cmd ->
%% If there is a valid VCS directory in the application directory,
%% use that version info
@@ -478,7 +479,8 @@ vcs_vsn_cmd(bzr) -> "bzr revno";
vcs_vsn_cmd(svn) -> "svnversion";
vcs_vsn_cmd(fossil) -> "fossil info";
vcs_vsn_cmd({cmd, _Cmd}=Custom) -> Custom;
-vcs_vsn_cmd(Version) -> {unknown, Version}.
+vcs_vsn_cmd(Version) when is_list(Version) -> {plain, Version};
+vcs_vsn_cmd(_) -> unknown.
vcs_vsn_invoke(Cmd, Dir) ->
{ok, VsnString} = rebar_utils:sh(Cmd, [{cd, Dir}, {use_stdout, false}]),
diff --git a/src/rebar_xref.erl b/src/rebar_xref.erl
index eaf6d03..0d89460 100644
--- a/src/rebar_xref.erl
+++ b/src/rebar_xref.erl
@@ -51,7 +51,7 @@ xref(Config, _) ->
xref:set_default(xref, [{warnings,
rebar_config:get(Config, xref_warnings, false)},
- {verbose, rebar_config:is_verbose(Config)}]),
+ {verbose, rebar_log:is_verbose(Config)}]),
{ok, _} = xref:add_directory(xref, "ebin"),