summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/rebar.hrl2
-rw-r--r--rebar.config6
-rw-r--r--src/rebar_app_info.erl4
-rw-r--r--src/rebar_erlc_compiler.erl14
-rw-r--r--src/rebar_packages.erl3
-rw-r--r--src/rebar_provider.erl36
-rw-r--r--src/rebar_prv_compile.erl2
-rw-r--r--src/rebar_prv_escripter.erl2
-rw-r--r--src/rebar_prv_install_deps.erl2
-rw-r--r--src/rebar_prv_release.erl2
-rw-r--r--src/rebar_prv_shell.erl16
-rw-r--r--src/rebar_prv_tar.erl2
-rw-r--r--src/rebar_prv_version.erl2
-rw-r--r--src/rebar_state.erl55
-rw-r--r--src/rebar_templater.erl2
15 files changed, 54 insertions, 96 deletions
diff --git a/include/rebar.hrl b/include/rebar.hrl
index 130182f..92fdbe9 100644
--- a/include/rebar.hrl
+++ b/include/rebar.hrl
@@ -19,7 +19,7 @@
deps :: [atom()], % The list of dependencies
desc :: string(), % The description for the task
short_desc :: string(), % A one line short description of the task
- example :: string(), % An example of the task usage
+ example :: string() | undefined, % An example of the task usage
opts :: list()}). % The list of options that the task requires/understands
-define(DEFAULT_LIB_DIRS, ["apps", "libs", "."]).
diff --git a/rebar.config b/rebar.config
index 3e2dcbb..acb1fad 100644
--- a/rebar.config
+++ b/rebar.config
@@ -12,6 +12,12 @@
{escript_top_level_app, rebar}.
{escript_name, rebar3}.
+{erl_opts,
+ [{platform_define, "^[0-9]+", namespaced_types},
+ {platform_define, "^R1[4|5]", deprecated_crypto},
+ debug_info,
+ warnings_as_errors]}.
+
%% Types dict:dict() and digraph:digraph() have been introduced in Erlang 17.
%% At the same time, their counterparts dict() and digraph() are to be
%% deprecated in Erlang 18. namespaced_types option is used to select proper
diff --git a/src/rebar_app_info.erl b/src/rebar_app_info.erl
index 403a5d1..5f44004 100644
--- a/src/rebar_app_info.erl
+++ b/src/rebar_app_info.erl
@@ -41,7 +41,7 @@
deps=[] :: list(),
dep_level :: integer(),
dir :: file:name(),
- source :: string() | undefined,
+ source :: string() | tuple() | undefined,
valid :: boolean()}).
%%============================================================================
@@ -190,7 +190,7 @@ ebin_dir(#app_info_t{dir=Dir}) ->
source(AppInfo=#app_info_t{}, Source) ->
AppInfo#app_info_t{source=Source}.
--spec source(t()) -> string().
+-spec source(t()) -> string() | tuple().
source(#app_info_t{source=Source}) ->
Source.
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index 6a16977..4076717 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -248,7 +248,7 @@ test_compile_config_and_opts(Config, ErlOpts, Cmd) ->
Config4 = rebar_state:set(Config3, erl_opts, Opts),
FirstFilesAtom = list_to_atom(Cmd ++ "_first_files"),
- FirstErls = rebar_state:get_list(Config4, FirstFilesAtom, []),
+ FirstErls = rebar_state:get(Config4, FirstFilesAtom, []),
Config5 = rebar_state:set(Config4, erl_first_files, FirstErls),
{Config5, Opts}.
@@ -274,7 +274,7 @@ define_if(Def, true) -> [{d, Def}];
define_if(_Def, false) -> [].
is_lib_avail(Config, DictKey, Mod, Hrl, Name) ->
- case rebar_state:get_xconf(Config, DictKey, undefined) of
+ case rebar_state:get(Config, DictKey, undefined) of
undefined ->
IsAvail = case code:lib_dir(Mod, include) of
{error, bad_name} ->
@@ -282,17 +282,17 @@ is_lib_avail(Config, DictKey, Mod, Hrl, Name) ->
Dir ->
filelib:is_regular(filename:join(Dir, Hrl))
end,
- NewConfig = rebar_state:set_xconf(Config, DictKey, IsAvail),
+ NewConfig = rebar_state:set(Config, DictKey, IsAvail),
?DEBUG("~s availability: ~p\n", [Name, IsAvail]),
{NewConfig, IsAvail};
IsAvail ->
{Config, IsAvail}
end.
--spec doterl_compile(rebar_state:t(), file:filename()) -> 'ok'.
-doterl_compile(Config, Dir) ->
- ErlOpts = rebar_utils:erl_opts(Config),
- doterl_compile(Config, Dir, [], ErlOpts).
+-spec doterl_compile(rebar_state:t(), file:filename()) -> ok.
+doterl_compile(State, Dir) ->
+ ErlOpts = rebar_utils:erl_opts(State),
+ doterl_compile(State, Dir, [], ErlOpts).
doterl_compile(Config, Dir, MoreSources, ErlOpts) ->
OutDir = filename:join(Dir, "ebin"),
diff --git a/src/rebar_packages.erl b/src/rebar_packages.erl
index 9cfcebb..dd229d3 100644
--- a/src/rebar_packages.erl
+++ b/src/rebar_packages.erl
@@ -12,7 +12,8 @@ get_packages(State) ->
true ->
try
{ok, Binary} = file:read_file(PackagesFile),
- binary_to_term(Binary)
+ {List, Graph} = binary_to_term(Binary),
+ {List, Graph}
catch
_:_ ->
?ERROR("Bad packages index, try to fix with `rebar update`~n", []),
diff --git a/src/rebar_provider.erl b/src/rebar_provider.erl
index 69ee22b..8a3d610 100644
--- a/src/rebar_provider.erl
+++ b/src/rebar_provider.erl
@@ -22,24 +22,8 @@
-type provider_name() :: atom().
--ifdef(have_callback_support).
-
--callback init(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error().
--callback do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error().
-
--else.
-
-%% In the case where R14 or lower is being used to compile the system
-%% we need to export a behaviour info
--export([behaviour_info/1]).
--spec behaviour_info(atom()) -> [{atom(), arity()}] | undefined.
-behaviour_info(callbacks) ->
- [{init, 1},
- {do, 1}];
-behaviour_info(_) ->
- undefined.
-
--endif.
+-callback init(rebar_state:t()) -> {ok, rebar_state:t()}.
+-callback do(rebar_state:t()) -> {ok, rebar_state:t()}.
%%%===================================================================
%%% API
@@ -50,17 +34,17 @@ behaviour_info(_) ->
%%
%% @param ModuleName The module name.
%% @param State0 The current state of the system
--spec new(module(), rebar_state:t()) ->
- {ok, rebar_state:t()}.
-new(ModuleName, State0) when is_atom(ModuleName) ->
+-spec new(module(), rebar_state:t()) -> {ok, rebar_state:t()}.
+new(ModuleName, State) when is_atom(ModuleName) ->
case code:which(ModuleName) of
non_existing ->
- ?ERROR("Module ~p does not exist.", [ModuleName]);
+ ?ERROR("Module ~p does not exist.", [ModuleName]),
+ {ok, State};
_ ->
- ModuleName:init(State0)
+ ModuleName:init(State)
end.
--spec create([{atom(), any()}]) -> t().
+-spec create(list()) -> t().
create(Attrs) ->
#provider{name=proplists:get_value(name, Attrs, undefined)
,provider_impl=proplists:get_value(provider_impl, Attrs, undefined)
@@ -75,14 +59,14 @@ create(Attrs) ->
%%
%% @param Provider the provider object
%% @param State the current state of the system
--spec do(Provider::t(), rebar_state:t()) ->
- {ok, rebar_state:t()}.
+-spec do(Provider::t(), rebar_state:t()) -> {ok, rebar_state:t()}.
do(Provider, State) ->
{PreHooks, PostHooks} = rebar_state:hooks(State, Provider#provider.name),
{ok, State1} = run_hook_plugins(PreHooks, State),
{ok, State2} = (Provider#provider.provider_impl):do(State1),
run_hook_plugins(PostHooks, State2).
+-spec run_hook_plugins([t()], rebar_state:t()) -> {ok, rebar_state:t()}.
run_hook_plugins(Hooks, State) ->
State1 = lists:foldl(fun(Hook, StateAcc) ->
{ok, StateAcc1} = rebar_provider:do(Hook, StateAcc),
diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl
index d89a4b0..11ee97a 100644
--- a/src/rebar_prv_compile.erl
+++ b/src/rebar_prv_compile.erl
@@ -27,7 +27,7 @@ init(State) ->
opts = []}),
{ok, State1}.
--spec do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error().
+-spec do(rebar_state:t()) -> {ok, rebar_state:t()}.
do(State) ->
ProjectApps = rebar_state:project_apps(State),
Deps = rebar_state:get(State, deps_to_build, []),
diff --git a/src/rebar_prv_escripter.erl b/src/rebar_prv_escripter.erl
index 9b5a812..bdaf1b8 100644
--- a/src/rebar_prv_escripter.erl
+++ b/src/rebar_prv_escripter.erl
@@ -59,7 +59,7 @@ init(State) ->
opts = []}),
{ok, State1}.
--spec do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error().
+-spec do(rebar_state:t()) -> {ok, rebar_state:t()}.
do(Config) ->
AppName = rebar_state:get(Config, escript_top_level_app, undefined),
App = rebar_state:get_app(Config, AppName),
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl
index 03dfce4..06e02cc 100644
--- a/src/rebar_prv_install_deps.erl
+++ b/src/rebar_prv_install_deps.erl
@@ -179,7 +179,7 @@ update_src_deps(Level, State, Update) ->
update_src_deps(Level+1, State2, Update)
end.
--spec handle_dep(binary(), rebar_state:t()) -> {[rebar_app_info:t()], [binary_dep()]}.
+-spec handle_dep(binary(), rebar_state:t()) -> {rebar_app_info:t(), [rebar_app_info:t()], [binary_dep()]}.
handle_dep(DepsDir, AppInfo) ->
C = rebar_config:consult(rebar_app_info:dir(AppInfo)),
S = rebar_state:new(rebar_state:new(), C, rebar_app_info:dir(AppInfo)),
diff --git a/src/rebar_prv_release.erl b/src/rebar_prv_release.erl
index 66ad4b2..d724490 100644
--- a/src/rebar_prv_release.erl
+++ b/src/rebar_prv_release.erl
@@ -31,5 +31,5 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()}.
do(Config) ->
- relx:main("release"),
+ relx:main(["release"]),
{ok, Config}.
diff --git a/src/rebar_prv_shell.erl b/src/rebar_prv_shell.erl
index 80f6bcf..bf37ddf 100644
--- a/src/rebar_prv_shell.erl
+++ b/src/rebar_prv_shell.erl
@@ -45,16 +45,16 @@
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
init(State) ->
State1 = rebar_state:add_provider(State, #provider{name = ?PROVIDER,
- provider_impl = ?MODULE,
- bare = false,
- deps = ?DEPS,
- example = "rebar shell",
- short_desc = "Run shell with project apps and deps in path.",
- desc = info(),
- opts = []}),
+ provider_impl = ?MODULE,
+ bare = false,
+ deps = ?DEPS,
+ example = "rebar shell",
+ short_desc = "Run shell with project apps and deps in path.",
+ desc = info(),
+ opts = []}),
{ok, State1}.
--spec do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error().
+-spec do(rebar_state:t()) -> {ok, rebar_state:t()}.
do(Config) ->
shell(),
{ok, Config}.
diff --git a/src/rebar_prv_tar.erl b/src/rebar_prv_tar.erl
index 6ef773c..c40c8df 100644
--- a/src/rebar_prv_tar.erl
+++ b/src/rebar_prv_tar.erl
@@ -31,5 +31,5 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()}.
do(State) ->
- relx:main("release tar"),
+ relx:main(["release tar"]),
{ok, State}.
diff --git a/src/rebar_prv_version.erl b/src/rebar_prv_version.erl
index 9197438..6969e62 100644
--- a/src/rebar_prv_version.erl
+++ b/src/rebar_prv_version.erl
@@ -30,7 +30,7 @@ init(State) ->
{ok, State1}.
--spec do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error().
+-spec do(rebar_state:t()) -> {ok, rebar_state:t()}.
do(State) ->
rebar3:version(),
{ok, State}.
diff --git a/src/rebar_state.erl b/src/rebar_state.erl
index 7ec4b97..58d535a 100644
--- a/src/rebar_state.erl
+++ b/src/rebar_state.erl
@@ -5,7 +5,6 @@
command_args/1, command_args/2,
dir/1, dir/2,
- set_skip_dir/2, is_skip_dir/2, reset_skip_dirs/1,
create_logic_providers/2,
project_apps/1, project_apps/2,
@@ -20,34 +19,23 @@
-include("rebar.hrl").
--ifdef(namespaced_types).
-%% dict:dict() exists starting from Erlang 17.
--type rebar_dict() :: dict:dict(term(), term()).
--else.
-%% dict() has been obsoleted in Erlang 17 and deprecated in 18.
--type rebar_dict() :: dict().
--endif.
+-record(state_t, {dir :: file:name(),
+ opts = [],
--record(state_t, {dir :: file:filename(),
- opts = [] :: list(),
- local_opts = [] :: list(),
- config = new_globals() :: rebar_dict(),
+ command_args = [],
- envs = new_env() :: rebar_dict(),
- command_args = [] :: list(),
-
- src_deps = [] :: [rebar_app_info:t()],
- src_apps = [] :: [rebar_app_info:t()],
+ src_deps = [],
+ src_apps = [],
binary_deps = [],
- project_apps = [] :: [rebar_app_info:t()],
+ project_apps = [],
providers = [],
- hooks = [],
- skip_dirs = new_skip_dirs() :: rebar_dict() }).
+ hooks = []}).
+
-export_type([t/0]).
--opaque t() :: #state_t{}.
+-type t() :: record(state_t).
-spec new() -> t().
new() ->
@@ -84,27 +72,11 @@ get(State, Key) ->
get(State, Key, Default) ->
proplists:get_value(Key, State#state_t.opts, Default).
+-spec set(t(), any(), any()) -> t().
set(State, Key, Value) ->
Opts = proplists:delete(Key, State#state_t.opts),
State#state_t { opts = [{Key, Value} | Opts] }.
-set_skip_dir(State, Dir) ->
- OldSkipDirs = State#state_t.skip_dirs,
- NewSkipDirs = case is_skip_dir(State, Dir) of
- false ->
- ?DEBUG("Adding skip dir: ~s\n", [Dir]),
- dict:store(Dir, true, OldSkipDirs);
- true ->
- OldSkipDirs
- end,
- State#state_t{skip_dirs = NewSkipDirs}.
-
-is_skip_dir(State, Dir) ->
- dict:is_key(Dir, State#state_t.skip_dirs).
-
-reset_skip_dirs(State) ->
- State#state_t{skip_dirs = new_skip_dirs()}.
-
command_args(#state_t{command_args=CmdArgs}) ->
CmdArgs.
@@ -181,15 +153,10 @@ append_hook(State=#state_t{hooks=Hooks}, Target, Hook) ->
{PreHooks, PostHooks} = proplists:get_value(Target, Hooks, {[], []}),
State#state_t{hooks=[{Target, {PreHooks, [Hook | PostHooks]}} | proplists:delete(Target, Hooks)]}.
+-spec hooks(t(), atom()) -> {[rebar_provider:t()], [rebar_provider:t()]}.
hooks(#state_t{hooks=Hooks}, Target) ->
proplists:get_value(Target, Hooks, {[], []}).
%% ===================================================================
%% Internal functions
%% ===================================================================
-
-new_globals() -> dict:new().
-
-new_env() -> dict:new().
-
-new_skip_dirs() -> dict:new().
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
index 048991b..99a67c3 100644
--- a/src/rebar_templater.erl
+++ b/src/rebar_templater.erl
@@ -378,7 +378,7 @@ execute_template(Files, [{'case', Variable, Values, Instructions} | Rest], Templ
ExistingFiles);
execute_template(Files, [{template, Input, Output} | Rest], TemplateType,
TemplateName, Context, Force, ExistingFiles) ->
- InputName = filename:join(filename:dirname(TemplateName), Input),
+ _InputName = filename:join(filename:dirname(TemplateName), Input),
%File = load_file(Files, TemplateType, InputName),
OutputTemplateName = make_template_name("rebar_output_template", Output),
{ok, OutputTemplateName1} = erlydtl:compile_template(Output, OutputTemplateName, ?ERLYDTL_COMPILE_OPTS),