From f4f96a356fcefaa2ad388eb5469c7da901846f21 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 19 Sep 2014 22:05:40 -0500 Subject: install plugins to plugins/ --- src/rebar_prv_install_deps.erl | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index d20f2b5..0752f0a 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -33,7 +33,8 @@ -include("rebar.hrl"). --export([setup_env/1]). +-export([setup_env/1, + handle_deps/2]). %% for internal use only -export([get_deps_dir/1]). @@ -65,12 +66,18 @@ init(State) -> -spec do(rebar_state:t()) -> {ok, rebar_state:t()}. do(State) -> - case rebar_state:get(State, locks, []) of - [] -> - handle_deps(State, ordsets:from_list(rebar_state:get(State, deps, []))); - Locks -> - handle_deps(State, ordsets:from_list(Locks)) - end. + ProjectApps = rebar_state:project_apps(State), + {ok, State1} = case rebar_state:get(State, locks, []) of + [] -> + handle_deps(State, ordsets:from_list(rebar_state:get(State, deps, []))); + Locks -> + handle_deps(State, ordsets:from_list(Locks)) + end, + + Source = ProjectApps ++ ordsets:to_list(rebar_state:src_deps(State1)), + {ok, Sort} = rebar_topo:sort_apps(ordsets:to_list(Source)), + {ok, rebar_state:set(State1, deps_to_build, lists:dropwhile(fun is_valid/1, Sort -- ProjectApps))}. + %% set REBAR_DEPS_DIR and ERL_LIBS environment variables setup_env(State) -> @@ -99,17 +106,12 @@ get_deps_dir(State) -> get_deps_dir(DepsDir, App) -> filename:join(DepsDir, App). -%% =================================================================== -%% Internal functions -%% =================================================================== - -spec handle_deps(rebar_state:t(), [dep()]) -> {ok, rebar_state:t()}. handle_deps(State, []) -> {ok, State}; handle_deps(State, Deps) -> %% Read in package index and dep graph {Packages, Graph} = rebar_packages:get_packages(State), - ProjectApps = rebar_state:project_apps(State), %% Split source deps form binary deps, needed to keep backwards compatibility DepsDir = get_deps_dir(State), @@ -136,14 +138,18 @@ handle_deps(State, Deps) -> end, S) end, - Source = ProjectApps ++ ordsets:to_list(rebar_state:src_deps(State2)), AllDeps = ordsets:union([ordsets:to_list(rebar_state:src_deps(State2)) ,ordsets:from_list(Solved)]), %% Sort all apps to build order State3 = rebar_state:set(State2, all_deps, AllDeps), - {ok, Sort} = rebar_topo:sort_apps(ordsets:to_list(Source)), - {ok, rebar_state:set(State3, deps_to_build, lists:dropwhile(fun is_valid/1, Sort -- ProjectApps))}. + + {ok, State3}. + + +%% =================================================================== +%% Internal functions +%% =================================================================== -spec is_valid(rebar_app_info:t()) -> boolean(). is_valid(App) -> -- cgit v1.1 From 51f1cf4aae5a22fe8974edcdf10da4e8a7b05255 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Sep 2014 09:01:03 -0500 Subject: install plugins to plugins/ --- src/rebar_prv_install_deps.erl | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 0752f0a..81acf22 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -33,8 +33,7 @@ -include("rebar.hrl"). --export([setup_env/1, - handle_deps/2]). +-export([handle_deps/2]). %% for internal use only -export([get_deps_dir/1]). @@ -78,29 +77,11 @@ do(State) -> {ok, Sort} = rebar_topo:sort_apps(ordsets:to_list(Source)), {ok, rebar_state:set(State1, deps_to_build, lists:dropwhile(fun is_valid/1, Sort -- ProjectApps))}. - -%% set REBAR_DEPS_DIR and ERL_LIBS environment variables -setup_env(State) -> - DepsDir = get_deps_dir(State), - %% include rebar's DepsDir in ERL_LIBS - Separator = case os:type() of - {win32, nt} -> - ";"; - _ -> - ":" - end, - ERL_LIBS = case os:getenv("ERL_LIBS") of - false -> - {"ERL_LIBS", DepsDir}; - PrevValue -> - {"ERL_LIBS", DepsDir ++ Separator ++ PrevValue} - end, - [{"REBAR_DEPS_DIR", DepsDir}, ERL_LIBS]. - -spec get_deps_dir(rebar_state:t()) -> file:filename_all(). get_deps_dir(State) -> BaseDir = rebar_state:get(State, base_dir, ""), - get_deps_dir(BaseDir, "deps"). + DepsDir = rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIR), + get_deps_dir(BaseDir, DepsDir). -spec get_deps_dir(file:filename_all(), rebar_state:t()) -> file:filename_all(). get_deps_dir(DepsDir, App) -> @@ -113,7 +94,7 @@ handle_deps(State, Deps) -> %% Read in package index and dep graph {Packages, Graph} = rebar_packages:get_packages(State), - %% Split source deps form binary deps, needed to keep backwards compatibility + %% Split source deps from binary deps, needed to keep backwards compatibility DepsDir = get_deps_dir(State), {SrcDeps, BinaryDeps} = parse_deps(DepsDir, Deps), State1 = rebar_state:src_deps(rebar_state:binary_deps(State, BinaryDeps), -- cgit v1.1 From 6c6480fa077065d1db77b78a49c79d9f6cf08035 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Sep 2014 09:12:36 -0500 Subject: only compile invalid plugins --- src/rebar_prv_install_deps.erl | 1 - 1 file changed, 1 deletion(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 81acf22..c86d2d1 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -124,7 +124,6 @@ handle_deps(State, Deps) -> %% Sort all apps to build order State3 = rebar_state:set(State2, all_deps, AllDeps), - {ok, State3}. -- cgit v1.1 From 1dabd217dbfbebae2f5375160551c35cd1f2a972 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Sep 2014 13:51:14 -0500 Subject: inefficient way, but safer, of checking if an app is already downloaded --- src/rebar_prv_install_deps.erl | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index c86d2d1..607aeb7 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -114,7 +114,7 @@ handle_deps(State, Deps) -> ,Packages ,Name ,Vsn), - ok = maybe_fetch(AppInfo), + ok = maybe_fetch(AppInfo, State2), AppInfo end, S) end, @@ -154,7 +154,7 @@ update_src_deps(State) -> SrcDeps = rebar_state:src_deps(State), DepsDir = get_deps_dir(State), case lists:foldl(fun(AppInfo, {SrcDepsAcc, BinaryDepsAcc}) -> - ok = maybe_fetch(AppInfo), + ok = maybe_fetch(AppInfo, State), {AppInfo1, NewSrcDeps, NewBinaryDeps} = handle_dep(DepsDir, AppInfo), {ordsets:union(ordsets:add_element(AppInfo1, SrcDepsAcc), NewSrcDeps) ,NewBinaryDeps++BinaryDepsAcc} @@ -175,16 +175,17 @@ handle_dep(DepsDir, AppInfo) -> {SrcDeps, BinaryDeps} = parse_deps(DepsDir, Deps), {AppInfo1, SrcDeps, BinaryDeps}. --spec maybe_fetch(rebar_app_info:t()) -> ok. -maybe_fetch(AppInfo) -> +-spec maybe_fetch(rebar_app_info:t(), rebar_state:t()) -> ok. +maybe_fetch(AppInfo, State) -> AppDir = rebar_app_info:dir(AppInfo), - case filelib:is_dir(AppDir) of - false -> + Apps = rebar_app_discover:find_apps([get_deps_dir(State)], all), + case rebar_app_utils:find(rebar_app_info:name(AppInfo), Apps) of + {ok, _} -> + ok; + _ -> ?INFO("Fetching ~s~n", [rebar_app_info:name(AppInfo)]), Source = rebar_app_info:source(AppInfo), - rebar_fetch:download_source(AppDir, Source); - true -> - ok + rebar_fetch:download_source(AppDir, Source) end. -spec parse_deps(binary(), [dep()]) -> {ordsets:ordset(rebar_app_info:t()), [binary_dep()]}. -- cgit v1.1 From 3924908f64dec6fdd9c8195b826453602f7b34f1 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Sep 2014 14:01:22 -0500 Subject: more efficient check for existing dep --- src/rebar_prv_install_deps.erl | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 607aeb7..ef08754 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -176,16 +176,22 @@ handle_dep(DepsDir, AppInfo) -> {AppInfo1, SrcDeps, BinaryDeps}. -spec maybe_fetch(rebar_app_info:t(), rebar_state:t()) -> ok. -maybe_fetch(AppInfo, State) -> - AppDir = rebar_app_info:dir(AppInfo), - Apps = rebar_app_discover:find_apps([get_deps_dir(State)], all), - case rebar_app_utils:find(rebar_app_info:name(AppInfo), Apps) of - {ok, _} -> +maybe_fetch(AppInfo, _State) -> + AppDir = ec_cnv:to_list(rebar_app_info:dir(AppInfo)), + %Apps = rebar_app_discover:find_apps([get_deps_dir(State)], all), + %case rebar_app_utils:find(rebar_app_info:name(AppInfo), Apps) of + case rebar_app_utils:is_app_dir(filename:absname(AppDir)++"-*") of + {true, _} -> ok; _ -> - ?INFO("Fetching ~s~n", [rebar_app_info:name(AppInfo)]), - Source = rebar_app_info:source(AppInfo), - rebar_fetch:download_source(AppDir, Source) + case rebar_app_utils:is_app_dir(filename:absname(AppDir)) of + {true, _} -> + ok; + _ -> + ?INFO("Fetching ~s~n", [rebar_app_info:name(AppInfo)]), + Source = rebar_app_info:source(AppInfo), + rebar_fetch:download_source(AppDir, Source) + end end. -spec parse_deps(binary(), [dep()]) -> {ordsets:ordset(rebar_app_info:t()), [binary_dep()]}. -- cgit v1.1 From 0649be271bd8b2db2549dbc3228bd2d6b83e8954 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Sep 2014 14:19:02 -0500 Subject: wip: update dep --- src/rebar_prv_install_deps.erl | 56 +++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index ef08754..3b78fd1 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -33,7 +33,8 @@ -include("rebar.hrl"). --export([handle_deps/2]). +-export([handle_deps/2, + handle_deps/3]). %% for internal use only -export([get_deps_dir/1]). @@ -88,9 +89,13 @@ get_deps_dir(DepsDir, App) -> filename:join(DepsDir, App). -spec handle_deps(rebar_state:t(), [dep()]) -> {ok, rebar_state:t()}. -handle_deps(State, []) -> - {ok, State}; handle_deps(State, Deps) -> + handle_deps(State, Deps, false). + +-spec handle_deps(rebar_state:t(), [dep()], boolean()) -> {ok, rebar_state:t()}. +handle_deps(State, [], _) -> + {ok, State}; +handle_deps(State, Deps, Update) -> %% Read in package index and dep graph {Packages, Graph} = rebar_packages:get_packages(State), @@ -101,7 +106,7 @@ handle_deps(State, Deps) -> SrcDeps), %% Fetch transitive src deps - State2 = update_src_deps(State1), + State2 = update_src_deps(State1, Update), Solved = case rebar_state:binary_deps(State2) of [] -> %% No binary deps []; @@ -114,7 +119,7 @@ handle_deps(State, Deps) -> ,Packages ,Name ,Vsn), - ok = maybe_fetch(AppInfo, State2), + ok = maybe_fetch(AppInfo, Update), AppInfo end, S) end, @@ -149,12 +154,12 @@ package_to_app(DepsDir, Packages, Name, Vsn) -> rebar_app_info:dir(AppInfo1, get_deps_dir(DepsDir, <>)), rebar_app_info:source(AppInfo2, Link). --spec update_src_deps(rebar_state:t()) -> rebat_state:t(). -update_src_deps(State) -> +-spec update_src_deps(rebar_state:t(), boolean()) -> rebat_state:t(). +update_src_deps(State, Update) -> SrcDeps = rebar_state:src_deps(State), DepsDir = get_deps_dir(State), case lists:foldl(fun(AppInfo, {SrcDepsAcc, BinaryDepsAcc}) -> - ok = maybe_fetch(AppInfo, State), + ok = maybe_fetch(AppInfo, Update), {AppInfo1, NewSrcDeps, NewBinaryDeps} = handle_dep(DepsDir, AppInfo), {ordsets:union(ordsets:add_element(AppInfo1, SrcDepsAcc), NewSrcDeps) ,NewBinaryDeps++BinaryDepsAcc} @@ -163,7 +168,7 @@ update_src_deps(State) -> rebar_state:src_deps(rebar_state:binary_deps(State, NewBinaryDeps), NewSrcDeps); {NewSrcDeps, NewBinaryDeps} -> State1 = rebar_state:src_deps(rebar_state:binary_deps(State, NewBinaryDeps), NewSrcDeps), - update_src_deps(State1) + update_src_deps(State1, Update) end. -spec handle_dep(binary(), rebar_state:t()) -> {[rebar_app_info:t()], [binary_dep()]}. @@ -175,23 +180,30 @@ handle_dep(DepsDir, AppInfo) -> {SrcDeps, BinaryDeps} = parse_deps(DepsDir, Deps), {AppInfo1, SrcDeps, BinaryDeps}. --spec maybe_fetch(rebar_app_info:t(), rebar_state:t()) -> ok. -maybe_fetch(AppInfo, _State) -> +-spec maybe_fetch(rebar_app_info:t(), boolean()) -> ok. +maybe_fetch(AppInfo, Update) -> AppDir = ec_cnv:to_list(rebar_app_info:dir(AppInfo)), %Apps = rebar_app_discover:find_apps([get_deps_dir(State)], all), %case rebar_app_utils:find(rebar_app_info:name(AppInfo), Apps) of - case rebar_app_utils:is_app_dir(filename:absname(AppDir)++"-*") of - {true, _} -> - ok; + Exists = case rebar_app_utils:is_app_dir(filename:absname(AppDir)++"-*") of + {true, _} -> + true; + _ -> + case rebar_app_utils:is_app_dir(filename:absname(AppDir)) of + {true, _} -> + true; + _ -> + false + end + end, + + case not Exists orelse Update of + true -> + ?INFO("Fetching ~s~n", [rebar_app_info:name(AppInfo)]), + Source = rebar_app_info:source(AppInfo), + rebar_fetch:download_source(AppDir, Source); _ -> - case rebar_app_utils:is_app_dir(filename:absname(AppDir)) of - {true, _} -> - ok; - _ -> - ?INFO("Fetching ~s~n", [rebar_app_info:name(AppInfo)]), - Source = rebar_app_info:source(AppInfo), - rebar_fetch:download_source(AppDir, Source) - end + ok end. -spec parse_deps(binary(), [dep()]) -> {ordsets:ordset(rebar_app_info:t()), [binary_dep()]}. -- cgit v1.1 From c8772ff398e43a535d6c145ce3ed0d31952f907e Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Sep 2014 22:02:02 -0500 Subject: wip: updating handling of src deps to include level in lock --- src/rebar_prv_install_deps.erl | 63 ++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 27 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 3b78fd1..03dfce4 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -69,13 +69,13 @@ do(State) -> ProjectApps = rebar_state:project_apps(State), {ok, State1} = case rebar_state:get(State, locks, []) of [] -> - handle_deps(State, ordsets:from_list(rebar_state:get(State, deps, []))); + handle_deps(State, rebar_state:get(State, deps, [])); Locks -> - handle_deps(State, ordsets:from_list(Locks)) + handle_deps(State, Locks) end, - Source = ProjectApps ++ ordsets:to_list(rebar_state:src_deps(State1)), - {ok, Sort} = rebar_topo:sort_apps(ordsets:to_list(Source)), + Source = ProjectApps ++ rebar_state:src_deps(State1), + {ok, Sort} = rebar_topo:sort_apps(Source), {ok, rebar_state:set(State1, deps_to_build, lists:dropwhile(fun is_valid/1, Sort -- ProjectApps))}. -spec get_deps_dir(rebar_state:t()) -> file:filename_all(). @@ -106,7 +106,7 @@ handle_deps(State, Deps, Update) -> SrcDeps), %% Fetch transitive src deps - State2 = update_src_deps(State1, Update), + State2 = update_src_deps(0, State1, Update), Solved = case rebar_state:binary_deps(State2) of [] -> %% No binary deps []; @@ -124,9 +124,10 @@ handle_deps(State, Deps, Update) -> end, S) end, - AllDeps = ordsets:union([ordsets:to_list(rebar_state:src_deps(State2)) - ,ordsets:from_list(Solved)]), - + AllDeps = lists:keymerge(2 + ,rebar_state:src_apps(State2) + ,Solved), + io:format("All ~p~n", [AllDeps]), %% Sort all apps to build order State3 = rebar_state:set(State2, all_deps, AllDeps), {ok, State3}. @@ -154,21 +155,28 @@ package_to_app(DepsDir, Packages, Name, Vsn) -> rebar_app_info:dir(AppInfo1, get_deps_dir(DepsDir, <>)), rebar_app_info:source(AppInfo2, Link). --spec update_src_deps(rebar_state:t(), boolean()) -> rebat_state:t(). -update_src_deps(State, Update) -> +-spec update_src_deps(integer(), rebar_state:t(), boolean()) -> rebat_state:t(). +update_src_deps(Level, State, Update) -> SrcDeps = rebar_state:src_deps(State), DepsDir = get_deps_dir(State), - case lists:foldl(fun(AppInfo, {SrcDepsAcc, BinaryDepsAcc}) -> - ok = maybe_fetch(AppInfo, Update), - {AppInfo1, NewSrcDeps, NewBinaryDeps} = handle_dep(DepsDir, AppInfo), - {ordsets:union(ordsets:add_element(AppInfo1, SrcDepsAcc), NewSrcDeps) - ,NewBinaryDeps++BinaryDepsAcc} - end, {ordsets:new(), rebar_state:binary_deps(State)}, SrcDeps) of - {NewSrcDeps, NewBinaryDeps} when length(SrcDeps) =:= length(NewSrcDeps) -> - rebar_state:src_deps(rebar_state:binary_deps(State, NewBinaryDeps), NewSrcDeps); - {NewSrcDeps, NewBinaryDeps} -> - State1 = rebar_state:src_deps(rebar_state:binary_deps(State, NewBinaryDeps), NewSrcDeps), - update_src_deps(State1, Update) + case lists:foldl(fun(AppInfo, {SrcDepsAcc, BinaryDepsAcc, StateAcc}) -> + case maybe_fetch(AppInfo, Update) of + true -> + {AppInfo1, NewSrcDeps, NewBinaryDeps} = + handle_dep(DepsDir, AppInfo), + AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), + {NewSrcDeps ++ SrcDepsAcc + ,NewBinaryDeps++BinaryDepsAcc + ,rebar_state:src_apps(StateAcc, AppInfo2)}; + false -> + {SrcDepsAcc, BinaryDepsAcc, State} + end + end, {[], rebar_state:binary_deps(State), State}, SrcDeps) of + {NewSrcDeps, NewBinaryDeps, State1} when length(SrcDeps) =:= length(NewSrcDeps) -> + rebar_state:src_deps(rebar_state:binary_deps(State1, NewBinaryDeps), NewSrcDeps); + {NewSrcDeps, NewBinaryDeps, State1} -> + State2 = rebar_state:src_deps(rebar_state:binary_deps(State1, NewBinaryDeps), NewSrcDeps), + update_src_deps(Level+1, State2, Update) end. -spec handle_dep(binary(), rebar_state:t()) -> {[rebar_app_info:t()], [binary_dep()]}. @@ -180,7 +188,7 @@ handle_dep(DepsDir, AppInfo) -> {SrcDeps, BinaryDeps} = parse_deps(DepsDir, Deps), {AppInfo1, SrcDeps, BinaryDeps}. --spec maybe_fetch(rebar_app_info:t(), boolean()) -> ok. +-spec maybe_fetch(rebar_app_info:t(), boolean()) -> boolean(). maybe_fetch(AppInfo, Update) -> AppDir = ec_cnv:to_list(rebar_app_info:dir(AppInfo)), %Apps = rebar_app_discover:find_apps([get_deps_dir(State)], all), @@ -201,12 +209,13 @@ maybe_fetch(AppInfo, Update) -> true -> ?INFO("Fetching ~s~n", [rebar_app_info:name(AppInfo)]), Source = rebar_app_info:source(AppInfo), - rebar_fetch:download_source(AppDir, Source); + rebar_fetch:download_source(AppDir, Source), + true; _ -> - ok + false end. --spec parse_deps(binary(), [dep()]) -> {ordsets:ordset(rebar_app_info:t()), [binary_dep()]}. +-spec parse_deps(binary(), [dep()]) -> {[rebar_app_info:t()], [binary_dep()]}. parse_deps(DepsDir, Deps) -> lists:foldl(fun({Name, Vsn}, {SrcDepsAcc, BinaryDepsAcc}) -> {SrcDepsAcc, [parse_goal(ec_cnv:to_binary(Name) @@ -222,8 +231,8 @@ parse_deps(DepsDir, Deps) -> rebar_app_info:new(Name, Vsn, Dir) end, Dep1 = rebar_app_info:source(Dep, Source), - {ordsets:add_element(Dep1, SrcDepsAcc), BinaryDepsAcc} - end, {ordsets:new(), []}, Deps). + {[Dep1 | SrcDepsAcc], BinaryDepsAcc} + end, {[], []}, Deps). -spec parse_goal(binary(), binary()) -> binary_dep(). parse_goal(Name, Constraint) -> -- cgit v1.1 From 6356112cbbb32b09dd2f94ea856c3cbd32b1c085 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 21 Sep 2014 09:19:38 -0500 Subject: more dialyzer fun. no likey opaque types --- src/rebar_prv_install_deps.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rebar_prv_install_deps.erl') 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)), -- cgit v1.1 From 1854276fb54b93654c0b2a300978f6e97973c857 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 21 Sep 2014 11:32:49 -0500 Subject: down to last 2 dialyzer errors --- src/rebar_prv_install_deps.erl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 06e02cc..daae204 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -84,7 +84,7 @@ get_deps_dir(State) -> DepsDir = rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIR), get_deps_dir(BaseDir, DepsDir). --spec get_deps_dir(file:filename_all(), rebar_state:t()) -> file:filename_all(). +-spec get_deps_dir(file:filename_all(), file:filename_all()) -> file:filename_all(). get_deps_dir(DepsDir, App) -> filename:join(DepsDir, App). @@ -119,7 +119,7 @@ handle_deps(State, Deps, Update) -> ,Packages ,Name ,Vsn), - ok = maybe_fetch(AppInfo, Update), + maybe_fetch(AppInfo, Update), AppInfo end, S) end, @@ -141,9 +141,14 @@ handle_deps(State, Deps, Update) -> is_valid(App) -> rebar_app_info:valid(App). --spec package_to_app(file:name(), rlx_depsolver:t(), binary(), binary()) -> rebar_app_info:t(). +-spec package_to_app(file:filename_all(), dict:dict(), rlx_depsolver:name(), rlx_depsolver:vsn()) -> rebar_app_info:t(). package_to_app(DepsDir, Packages, Name, Vsn) -> - FmtVsn = ec_cnv:to_binary(rlx_depsolver:format_version(Vsn)), + FmtVsn = case Vsn of + 'NO_VSN' -> + <<"NO_VSN">>; + _ -> + iolist_to_binary(rlx_depsolver:format_version(Vsn)) + end, {ok, P} = dict:find({Name, FmtVsn}, Packages), PkgDeps = proplists:get_value(<<"deps">>, P), @@ -155,7 +160,7 @@ package_to_app(DepsDir, Packages, Name, Vsn) -> rebar_app_info:dir(AppInfo1, get_deps_dir(DepsDir, <>)), rebar_app_info:source(AppInfo2, Link). --spec update_src_deps(integer(), rebar_state:t(), boolean()) -> rebat_state:t(). +-spec update_src_deps(integer(), rebar_state:t(), boolean()) -> rebar_state:t(). update_src_deps(Level, State, Update) -> SrcDeps = rebar_state:src_deps(State), DepsDir = get_deps_dir(State), @@ -179,7 +184,8 @@ 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(), [rebar_app_info:t()], [binary_dep()]}. +-spec handle_dep(file:filename_all(), rebar_app_info: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)), -- cgit v1.1 From ffe8924f3b0f6fd68fec197e11a4229c0542b0b5 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 21 Sep 2014 12:01:30 -0500 Subject: fixed up a few unknown types --- src/rebar_prv_install_deps.erl | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index daae204..9180cc4 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -114,11 +114,10 @@ handle_deps(State, Deps, Update) -> %% Find binary deps needed {ok, S} = rlx_depsolver:solve(Graph, BinaryDeps1), %% Create app_info record for each binary dep - lists:map(fun({Name, Vsn}) -> + lists:map(fun(Pkg) -> AppInfo = package_to_app(DepsDir ,Packages - ,Name - ,Vsn), + ,Pkg), maybe_fetch(AppInfo, Update), AppInfo end, S) @@ -127,7 +126,7 @@ handle_deps(State, Deps, Update) -> AllDeps = lists:keymerge(2 ,rebar_state:src_apps(State2) ,Solved), - io:format("All ~p~n", [AllDeps]), + %% Sort all apps to build order State3 = rebar_state:set(State2, all_deps, AllDeps), {ok, State3}. @@ -141,15 +140,11 @@ handle_deps(State, Deps, Update) -> is_valid(App) -> rebar_app_info:valid(App). --spec package_to_app(file:filename_all(), dict:dict(), rlx_depsolver:name(), rlx_depsolver:vsn()) -> rebar_app_info:t(). -package_to_app(DepsDir, Packages, Name, Vsn) -> - FmtVsn = case Vsn of - 'NO_VSN' -> - <<"NO_VSN">>; - _ -> - iolist_to_binary(rlx_depsolver:format_version(Vsn)) - end, - +-spec package_to_app(file:filename_all(), dict:dict(), + rlx_depsolver:pkg()) -> rebar_app_info:t(). +package_to_app(DepsDir, Packages, Pkg={_, Vsn}) -> + Name = ec_cnv:to_binary(rlx_depsolver:dep_pkg(Pkg)), + FmtVsn = iolist_to_binary(rlx_depsolver:format_version(Vsn)), {ok, P} = dict:find({Name, FmtVsn}, Packages), PkgDeps = proplists:get_value(<<"deps">>, P), Link = proplists:get_value(<<"link">>, P), -- cgit v1.1 From 6efdd8cbfea393e8b9c2a8b9029b53f25aa0cef4 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Thu, 25 Sep 2014 13:38:33 -0500 Subject: fix namespaced types for pre-17 otp --- src/rebar_prv_install_deps.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 9180cc4..1c3049c 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -140,7 +140,7 @@ handle_deps(State, Deps, Update) -> is_valid(App) -> rebar_app_info:valid(App). --spec package_to_app(file:filename_all(), dict:dict(), +-spec package_to_app(file:filename_all(), rebar_dict(), rlx_depsolver:pkg()) -> rebar_app_info:t(). package_to_app(DepsDir, Packages, Pkg={_, Vsn}) -> Name = ec_cnv:to_binary(rlx_depsolver:dep_pkg(Pkg)), -- cgit v1.1 From e392bfaec3942e63a88bb86a676fe4755ba84ce3 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 26 Sep 2014 08:22:24 -0500 Subject: update src dep works except for removed transitive deps --- src/rebar_prv_install_deps.erl | 51 +++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 11 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 1c3049c..2498215 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -92,7 +92,7 @@ get_deps_dir(DepsDir, App) -> handle_deps(State, Deps) -> handle_deps(State, Deps, false). --spec handle_deps(rebar_state:t(), [dep()], boolean()) -> {ok, rebar_state:t()}. +-spec handle_deps(rebar_state:t(), [dep()], false | {true, integer()}) -> {ok, rebar_state:t()}. handle_deps(State, [], _) -> {ok, State}; handle_deps(State, Deps, Update) -> @@ -160,16 +160,35 @@ update_src_deps(Level, State, Update) -> SrcDeps = rebar_state:src_deps(State), DepsDir = get_deps_dir(State), case lists:foldl(fun(AppInfo, {SrcDepsAcc, BinaryDepsAcc, StateAcc}) -> - case maybe_fetch(AppInfo, Update) of - true -> - {AppInfo1, NewSrcDeps, NewBinaryDeps} = - handle_dep(DepsDir, AppInfo), - AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), - {NewSrcDeps ++ SrcDepsAcc - ,NewBinaryDeps++BinaryDepsAcc - ,rebar_state:src_apps(StateAcc, AppInfo2)}; - false -> - {SrcDepsAcc, BinaryDepsAcc, State} + Name = rebar_app_info:name(AppInfo), + Locks = rebar_state:get(State, locks, []), + {_, _, _, DepLevel} = lists:keyfind(Name, 1, Locks), + case Update of + {true, UpdateName, UpdateLevel} when UpdateLevel < DepLevel + ; Name =:= UpdateName -> + case maybe_fetch(AppInfo, true) of + true -> + {AppInfo1, NewSrcDeps, NewBinaryDeps} = + handle_dep(DepsDir, AppInfo), + AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), + {NewSrcDeps ++ SrcDepsAcc + ,NewBinaryDeps++BinaryDepsAcc + ,rebar_state:src_apps(StateAcc, AppInfo2)}; + false -> + {SrcDepsAcc, BinaryDepsAcc, State} + end; + _ -> + case maybe_fetch(AppInfo, false) of + true -> + {AppInfo1, NewSrcDeps, NewBinaryDeps} = + handle_dep(DepsDir, AppInfo), + AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), + {NewSrcDeps ++ SrcDepsAcc + ,NewBinaryDeps++BinaryDepsAcc + ,rebar_state:src_apps(StateAcc, AppInfo2)}; + false -> + {SrcDepsAcc, BinaryDepsAcc, State} + end end end, {[], rebar_state:binary_deps(State), State}, SrcDeps) of {NewSrcDeps, NewBinaryDeps, State1} when length(SrcDeps) =:= length(NewSrcDeps) -> @@ -232,6 +251,16 @@ parse_deps(DepsDir, Deps) -> rebar_app_info:new(Name, Vsn, Dir) end, Dep1 = rebar_app_info:source(Dep, Source), + {[Dep1 | SrcDepsAcc], BinaryDepsAcc}; + ({Name, Vsn, Source, _Level}, {SrcDepsAcc, BinaryDepsAcc}) when is_tuple (Source) -> + Dir = ec_cnv:to_list(get_deps_dir(DepsDir, Name)), + {ok, Dep} = case rebar_app_info:discover(Dir) of + {ok, App} -> + {ok, App}; + not_found -> + rebar_app_info:new(Name, Vsn, Dir) + end, + Dep1 = rebar_app_info:source(Dep, Source), {[Dep1 | SrcDepsAcc], BinaryDepsAcc} end, {[], []}, Deps). -- cgit v1.1 From 3f9ff5a30221919b1ce4f65bbefcebe360c09ecb Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 26 Sep 2014 09:22:25 -0500 Subject: fix compilation order --- src/rebar_prv_install_deps.erl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 2498215..de4be27 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -74,7 +74,7 @@ do(State) -> handle_deps(State, Locks) end, - Source = ProjectApps ++ rebar_state:src_deps(State1), + Source = ProjectApps ++ rebar_state:get(State1, all_deps), {ok, Sort} = rebar_topo:sort_apps(Source), {ok, rebar_state:set(State1, deps_to_build, lists:dropwhile(fun is_valid/1, Sort -- ProjectApps))}. @@ -123,15 +123,14 @@ handle_deps(State, Deps, Update) -> end, S) end, - AllDeps = lists:keymerge(2 - ,rebar_state:src_apps(State2) - ,Solved), + AllDeps = lists:keymerge(2, lists:keymerge(2 + ,rebar_state:src_apps(State2) + ,Solved), SrcDeps), %% Sort all apps to build order State3 = rebar_state:set(State2, all_deps, AllDeps), {ok, State3}. - %% =================================================================== %% Internal functions %% =================================================================== -- cgit v1.1 From 1549b11b88dca340a1e471775d8387ca94e377e5 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 26 Sep 2014 19:51:45 -0500 Subject: getting closer --- src/rebar_prv_install_deps.erl | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index de4be27..8071382 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -74,7 +74,7 @@ do(State) -> handle_deps(State, Locks) end, - Source = ProjectApps ++ rebar_state:get(State1, all_deps), + Source = ProjectApps ++ rebar_state:src_deps(State1), {ok, Sort} = rebar_topo:sort_apps(Source), {ok, rebar_state:set(State1, deps_to_build, lists:dropwhile(fun is_valid/1, Sort -- ProjectApps))}. @@ -151,7 +151,7 @@ package_to_app(DepsDir, Packages, Pkg={_, Vsn}) -> {ok, AppInfo} = rebar_app_info:new(Name, FmtVsn), AppInfo1 = rebar_app_info:deps(AppInfo, PkgDeps), AppInfo2 = - rebar_app_info:dir(AppInfo1, get_deps_dir(DepsDir, <>)), + rebar_app_info:dir(AppInfo1, get_deps_dir(DepsDir, Name)), rebar_app_info:source(AppInfo2, Link). -spec update_src_deps(integer(), rebar_state:t(), boolean()) -> rebar_state:t(). @@ -161,18 +161,23 @@ update_src_deps(Level, State, Update) -> case lists:foldl(fun(AppInfo, {SrcDepsAcc, BinaryDepsAcc, StateAcc}) -> Name = rebar_app_info:name(AppInfo), Locks = rebar_state:get(State, locks, []), - {_, _, _, DepLevel} = lists:keyfind(Name, 1, Locks), case Update of - {true, UpdateName, UpdateLevel} when UpdateLevel < DepLevel - ; Name =:= UpdateName -> - case maybe_fetch(AppInfo, true) of + {true, UpdateName, UpdateLevel} -> + {_, _, _, DepLevel} = lists:keyfind(Name, 1, Locks), + case UpdateLevel < DepLevel + orelse Name =:= UpdateName of true -> - {AppInfo1, NewSrcDeps, NewBinaryDeps} = - handle_dep(DepsDir, AppInfo), - AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), - {NewSrcDeps ++ SrcDepsAcc - ,NewBinaryDeps++BinaryDepsAcc - ,rebar_state:src_apps(StateAcc, AppInfo2)}; + case maybe_fetch(AppInfo, true) of + true -> + {AppInfo1, NewSrcDeps, NewBinaryDeps} = + handle_dep(DepsDir, AppInfo), + AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), + {NewSrcDeps ++ SrcDepsAcc + ,NewBinaryDeps++BinaryDepsAcc + ,rebar_state:src_apps(StateAcc, AppInfo2)}; + false -> + {SrcDepsAcc, BinaryDepsAcc, State} + end; false -> {SrcDepsAcc, BinaryDepsAcc, State} end; @@ -190,10 +195,10 @@ update_src_deps(Level, State, Update) -> end end end, {[], rebar_state:binary_deps(State), State}, SrcDeps) of - {NewSrcDeps, NewBinaryDeps, State1} when length(SrcDeps) =:= length(NewSrcDeps) -> - rebar_state:src_deps(rebar_state:binary_deps(State1, NewBinaryDeps), NewSrcDeps); - {NewSrcDeps, NewBinaryDeps, State1} -> - State2 = rebar_state:src_deps(rebar_state:binary_deps(State1, NewBinaryDeps), NewSrcDeps), + {[], NewBinaryDeps, State1} -> + rebar_state:binary_deps(State1, NewBinaryDeps); + {_NewSrcDeps, NewBinaryDeps, State1} -> + State2 = rebar_state:binary_deps(State1, NewBinaryDeps), update_src_deps(Level+1, State2, Update) end. -- cgit v1.1 From e9a3396e56679a11ac1caa3b47f1f196f0307d72 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 27 Sep 2014 14:12:11 -0500 Subject: return error messages from providers --- src/rebar_prv_install_deps.erl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 8071382..0092eaa 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -64,7 +64,7 @@ init(State) -> opts = []}), {ok, State1}. --spec do(rebar_state:t()) -> {ok, rebar_state:t()}. +-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do(State) -> ProjectApps = rebar_state:project_apps(State), {ok, State1} = case rebar_state:get(State, locks, []) of @@ -123,9 +123,9 @@ handle_deps(State, Deps, Update) -> end, S) end, - AllDeps = lists:keymerge(2, lists:keymerge(2 - ,rebar_state:src_apps(State2) - ,Solved), SrcDeps), + AllDeps = lists:ukeymerge(2 + ,lists:ukeysort(2, rebar_state:src_apps(State2)) + ,lists:ukeysort(2, Solved)), %% Sort all apps to build order State3 = rebar_state:set(State2, all_deps, AllDeps), @@ -191,7 +191,8 @@ update_src_deps(Level, State, Update) -> ,NewBinaryDeps++BinaryDepsAcc ,rebar_state:src_apps(StateAcc, AppInfo2)}; false -> - {SrcDepsAcc, BinaryDepsAcc, State} + AppInfo1 = rebar_app_info:dep_level(AppInfo, Level), + {SrcDepsAcc, BinaryDepsAcc, rebar_state:src_apps(StateAcc, AppInfo1)} end end end, {[], rebar_state:binary_deps(State), State}, SrcDeps) of -- cgit v1.1 From 955f582a3ea6bb89b7b5df8ccdcbf48ab5fc815c Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 28 Sep 2014 17:27:31 -0500 Subject: fix for downloading transitive source deps --- src/rebar_prv_install_deps.erl | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 0092eaa..26d1712 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -74,7 +74,7 @@ do(State) -> handle_deps(State, Locks) end, - Source = ProjectApps ++ rebar_state:src_deps(State1), + Source = ProjectApps ++ rebar_state:src_apps(State1), {ok, Sort} = rebar_topo:sort_apps(Source), {ok, rebar_state:set(State1, deps_to_build, lists:dropwhile(fun is_valid/1, Sort -- ProjectApps))}. @@ -191,16 +191,21 @@ update_src_deps(Level, State, Update) -> ,NewBinaryDeps++BinaryDepsAcc ,rebar_state:src_apps(StateAcc, AppInfo2)}; false -> - AppInfo1 = rebar_app_info:dep_level(AppInfo, Level), - {SrcDepsAcc, BinaryDepsAcc, rebar_state:src_apps(StateAcc, AppInfo1)} + {AppInfo1, NewSrcDeps, NewBinaryDeps} = + handle_dep(DepsDir, AppInfo), + AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), + {NewSrcDeps ++ SrcDepsAcc + ,NewBinaryDeps++BinaryDepsAcc + ,rebar_state:src_apps(StateAcc, AppInfo2)} end end end, {[], rebar_state:binary_deps(State), State}, SrcDeps) of {[], NewBinaryDeps, State1} -> rebar_state:binary_deps(State1, NewBinaryDeps); - {_NewSrcDeps, NewBinaryDeps, State1} -> + {NewSrcDeps, NewBinaryDeps, State1} -> State2 = rebar_state:binary_deps(State1, NewBinaryDeps), - update_src_deps(Level+1, State2, Update) + State3 = rebar_state:src_deps(State2, NewSrcDeps), + update_src_deps(Level+1, State3, Update) end. -spec handle_dep(file:filename_all(), rebar_app_info:t()) -> -- cgit v1.1 From f8feb56bb5d9faf6bdc1af8c411aadc8c727ada4 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Tue, 30 Sep 2014 22:14:07 -0500 Subject: refactor bc supporting source deps from central repo now --- src/rebar_prv_install_deps.erl | 76 +++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 26d1712..7d0d751 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -44,9 +44,9 @@ -define(DEPS, [app_discovery]). -type src_dep() :: {atom(), string(), {atom(), string(), string()}}. --type binary_dep() :: {atom(), binary()} | atom(). +-type pkg_dep() :: {atom(), binary()} | atom(). --type dep() :: src_dep() | binary_dep(). +-type dep() :: src_dep() | pkg_dep(). %% =================================================================== %% Public API @@ -99,21 +99,21 @@ handle_deps(State, Deps, Update) -> %% Read in package index and dep graph {Packages, Graph} = rebar_packages:get_packages(State), - %% Split source deps from binary deps, needed to keep backwards compatibility + %% Split source deps from pkg deps, needed to keep backwards compatibility DepsDir = get_deps_dir(State), - {SrcDeps, BinaryDeps} = parse_deps(DepsDir, Deps), - State1 = rebar_state:src_deps(rebar_state:binary_deps(State, BinaryDeps), + {SrcDeps, PkgDeps} = parse_deps(DepsDir, Deps), + State1 = rebar_state:src_deps(rebar_state:pkg_deps(State, PkgDeps), SrcDeps), %% Fetch transitive src deps State2 = update_src_deps(0, State1, Update), - Solved = case rebar_state:binary_deps(State2) of - [] -> %% No binary deps + Solved = case rebar_state:pkg_deps(State2) of + [] -> %% No pkg deps []; - BinaryDeps1 -> - %% Find binary deps needed - {ok, S} = rlx_depsolver:solve(Graph, BinaryDeps1), - %% Create app_info record for each binary dep + PkgDeps1 -> + %% Find pkg deps needed + {ok, S} = rlx_depsolver:solve(Graph, PkgDeps1), + %% Create app_info record for each pkg dep lists:map(fun(Pkg) -> AppInfo = package_to_app(DepsDir ,Packages @@ -158,7 +158,7 @@ package_to_app(DepsDir, Packages, Pkg={_, Vsn}) -> update_src_deps(Level, State, Update) -> SrcDeps = rebar_state:src_deps(State), DepsDir = get_deps_dir(State), - case lists:foldl(fun(AppInfo, {SrcDepsAcc, BinaryDepsAcc, StateAcc}) -> + case lists:foldl(fun(AppInfo, {SrcDepsAcc, PkgDepsAcc, StateAcc}) -> Name = rebar_app_info:name(AppInfo), Locks = rebar_state:get(State, locks, []), case Update of @@ -169,54 +169,54 @@ update_src_deps(Level, State, Update) -> true -> case maybe_fetch(AppInfo, true) of true -> - {AppInfo1, NewSrcDeps, NewBinaryDeps} = + {AppInfo1, NewSrcDeps, NewPkgDeps} = handle_dep(DepsDir, AppInfo), AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), {NewSrcDeps ++ SrcDepsAcc - ,NewBinaryDeps++BinaryDepsAcc + ,NewPkgDeps++PkgDepsAcc ,rebar_state:src_apps(StateAcc, AppInfo2)}; false -> - {SrcDepsAcc, BinaryDepsAcc, State} + {SrcDepsAcc, PkgDepsAcc, State} end; false -> - {SrcDepsAcc, BinaryDepsAcc, State} + {SrcDepsAcc, PkgDepsAcc, State} end; _ -> case maybe_fetch(AppInfo, false) of true -> - {AppInfo1, NewSrcDeps, NewBinaryDeps} = + {AppInfo1, NewSrcDeps, NewPkgDeps} = handle_dep(DepsDir, AppInfo), AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), {NewSrcDeps ++ SrcDepsAcc - ,NewBinaryDeps++BinaryDepsAcc + ,NewPkgDeps++PkgDepsAcc ,rebar_state:src_apps(StateAcc, AppInfo2)}; false -> - {AppInfo1, NewSrcDeps, NewBinaryDeps} = + {AppInfo1, NewSrcDeps, NewPkgDeps} = handle_dep(DepsDir, AppInfo), AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), {NewSrcDeps ++ SrcDepsAcc - ,NewBinaryDeps++BinaryDepsAcc + ,NewPkgDeps++PkgDepsAcc ,rebar_state:src_apps(StateAcc, AppInfo2)} end end - end, {[], rebar_state:binary_deps(State), State}, SrcDeps) of - {[], NewBinaryDeps, State1} -> - rebar_state:binary_deps(State1, NewBinaryDeps); - {NewSrcDeps, NewBinaryDeps, State1} -> - State2 = rebar_state:binary_deps(State1, NewBinaryDeps), + end, {[], rebar_state:pkg_deps(State), State}, SrcDeps) of + {[], NewPkgDeps, State1} -> + rebar_state:pkg_deps(State1, NewPkgDeps); + {NewSrcDeps, NewPkgDeps, State1} -> + State2 = rebar_state:pkg_deps(State1, NewPkgDeps), State3 = rebar_state:src_deps(State2, NewSrcDeps), update_src_deps(Level+1, State3, Update) end. -spec handle_dep(file:filename_all(), rebar_app_info:t()) -> - {rebar_app_info:t(), [rebar_app_info:t()], [binary_dep()]}. + {rebar_app_info:t(), [rebar_app_info:t()], [pkg_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)), Deps = rebar_state:get(S, deps, []), AppInfo1 = rebar_app_info:deps(AppInfo, rebar_state:deps_names(S)), - {SrcDeps, BinaryDeps} = parse_deps(DepsDir, Deps), - {AppInfo1, SrcDeps, BinaryDeps}. + {SrcDeps, PkgDeps} = parse_deps(DepsDir, Deps), + {AppInfo1, SrcDeps, PkgDeps}. -spec maybe_fetch(rebar_app_info:t(), boolean()) -> boolean(). maybe_fetch(AppInfo, Update) -> @@ -245,14 +245,14 @@ maybe_fetch(AppInfo, Update) -> false end. --spec parse_deps(binary(), [dep()]) -> {[rebar_app_info:t()], [binary_dep()]}. +-spec parse_deps(binary(), [dep()]) -> {[rebar_app_info:t()], [pkg_dep()]}. parse_deps(DepsDir, Deps) -> - lists:foldl(fun({Name, Vsn}, {SrcDepsAcc, BinaryDepsAcc}) -> + lists:foldl(fun({Name, Vsn}, {SrcDepsAcc, PkgDepsAcc}) -> {SrcDepsAcc, [parse_goal(ec_cnv:to_binary(Name) - ,ec_cnv:to_binary(Vsn)) | BinaryDepsAcc]}; - (Name, {SrcDepsAcc, BinaryDepsAcc}) when is_atom(Name) -> - {SrcDepsAcc, [ec_cnv:to_binary(Name) | BinaryDepsAcc]}; - ({Name, Vsn, Source}, {SrcDepsAcc, BinaryDepsAcc}) when is_tuple (Source) -> + ,ec_cnv:to_binary(Vsn)) | PkgDepsAcc]}; + (Name, {SrcDepsAcc, PkgDepsAcc}) when is_atom(Name) -> + {SrcDepsAcc, [ec_cnv:to_binary(Name) | PkgDepsAcc]}; + ({Name, Vsn, Source}, {SrcDepsAcc, PkgDepsAcc}) when is_tuple (Source) -> Dir = ec_cnv:to_list(get_deps_dir(DepsDir, Name)), {ok, Dep} = case rebar_app_info:discover(Dir) of {ok, App} -> @@ -261,8 +261,8 @@ parse_deps(DepsDir, Deps) -> rebar_app_info:new(Name, Vsn, Dir) end, Dep1 = rebar_app_info:source(Dep, Source), - {[Dep1 | SrcDepsAcc], BinaryDepsAcc}; - ({Name, Vsn, Source, _Level}, {SrcDepsAcc, BinaryDepsAcc}) when is_tuple (Source) -> + {[Dep1 | SrcDepsAcc], PkgDepsAcc}; + ({Name, Vsn, Source, _Level}, {SrcDepsAcc, PkgDepsAcc}) when is_tuple (Source) -> Dir = ec_cnv:to_list(get_deps_dir(DepsDir, Name)), {ok, Dep} = case rebar_app_info:discover(Dir) of {ok, App} -> @@ -271,10 +271,10 @@ parse_deps(DepsDir, Deps) -> rebar_app_info:new(Name, Vsn, Dir) end, Dep1 = rebar_app_info:source(Dep, Source), - {[Dep1 | SrcDepsAcc], BinaryDepsAcc} + {[Dep1 | SrcDepsAcc], PkgDepsAcc} end, {[], []}, Deps). --spec parse_goal(binary(), binary()) -> binary_dep(). +-spec parse_goal(binary(), binary()) -> pkg_dep(). parse_goal(Name, Constraint) -> case re:run(Constraint, "([^\\d]*)(\\d.*)", [{capture, [1,2], binary}]) of {match, [<<>>, Vsn]} -> -- cgit v1.1 From b37a5ae611aaf6b84a046fbe716f40c2aa8c75d8 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 3 Oct 2014 06:33:33 -0500 Subject: move providers to separate app --- src/rebar_prv_install_deps.erl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 7d0d751..8b56ac3 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -26,7 +26,7 @@ %% ------------------------------------------------------------------- -module(rebar_prv_install_deps). --behaviour(rebar_provider). +-behaviour(provider). -export([init/1, do/1]). @@ -54,14 +54,14 @@ -spec init(rebar_state:t()) -> {ok, rebar_state:t()}. init(State) -> - State1 = rebar_state:add_provider(State, #provider{name = ?PROVIDER, - provider_impl = ?MODULE, - bare = true, - deps = ?DEPS, - example = undefined, - short_desc = "Install dependencies", - desc = info("Install dependencies"), - opts = []}), + State1 = rebar_state:add_provider(State, providers:create([{name, ?PROVIDER}, + {module, ?MODULE}, + {bare, true}, + {deps, ?DEPS}, + {example, undefined}, + {short_desc, "Install dependencies"}, + {desc, info("Install dependencies")}, + {opts, []}])), {ok, State1}. -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. -- cgit v1.1 From f1a0249bcf12f08b7aae21aec373fec4cd583dbe Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Mon, 13 Oct 2014 16:23:50 -0500 Subject: preliminary _checkouts/ support --- src/rebar_prv_install_deps.erl | 68 +++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 28 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 8b56ac3..6cd004c 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -75,8 +75,12 @@ do(State) -> end, Source = ProjectApps ++ rebar_state:src_apps(State1), - {ok, Sort} = rebar_topo:sort_apps(Source), - {ok, rebar_state:set(State1, deps_to_build, lists:dropwhile(fun is_valid/1, Sort -- ProjectApps))}. + case rebar_topo:sort_apps(Source) of + {ok, Sort} -> + {ok, rebar_state:set(State1, deps_to_build, lists:dropwhile(fun is_valid/1, Sort -- ProjectApps))}; + {error, Error} -> + {error, Error} + end. -spec get_deps_dir(rebar_state:t()) -> file:filename_all(). get_deps_dir(State) -> @@ -114,19 +118,22 @@ handle_deps(State, Deps, Update) -> %% Find pkg deps needed {ok, S} = rlx_depsolver:solve(Graph, PkgDeps1), %% Create app_info record for each pkg dep - lists:map(fun(Pkg) -> - AppInfo = package_to_app(DepsDir - ,Packages - ,Pkg), - maybe_fetch(AppInfo, Update), - AppInfo - end, S) + lists:flatmap(fun(Pkg) -> + AppInfo = package_to_app(DepsDir + ,Packages + ,Pkg), + case maybe_fetch(AppInfo, Update) of + false -> + []; + true -> + AppInfo + end + end, S) end, AllDeps = lists:ukeymerge(2 ,lists:ukeysort(2, rebar_state:src_apps(State2)) ,lists:ukeysort(2, Solved)), - %% Sort all apps to build order State3 = rebar_state:set(State2, all_deps, AllDeps), {ok, State3}. @@ -221,28 +228,33 @@ handle_dep(DepsDir, AppInfo) -> -spec maybe_fetch(rebar_app_info:t(), boolean()) -> boolean(). maybe_fetch(AppInfo, Update) -> AppDir = ec_cnv:to_list(rebar_app_info:dir(AppInfo)), - %Apps = rebar_app_discover:find_apps([get_deps_dir(State)], all), - %case rebar_app_utils:find(rebar_app_info:name(AppInfo), Apps) of - Exists = case rebar_app_utils:is_app_dir(filename:absname(AppDir)++"-*") of - {true, _} -> - true; - _ -> - case rebar_app_utils:is_app_dir(filename:absname(AppDir)) of + Apps = rebar_app_discover:find_apps(["_checkouts"], all), + case rebar_app_utils:find(rebar_app_info:name(AppInfo), Apps) of + {ok, _} -> + %% Don't fetch dep if it exists in the _checkouts dir + false; + error -> + Exists = case rebar_app_utils:is_app_dir(filename:absname(AppDir)++"-*") of {true, _} -> true; _ -> - false - end - end, + case rebar_app_utils:is_app_dir(filename:absname(AppDir)) of + {true, _} -> + true; + _ -> + false + end + end, - case not Exists orelse Update of - true -> - ?INFO("Fetching ~s~n", [rebar_app_info:name(AppInfo)]), - Source = rebar_app_info:source(AppInfo), - rebar_fetch:download_source(AppDir, Source), - true; - _ -> - false + case not Exists orelse Update of + true -> + ?INFO("Fetching ~s~n", [rebar_app_info:name(AppInfo)]), + Source = rebar_app_info:source(AppInfo), + rebar_fetch:download_source(AppDir, Source), + true; + _ -> + false + end end. -spec parse_deps(binary(), [dep()]) -> {[rebar_app_info:t()], [pkg_dep()]}. -- cgit v1.1 From 141d34a5d01216b7e918b07c22ee998766217b6d Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Thu, 16 Oct 2014 11:15:37 -0500 Subject: remove unused utils functions --- src/rebar_prv_install_deps.erl | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 6cd004c..a717e5f 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -118,17 +118,12 @@ handle_deps(State, Deps, Update) -> %% Find pkg deps needed {ok, S} = rlx_depsolver:solve(Graph, PkgDeps1), %% Create app_info record for each pkg dep - lists:flatmap(fun(Pkg) -> - AppInfo = package_to_app(DepsDir - ,Packages - ,Pkg), - case maybe_fetch(AppInfo, Update) of - false -> - []; - true -> - AppInfo - end - end, S) + [AppInfo || Pkg <- S, + AppInfo <- package_to_app(DepsDir + ,Packages + ,Pkg), + maybe_fetch(AppInfo, Update)] + end, AllDeps = lists:ukeymerge(2 @@ -147,7 +142,7 @@ is_valid(App) -> rebar_app_info:valid(App). -spec package_to_app(file:filename_all(), rebar_dict(), - rlx_depsolver:pkg()) -> rebar_app_info:t(). + rlx_depsolver:pkg()) -> [rebar_app_info:t()]. package_to_app(DepsDir, Packages, Pkg={_, Vsn}) -> Name = ec_cnv:to_binary(rlx_depsolver:dep_pkg(Pkg)), FmtVsn = iolist_to_binary(rlx_depsolver:format_version(Vsn)), @@ -159,7 +154,7 @@ package_to_app(DepsDir, Packages, Pkg={_, Vsn}) -> AppInfo1 = rebar_app_info:deps(AppInfo, PkgDeps), AppInfo2 = rebar_app_info:dir(AppInfo1, get_deps_dir(DepsDir, Name)), - rebar_app_info:source(AppInfo2, Link). + [rebar_app_info:source(AppInfo2, Link)]. -spec update_src_deps(integer(), rebar_state:t(), boolean()) -> rebar_state:t(). update_src_deps(Level, State, Update) -> -- cgit v1.1 From fa74056d2ac7add49397615cde8b5591f3c36bf6 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Thu, 16 Oct 2014 21:43:44 -0500 Subject: test deps support, but builds them after project apps currently --- src/rebar_prv_install_deps.erl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index a717e5f..654a5fb 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -77,7 +77,7 @@ do(State) -> Source = ProjectApps ++ rebar_state:src_apps(State1), case rebar_topo:sort_apps(Source) of {ok, Sort} -> - {ok, rebar_state:set(State1, deps_to_build, lists:dropwhile(fun is_valid/1, Sort -- ProjectApps))}; + {ok, rebar_state:set(State1, deps_to_build, lists:dropwhile(fun rebar_app_info:valid/1, Sort -- ProjectApps))}; {error, Error} -> {error, Error} end. @@ -137,10 +137,6 @@ handle_deps(State, Deps, Update) -> %% Internal functions %% =================================================================== --spec is_valid(rebar_app_info:t()) -> boolean(). -is_valid(App) -> - rebar_app_info:valid(App). - -spec package_to_app(file:filename_all(), rebar_dict(), rlx_depsolver:pkg()) -> [rebar_app_info:t()]. package_to_app(DepsDir, Packages, Pkg={_, Vsn}) -> -- cgit v1.1 From 21cf46ff9ce8b7748b46d2562259791e20797597 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 18 Oct 2014 13:00:18 -0500 Subject: dialyzer fixes --- src/rebar_prv_install_deps.erl | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 654a5fb..d752fb9 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -96,7 +96,7 @@ get_deps_dir(DepsDir, App) -> handle_deps(State, Deps) -> handle_deps(State, Deps, false). --spec handle_deps(rebar_state:t(), [dep()], false | {true, integer()}) -> {ok, rebar_state:t()}. +-spec handle_deps(rebar_state:t(), [dep()], boolean() | {true, binary(), integer()}) -> {ok, rebar_state:t()}. handle_deps(State, [], _) -> {ok, State}; handle_deps(State, Deps, Update) -> @@ -113,7 +113,7 @@ handle_deps(State, Deps, Update) -> State2 = update_src_deps(0, State1, Update), Solved = case rebar_state:pkg_deps(State2) of [] -> %% No pkg deps - []; + []; PkgDeps1 -> %% Find pkg deps needed {ok, S} = rlx_depsolver:solve(Graph, PkgDeps1), @@ -123,7 +123,6 @@ handle_deps(State, Deps, Update) -> ,Packages ,Pkg), maybe_fetch(AppInfo, Update)] - end, AllDeps = lists:ukeymerge(2 @@ -137,20 +136,21 @@ handle_deps(State, Deps, Update) -> %% Internal functions %% =================================================================== --spec package_to_app(file:filename_all(), rebar_dict(), - rlx_depsolver:pkg()) -> [rebar_app_info:t()]. +%-spec package_to_app(any(), ) -> []. % [rebar_app_info:t()]. package_to_app(DepsDir, Packages, Pkg={_, Vsn}) -> Name = ec_cnv:to_binary(rlx_depsolver:dep_pkg(Pkg)), FmtVsn = iolist_to_binary(rlx_depsolver:format_version(Vsn)), - {ok, P} = dict:find({Name, FmtVsn}, Packages), - PkgDeps = proplists:get_value(<<"deps">>, P), - Link = proplists:get_value(<<"link">>, P), - - {ok, AppInfo} = rebar_app_info:new(Name, FmtVsn), - AppInfo1 = rebar_app_info:deps(AppInfo, PkgDeps), - AppInfo2 = - rebar_app_info:dir(AppInfo1, get_deps_dir(DepsDir, Name)), - [rebar_app_info:source(AppInfo2, Link)]. + case dict:find({Name, FmtVsn}, Packages) of + error -> + []; + {ok, P} -> + PkgDeps = proplists:get_value(<<"deps">>, P, []), + Link = proplists:get_value(<<"link">>, P, ""), + {ok, AppInfo} = rebar_app_info:new(Name, FmtVsn), + AppInfo1 = rebar_app_info:deps(AppInfo, PkgDeps), + AppInfo2 = rebar_app_info:dir(AppInfo1, get_deps_dir(DepsDir, Name)), + [rebar_app_info:source(AppInfo2, Link)] + end. -spec update_src_deps(integer(), rebar_state:t(), boolean()) -> rebar_state:t(). update_src_deps(Level, State, Update) -> @@ -216,7 +216,7 @@ handle_dep(DepsDir, AppInfo) -> {SrcDeps, PkgDeps} = parse_deps(DepsDir, Deps), {AppInfo1, SrcDeps, PkgDeps}. --spec maybe_fetch(rebar_app_info:t(), boolean()) -> boolean(). +-spec maybe_fetch(rebar_app_info:t(), boolean() | {true, binary(), integer()}) -> boolean(). maybe_fetch(AppInfo, Update) -> AppDir = ec_cnv:to_list(rebar_app_info:dir(AppInfo)), Apps = rebar_app_discover:find_apps(["_checkouts"], all), -- cgit v1.1 From e8ef242c8bda1890b5e587527ae0f3d988b36d9c Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 19 Oct 2014 12:25:37 -0500 Subject: code cleanup --- src/rebar_prv_install_deps.erl | 81 +++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 37 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index d752fb9..dacd4e1 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -155,47 +155,23 @@ package_to_app(DepsDir, Packages, Pkg={_, Vsn}) -> -spec update_src_deps(integer(), rebar_state:t(), boolean()) -> rebar_state:t(). update_src_deps(Level, State, Update) -> SrcDeps = rebar_state:src_deps(State), - DepsDir = get_deps_dir(State), case lists:foldl(fun(AppInfo, {SrcDepsAcc, PkgDepsAcc, StateAcc}) -> - Name = rebar_app_info:name(AppInfo), - Locks = rebar_state:get(State, locks, []), case Update of {true, UpdateName, UpdateLevel} -> - {_, _, _, DepLevel} = lists:keyfind(Name, 1, Locks), - case UpdateLevel < DepLevel - orelse Name =:= UpdateName of - true -> - case maybe_fetch(AppInfo, true) of - true -> - {AppInfo1, NewSrcDeps, NewPkgDeps} = - handle_dep(DepsDir, AppInfo), - AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), - {NewSrcDeps ++ SrcDepsAcc - ,NewPkgDeps++PkgDepsAcc - ,rebar_state:src_apps(StateAcc, AppInfo2)}; - false -> - {SrcDepsAcc, PkgDepsAcc, State} - end; - false -> - {SrcDepsAcc, PkgDepsAcc, State} - end; + handle_update(AppInfo + ,UpdateName + ,UpdateLevel + ,SrcDepsAcc + ,PkgDepsAcc + ,Level + ,StateAcc); _ -> - case maybe_fetch(AppInfo, false) of - true -> - {AppInfo1, NewSrcDeps, NewPkgDeps} = - handle_dep(DepsDir, AppInfo), - AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), - {NewSrcDeps ++ SrcDepsAcc - ,NewPkgDeps++PkgDepsAcc - ,rebar_state:src_apps(StateAcc, AppInfo2)}; - false -> - {AppInfo1, NewSrcDeps, NewPkgDeps} = - handle_dep(DepsDir, AppInfo), - AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), - {NewSrcDeps ++ SrcDepsAcc - ,NewPkgDeps++PkgDepsAcc - ,rebar_state:src_apps(StateAcc, AppInfo2)} - end + maybe_fetch(AppInfo, false), + handle_dep(AppInfo + ,SrcDepsAcc + ,PkgDepsAcc + ,Level + ,StateAcc) end end, {[], rebar_state:pkg_deps(State), State}, SrcDeps) of {[], NewPkgDeps, State1} -> @@ -206,6 +182,37 @@ update_src_deps(Level, State, Update) -> update_src_deps(Level+1, State3, Update) end. +handle_update(AppInfo, UpdateName, UpdateLevel, SrcDeps, PkgDeps, Level, State) -> + Name = rebar_app_info:name(AppInfo), + Locks = rebar_state:get(State, locks, []), + {_, _, _, DepLevel} = lists:keyfind(Name, 1, Locks), + case UpdateLevel < DepLevel + orelse Name =:= UpdateName of + true -> + case maybe_fetch(AppInfo, true) of + true -> + handle_dep(AppInfo + ,SrcDeps + ,PkgDeps + ,Level + ,State); + + false -> + {SrcDeps, PkgDeps, State} + end; + false -> + {SrcDeps, PkgDeps, State} + end. + +handle_dep(AppInfo, SrcDeps, PkgDeps, Level, State) -> + DepsDir = get_deps_dir(State), + {AppInfo1, NewSrcDeps, NewPkgDeps} = + handle_dep(DepsDir, AppInfo), + AppInfo2 = rebar_app_info:dep_level(AppInfo1, Level), + {NewSrcDeps ++ SrcDeps + ,NewPkgDeps++PkgDeps + ,rebar_state:src_apps(State, AppInfo2)}. + -spec handle_dep(file:filename_all(), rebar_app_info:t()) -> {rebar_app_info:t(), [rebar_app_info:t()], [pkg_dep()]}. handle_dep(DepsDir, AppInfo) -> -- cgit v1.1 From da75d73b2fd1801826dbc2fc6173afe471059f0f Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 19 Oct 2014 19:41:27 -0500 Subject: code cleanup --- src/rebar_prv_install_deps.erl | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index dacd4e1..2ff7f19 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -136,7 +136,6 @@ handle_deps(State, Deps, Update) -> %% Internal functions %% =================================================================== -%-spec package_to_app(any(), ) -> []. % [rebar_app_info:t()]. package_to_app(DepsDir, Packages, Pkg={_, Vsn}) -> Name = ec_cnv:to_binary(rlx_depsolver:dep_pkg(Pkg)), FmtVsn = iolist_to_binary(rlx_depsolver:format_version(Vsn)), @@ -263,27 +262,23 @@ parse_deps(DepsDir, Deps) -> (Name, {SrcDepsAcc, PkgDepsAcc}) when is_atom(Name) -> {SrcDepsAcc, [ec_cnv:to_binary(Name) | PkgDepsAcc]}; ({Name, Vsn, Source}, {SrcDepsAcc, PkgDepsAcc}) when is_tuple (Source) -> - Dir = ec_cnv:to_list(get_deps_dir(DepsDir, Name)), - {ok, Dep} = case rebar_app_info:discover(Dir) of - {ok, App} -> - {ok, App}; - not_found -> - rebar_app_info:new(Name, Vsn, Dir) - end, - Dep1 = rebar_app_info:source(Dep, Source), - {[Dep1 | SrcDepsAcc], PkgDepsAcc}; + Dep = new_dep(DepsDir, Name, Vsn, Source), + {[Dep | SrcDepsAcc], PkgDepsAcc}; ({Name, Vsn, Source, _Level}, {SrcDepsAcc, PkgDepsAcc}) when is_tuple (Source) -> - Dir = ec_cnv:to_list(get_deps_dir(DepsDir, Name)), - {ok, Dep} = case rebar_app_info:discover(Dir) of - {ok, App} -> - {ok, App}; - not_found -> - rebar_app_info:new(Name, Vsn, Dir) - end, - Dep1 = rebar_app_info:source(Dep, Source), - {[Dep1 | SrcDepsAcc], PkgDepsAcc} + Dep = new_dep(DepsDir, Name, Vsn, Source), + {[Dep | SrcDepsAcc], PkgDepsAcc} end, {[], []}, Deps). +new_dep(DepsDir, Name, Vsn, Source) -> + Dir = ec_cnv:to_list(get_deps_dir(DepsDir, Name)), + {ok, Dep} = case rebar_app_info:discover(Dir) of + {ok, App} -> + {ok, App}; + not_found -> + rebar_app_info:new(Name, Vsn, Dir) + end, + rebar_app_info:source(Dep, Source). + -spec parse_goal(binary(), binary()) -> pkg_dep(). parse_goal(Name, Constraint) -> case re:run(Constraint, "([^\\d]*)(\\d.*)", [{capture, [1,2], binary}]) of @@ -300,9 +295,7 @@ info(Description) -> "~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", + " ~p~n", [ Description, {deps_dir, "deps"}, -- cgit v1.1 From 1dce2d36cc75263db279abd7f282772ce0f0f3e6 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Wed, 22 Oct 2014 12:03:49 -0500 Subject: add format_error/2 provider callback to providers --- src/rebar_prv_install_deps.erl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/rebar_prv_install_deps.erl') diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 2ff7f19..522420d 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -29,7 +29,8 @@ -behaviour(provider). -export([init/1, - do/1]). + do/1, + format_error/2]). -include("rebar.hrl"). @@ -82,6 +83,10 @@ do(State) -> {error, Error} end. +-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}. +format_error(Reason, State) -> + {io_lib:format("~p", [Reason]), State}. + -spec get_deps_dir(rebar_state:t()) -> file:filename_all(). get_deps_dir(State) -> BaseDir = rebar_state:get(State, base_dir, ""), @@ -96,7 +101,8 @@ get_deps_dir(DepsDir, App) -> handle_deps(State, Deps) -> handle_deps(State, Deps, false). --spec handle_deps(rebar_state:t(), [dep()], boolean() | {true, binary(), integer()}) -> {ok, rebar_state:t()}. +-spec handle_deps(rebar_state:t(), [dep()], boolean() | {true, binary(), integer()}) + -> {ok, rebar_state:t()}. handle_deps(State, [], _) -> {ok, State}; handle_deps(State, Deps, Update) -> -- cgit v1.1