From 79bbf33cbd46c9a1beeae00424e14969608385ba Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 3 Nov 2014 20:47:54 -0600 Subject: fix modules thta still were using format_error/1 --- src/rlx_app_info.erl | 6 +- src/rlx_config.erl | 8 +-- src/rlx_depsolver.erl | 8 +-- src/rlx_depsolver_culprit.erl | 12 ++-- src/rlx_dscv_util.erl | 6 +- src/rlx_prv_discover.erl | 151 ------------------------------------------ src/rlx_prv_release.erl | 4 +- src/rlx_rel_discovery.erl | 10 +-- src/rlx_state.erl | 3 +- 9 files changed, 27 insertions(+), 181 deletions(-) delete mode 100644 src/rlx_prv_discover.erl (limited to 'src') diff --git a/src/rlx_app_info.erl b/src/rlx_app_info.erl index 931c139..ab35195 100644 --- a/src/rlx_app_info.erl +++ b/src/rlx_app_info.erl @@ -52,7 +52,7 @@ library_deps/2, link/1, link/2, - format_error/1, + format_error/2, format/2, format/1]). @@ -170,8 +170,8 @@ link(#app_info_t{link=Link}) -> link(AppInfo, NewLink) -> AppInfo#app_info_t{link=NewLink}. --spec format_error(Reason::term()) -> iolist(). -format_error({vsn_parse, AppName}) -> +-spec format_error(Reason::term(), rlx_state:t()) -> iolist(). +format_error({vsn_parse, AppName}, _) -> io_lib:format("Error parsing version for ~p", [AppName]). diff --git a/src/rlx_config.erl b/src/rlx_config.erl index c838c18..307d2b6 100644 --- a/src/rlx_config.erl +++ b/src/rlx_config.erl @@ -25,7 +25,7 @@ %% API -export([do/1, - format_error/1]). + format_error/2]). -include("relx.hrl"). @@ -46,11 +46,11 @@ do(State) -> load_config(ConfigFile, State) end. --spec format_error(Reason::term()) -> iolist(). -format_error({consult, ConfigFile, Reason}) -> +-spec format_error(Reason::term(), rlx_state:t()) -> iolist(). +format_error({consult, ConfigFile, Reason}, _) -> io_lib:format("Unable to read file ~s: ~s", [ConfigFile, file:format_error(Reason)]); -format_error({invalid_term, Term}) -> +format_error({invalid_term, Term}, _) -> io_lib:format("Invalid term in config file: ~p", [Term]). %%%=================================================================== diff --git a/src/rlx_depsolver.erl b/src/rlx_depsolver.erl index fd26145..c7f2f5c 100644 --- a/src/rlx_depsolver.erl +++ b/src/rlx_depsolver.erl @@ -76,7 +76,7 @@ -module(rlx_depsolver). %% Public Api --export([format_error/1, +-export([format_error/2, format_roots/1, format_culprits/1, format_constraint/1, @@ -326,9 +326,9 @@ filter_packages(PVPairs, RawConstraints) -> %% could not be satisfied -spec format_error({error, {unreachable_package, list()} | {invalid_constraints, [constraint()]} | - list()}) -> iolist(). -format_error(Error) -> - rlx_depsolver_culprit:format_error(Error). + list()}, rlx_state:t()) -> iolist(). +format_error(Error, State) -> + rlx_depsolver_culprit:format_error(Error, State). %% @doc Return a formatted list of roots of the dependency trees which %% could not be satisified. These may also have versions attached. diff --git a/src/rlx_depsolver_culprit.erl b/src/rlx_depsolver_culprit.erl index cf6dcb2..4448777 100644 --- a/src/rlx_depsolver_culprit.erl +++ b/src/rlx_depsolver_culprit.erl @@ -31,7 +31,7 @@ -module(rlx_depsolver_culprit). -export([search/3, - format_error/1, + format_error/2, format_version/1, format_constraint/1, format_roots/1, @@ -68,19 +68,19 @@ search(State, ActiveCons, [NewCon | Constraints]) -> search(State, [NewCon | ActiveCons], Constraints) end. -format_error({error, {unreachable_package, AppName}}) -> +format_error({error, {unreachable_package, AppName}}, _) -> ["Dependency ", format_constraint(AppName), " is specified as a dependency ", "but is not reachable by the system.\n"]; -format_error({error, {invalid_constraints, Constraints}}) -> +format_error({error, {invalid_constraints, Constraints}}, _) -> ["Invalid constraint ", add_s(Constraints), " specified ", lists:foldl(fun(Con, "") -> [io_lib:format("~p", [Con])]; (Con, Acc) -> [io_lib:format("~p", [Con]), ", " | Acc] end, "", Constraints)]; -format_error({error, Detail}) -> - format_error(Detail); -format_error(Details) when erlang:is_list(Details) -> +format_error({error, Detail}, State) -> + format_error(Detail, State); +format_error(Details, _) when erlang:is_list(Details) -> ["Unable to solve constraints, the following solutions were attempted \n\n", [[format_error_path(" ", Detail)] || Detail <- Details]]. diff --git a/src/rlx_dscv_util.erl b/src/rlx_dscv_util.erl index fefdbce..90153e9 100644 --- a/src/rlx_dscv_util.erl +++ b/src/rlx_dscv_util.erl @@ -25,7 +25,7 @@ -module(rlx_dscv_util). -export([do/2, - format_error/1]). + format_error/2]). -include("relx.hrl"). @@ -54,8 +54,8 @@ do(ProcessDir, LibDirs) -> ec_file:type(LibDir)) end, LibDirs)). --spec format_error([ErrorDetail::term()]) -> iolist(). -format_error(ErrorDetails) +-spec format_error([ErrorDetail::term()], rlx_state:t()) -> iolist(). +format_error(ErrorDetails, _) when erlang:is_list(ErrorDetails) -> [[format_detail(ErrorDetail), "\n"] || ErrorDetail <- ErrorDetails]. diff --git a/src/rlx_prv_discover.erl b/src/rlx_prv_discover.erl deleted file mode 100644 index 41e3993..0000000 --- a/src/rlx_prv_discover.erl +++ /dev/null @@ -1,151 +0,0 @@ -%% -*- erlang-indent-level: 4; indent-tabs-mode: nil; fill-column: 80 -*- -%%% Copyright 2012 Erlware, LLC. All Rights Reserved. -%%% -%%% This file is provided to you under the Apache License, -%%% Version 2.0 (the "License"); you may not use this file -%%% except in compliance with the License. You may obtain -%%% a copy of the License at -%%% -%%% http://www.apache.org/licenses/LICENSE-2.0 -%%% -%%% Unless required by applicable law or agreed to in writing, -%%% software distributed under the License is distributed on an -%%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -%%% KIND, either express or implied. See the License for the -%%% specific language governing permissions and limitations -%%% under the License. -%%%--------------------------------------------------------------------------- -%%% @author Eric Merritt -%%% @copyright (C) 2012 Erlware, LLC. -%%% -%%% @doc This provider uses the lib_dir setting of the state. It searches the -%%% Lib Dirs looking for all OTP Applications that are available. When it finds -%%% those OTP Applications it loads the information about them and adds them to -%%% the state of available apps. This implements the provider behaviour. --module(rlx_prv_discover). --behaviour(provider). - --export([init/1, - do/1, - format_error/2]). - --include("relx.hrl"). - --define(PROVIDER, discover). --define(DEPS, []). - -%%============================================================================ -%% API -%%============================================================================ - --spec init(rlx_state:t()) -> {ok, rlx_state:t()}. -init(State) -> - State1 = rlx_state:add_provider(State, providers:create([{name, ?PROVIDER}, - {module, ?MODULE}, - {bare, false}, - {deps, ?DEPS}, - {example, "build"}, - {short_desc, ""}, - {desc, ""}, - {opts, []}])), - {ok, State1}. - -%% @doc recursively dig down into the library directories specified in the state -%% looking for OTP Applications --spec do(rlx_state:t()) -> {ok, rlx_state:t()} | relx:error(). -do(State0) -> - LibDirs = get_lib_dirs(State0), - case rlx_app_discovery:do(State0, LibDirs) of - {ok, AppMeta} -> - case rlx_rel_discovery:do(State0, LibDirs, AppMeta) of - {ok, Releases} -> - State1 = rlx_state:available_apps(State0, AppMeta), - {ok, rlx_state:realized_releases(State1, lists:foldl(fun add/2, - ec_dictionary:new(ec_dict), - Releases))}; - Error -> - Error - end; - Error -> - Error - end. - -%% @doc this is here to comply with the signature. However, we do not actually -%% produce any errors and so simply return an empty string. --spec format_error(any(), rlx_state:t()) -> iolist(). -format_error(_, _) -> - "". - -%%%=================================================================== -%%% Internal Functions -%%%=================================================================== -%% @doc only add the release if its not documented in the system -add(Rel, Dict) -> - RelName = rlx_release:name(Rel), - RelVsn = rlx_release:vsn(Rel), - ec_dictionary:add({RelName, RelVsn}, Rel, Dict). - -get_lib_dirs(State) -> - LibDirs0 = rlx_state:lib_dirs(State), - case rlx_state:get(State, default_libs, true) of - false -> - LibDirs0; - true -> - lists:flatten([LibDirs0, - add_common_project_dirs(State), - add_system_lib_dir(State), - add_release_output_dir(State)]) - end. - --spec add_common_project_dirs(rlx_state:t()) -> [file:name()]. -add_common_project_dirs(State) -> - %% Check to see if there is a rebar.config. If so then look for a deps - %% dir. If both are there then we add that to the lib dirs. - case rlx_state:get(State, disable_project_subdirs, false) of - true -> - []; - false -> - Root = rlx_state:root_dir(State), - Apps = filename:join(Root, "apps"), - Lib = filename:join(Root, "lib"), - Deps = filename:join(Root, "deps"), - Rebar3Deps = filename:join(Root, "_deps"), - Ebin = filename:join(Root, "ebin"), - lists:foldl(fun(Dir, LibDirs) -> - case ec_file:exists(Dir) of - true -> - [erlang:iolist_to_binary(Dir) | LibDirs]; - false -> - LibDirs - end - end, [], [Rebar3Deps, Deps, Lib, Apps, Ebin]) - end. - --spec add_system_lib_dir(rlx_state:t()) -> [file:name()]. -add_system_lib_dir(State) -> - ExcludeSystem = rlx_state:get(State, discover_exclude_system, false), - case rlx_state:get(State, system_libs, undefined) of - undefined -> - case ExcludeSystem of - true -> - []; - false -> - erlang:iolist_to_binary(code:lib_dir()) - end; - SystemLibs -> - erlang:iolist_to_binary(SystemLibs) - end. - -add_release_output_dir(State) -> - case rlx_state:get(State, disable_discover_release_output, false) of - true -> - []; - false -> - Output = erlang:iolist_to_binary(rlx_state:base_output_dir(State)), - case ec_file:exists(erlang:binary_to_list(Output)) of - true -> - Output; - false -> - [] - end - end. diff --git a/src/rlx_prv_release.erl b/src/rlx_prv_release.erl index 02a9758..3eb59d1 100644 --- a/src/rlx_prv_release.erl +++ b/src/rlx_prv_release.erl @@ -71,9 +71,9 @@ format_error({no_releases_for, RelName}, _) -> io_lib:format("No releases exist in the system for ~s!", [RelName]); format_error({release_not_found, {RelName, RelVsn}}, _) -> io_lib:format("No releases exist in the system for ~p:~s!", [RelName, RelVsn]); -format_error({failed_solve, Error}, _) -> +format_error({failed_solve, Error}, State) -> io_lib:format("Failed to solve release:\n ~s", - [rlx_depsolver:format_error({error, Error})]). + [rlx_depsolver:format_error({error, Error}, State)]). %%%=================================================================== %%% Internal Functions diff --git a/src/rlx_rel_discovery.erl b/src/rlx_rel_discovery.erl index b7c15bc..dc6210f 100644 --- a/src/rlx_rel_discovery.erl +++ b/src/rlx_rel_discovery.erl @@ -18,14 +18,10 @@ %%% @author Eric Merritt %%% @copyright (C) 2012 Erlware, LLC. %%% -%%% @doc This provider uses the lib_dir setting of the state. It searches the -%%% Lib Dirs looking for all OTP Applications that are available. When it finds -%%% those OTP Applications it loads the information about them and adds them to -%%% the state of available apps. This implements the provider behaviour. -module(rlx_rel_discovery). -export([do/3, - format_error/1]). + format_error/2]). -include("relx.hrl"). @@ -51,8 +47,8 @@ do(State, LibDirs, AppMeta) -> resolve_rel_metadata(State, LibDirs, AppMeta) end. --spec format_error([ErrorDetail::term()]) -> iolist(). -format_error(ErrorDetails) +-spec format_error([ErrorDetail::term()], rlx_state:t()) -> iolist(). +format_error(ErrorDetails, _) when erlang:is_list(ErrorDetails) -> [[format_detail(ErrorDetail), "\n"] || ErrorDetail <- ErrorDetails]. diff --git a/src/rlx_state.erl b/src/rlx_state.erl index 550a44a..b7cb6ba 100644 --- a/src/rlx_state.erl +++ b/src/rlx_state.erl @@ -438,7 +438,8 @@ add_hook(post, {PreHooks, PostHooks}, Hook) -> -spec create_logic_providers(t()) -> t() | relx:error(). create_logic_providers(State) -> - create_all(State, [rlx_prv_discover, + create_all(State, [rlx_prv_app_discover, + rlx_prv_rel_discover, rlx_prv_overlay, rlx_prv_release, rlx_prv_assembler, -- cgit v1.2.3