|
@ -118,59 +118,20 @@ parse_dep(Dep, Parent, DepsDir, State, Locks, Level) -> |
|
|
end. |
|
|
end. |
|
|
|
|
|
|
|
|
parse_dep(Parent, {Name, Vsn, {pkg, PkgName}}, DepsDir, IsLock, State) -> |
|
|
parse_dep(Parent, {Name, Vsn, {pkg, PkgName}}, DepsDir, IsLock, State) -> |
|
|
%% Versioned Package dependency with different package name from app name |
|
|
|
|
|
CheckoutsDir = ec_cnv:to_list(rebar_dir:checkouts_dir(State, PkgName)), |
|
|
|
|
|
case rebar_app_info:discover(CheckoutsDir) of |
|
|
|
|
|
{ok, _App} -> |
|
|
|
|
|
dep_to_app(root, DepsDir, Name, [], [], IsLock, State); |
|
|
|
|
|
not_found -> |
|
|
|
|
|
{PkgName1, PkgVsn} = parse_goal(ec_cnv:to_binary(PkgName) |
|
|
|
|
|
,ec_cnv:to_binary(Vsn)), |
|
|
|
|
|
%% Verify package actually exists. This will throw a missing_package exception |
|
|
|
|
|
rebar_packages:deps(PkgName1, PkgVsn, State), |
|
|
|
|
|
Source = {pkg, PkgName1, PkgVsn}, |
|
|
|
|
|
rebar_app_info:resource_type(dep_to_app(Parent, DepsDir, Name, PkgVsn, Source, IsLock, State), pkg) |
|
|
|
|
|
end; |
|
|
|
|
|
|
|
|
{PkgName1, PkgVsn} = parse_goal(ec_cnv:to_binary(PkgName), ec_cnv:to_binary(Vsn)), |
|
|
|
|
|
pkg_to_app(Parent, DepsDir, Name, PkgName1, PkgVsn, IsLock, State); |
|
|
parse_dep(Parent, {Name, {pkg, PkgName}}, DepsDir, IsLock, State) -> |
|
|
parse_dep(Parent, {Name, {pkg, PkgName}}, DepsDir, IsLock, State) -> |
|
|
%% Package dependency with different package name from app name |
|
|
%% Package dependency with different package name from app name |
|
|
{PkgName1, PkgVsn} = get_package(ec_cnv:to_binary(PkgName), State), |
|
|
{PkgName1, PkgVsn} = get_package(ec_cnv:to_binary(PkgName), State), |
|
|
CheckoutsDir = ec_cnv:to_list(rebar_dir:checkouts_dir(State, PkgName1)), |
|
|
|
|
|
case rebar_app_info:discover(CheckoutsDir) of |
|
|
|
|
|
{ok, _App} -> |
|
|
|
|
|
dep_to_app(root, DepsDir, Name, [], [], IsLock, State); |
|
|
|
|
|
not_found -> |
|
|
|
|
|
%% Verify package actually exists. This will throw a missing_package exception |
|
|
|
|
|
rebar_packages:deps(PkgName1, PkgVsn, State), |
|
|
|
|
|
Source = {pkg, PkgName1, PkgVsn}, |
|
|
|
|
|
rebar_app_info:resource_type(dep_to_app(Parent, DepsDir, Name, PkgVsn, Source, IsLock, State), pkg) |
|
|
|
|
|
end; |
|
|
|
|
|
|
|
|
pkg_to_app(Parent, DepsDir, Name, PkgName1, PkgVsn, IsLock, State); |
|
|
parse_dep(Parent, {Name, Vsn}, DepsDir, IsLock, State) when is_list(Vsn); is_binary(Vsn) -> |
|
|
parse_dep(Parent, {Name, Vsn}, DepsDir, IsLock, State) when is_list(Vsn); is_binary(Vsn) -> |
|
|
%% Versioned Package dependency |
|
|
%% Versioned Package dependency |
|
|
CheckoutsDir = ec_cnv:to_list(rebar_dir:checkouts_dir(State, Name)), |
|
|
|
|
|
case rebar_app_info:discover(CheckoutsDir) of |
|
|
|
|
|
{ok, _App} -> |
|
|
|
|
|
dep_to_app(root, DepsDir, Name, [], [], IsLock, State); |
|
|
|
|
|
not_found -> |
|
|
|
|
|
{PkgName, PkgVsn} = parse_goal(ec_cnv:to_binary(Name) |
|
|
|
|
|
,ec_cnv:to_binary(Vsn)), |
|
|
|
|
|
%% Verify package actually exists. This will throw a missing_package exception |
|
|
|
|
|
rebar_packages:deps(PkgName, PkgVsn, State), |
|
|
|
|
|
Source = {pkg, PkgName, PkgVsn}, |
|
|
|
|
|
rebar_app_info:resource_type(dep_to_app(Parent, DepsDir, PkgName, PkgVsn, Source, IsLock, State), pkg) |
|
|
|
|
|
end; |
|
|
|
|
|
|
|
|
{PkgName, PkgVsn} = parse_goal(ec_cnv:to_binary(Name), ec_cnv:to_binary(Vsn)), |
|
|
|
|
|
pkg_to_app(Parent, DepsDir, PkgName, PkgName, PkgVsn, IsLock, State); |
|
|
parse_dep(Parent, Name, DepsDir, IsLock, State) when is_atom(Name); is_binary(Name) -> |
|
|
parse_dep(Parent, Name, DepsDir, IsLock, State) when is_atom(Name); is_binary(Name) -> |
|
|
%% Unversioned package dependency |
|
|
%% Unversioned package dependency |
|
|
{PkgName, PkgVsn} = get_package(ec_cnv:to_binary(Name), State), |
|
|
{PkgName, PkgVsn} = get_package(ec_cnv:to_binary(Name), State), |
|
|
CheckoutsDir = ec_cnv:to_list(rebar_dir:checkouts_dir(State, Name)), |
|
|
|
|
|
case rebar_app_info:discover(CheckoutsDir) of |
|
|
|
|
|
{ok, _App} -> |
|
|
|
|
|
dep_to_app(root, DepsDir, Name, [], [], IsLock, State); |
|
|
|
|
|
not_found -> |
|
|
|
|
|
%% Verify package actually exists. This will throw a missing_package exception |
|
|
|
|
|
rebar_packages:deps(PkgName, PkgVsn, State), |
|
|
|
|
|
Source = {pkg, PkgName, PkgVsn}, |
|
|
|
|
|
rebar_app_info:resource_type(dep_to_app(Parent, DepsDir, PkgName, PkgVsn, Source, IsLock, State), pkg) |
|
|
|
|
|
end; |
|
|
|
|
|
|
|
|
pkg_to_app(Parent, DepsDir, PkgName, PkgName, PkgVsn, IsLock, State); |
|
|
parse_dep(Parent, {Name, Source}, DepsDir, IsLock, State) when is_tuple(Source) -> |
|
|
parse_dep(Parent, {Name, Source}, DepsDir, IsLock, State) when is_tuple(Source) -> |
|
|
dep_to_app(Parent, DepsDir, Name, [], Source, IsLock, State); |
|
|
dep_to_app(Parent, DepsDir, Name, [], Source, IsLock, State); |
|
|
parse_dep(Parent, {Name, _Vsn, Source}, DepsDir, IsLock, State) when is_tuple(Source) -> |
|
|
parse_dep(Parent, {Name, _Vsn, Source}, DepsDir, IsLock, State) when is_tuple(Source) -> |
|
@ -179,26 +140,25 @@ parse_dep(Parent, {Name, _Vsn, Source, Opts}, DepsDir, IsLock, State) when is_tu |
|
|
?WARN("Dependency option list ~p in ~p is not supported and will be ignored", [Opts, Name]), |
|
|
?WARN("Dependency option list ~p in ~p is not supported and will be ignored", [Opts, Name]), |
|
|
dep_to_app(Parent, DepsDir, Name, [], Source, IsLock, State); |
|
|
dep_to_app(Parent, DepsDir, Name, [], Source, IsLock, State); |
|
|
parse_dep(Parent, {Name, {pkg, PkgName, Vsn}, Level}, DepsDir, IsLock, State) when is_integer(Level) -> |
|
|
parse_dep(Parent, {Name, {pkg, PkgName, Vsn}, Level}, DepsDir, IsLock, State) when is_integer(Level) -> |
|
|
CheckoutsDir = ec_cnv:to_list(rebar_dir:checkouts_dir(State, PkgName)), |
|
|
|
|
|
case rebar_app_info:discover(CheckoutsDir) of |
|
|
|
|
|
{ok, _App} -> |
|
|
|
|
|
dep_to_app(root, DepsDir, Name, [], [], IsLock, State); |
|
|
|
|
|
not_found -> |
|
|
|
|
|
%% Verify package actually exists. This will throw a missing_package exception |
|
|
|
|
|
rebar_packages:deps(PkgName, Vsn, State), |
|
|
|
|
|
Source = {pkg, PkgName, Vsn}, |
|
|
|
|
|
rebar_app_info:resource_type(dep_to_app(Parent, DepsDir, Name, Vsn, Source, IsLock, State), pkg) |
|
|
|
|
|
end; |
|
|
|
|
|
|
|
|
pkg_to_app(Parent, DepsDir, Name, PkgName, Vsn, IsLock, State); |
|
|
parse_dep(Parent, {Name, Source, Level}, DepsDir, IsLock, State) when is_tuple(Source) |
|
|
parse_dep(Parent, {Name, Source, Level}, DepsDir, IsLock, State) when is_tuple(Source) |
|
|
, is_integer(Level) -> |
|
|
, is_integer(Level) -> |
|
|
dep_to_app(Parent, DepsDir, Name, [], Source, IsLock, State); |
|
|
dep_to_app(Parent, DepsDir, Name, [], Source, IsLock, State); |
|
|
parse_dep(_, Dep, _, _, _) -> |
|
|
parse_dep(_, Dep, _, _, _) -> |
|
|
throw(?PRV_ERROR({parse_dep, Dep})). |
|
|
throw(?PRV_ERROR({parse_dep, Dep})). |
|
|
|
|
|
|
|
|
|
|
|
%% Verify package exists and create the AppInfo record |
|
|
|
|
|
pkg_to_app(Parent, DepsDir, AppName, PkgName, PkgVsn, IsLock, State) -> |
|
|
|
|
|
%% Verify package actually exists. This will throw a missing_package exception |
|
|
|
|
|
Deps = rebar_packages:deps(PkgName, PkgVsn, State), |
|
|
|
|
|
Source = {pkg, PkgName, PkgVsn}, |
|
|
|
|
|
AppInfo = dep_to_app(Parent, DepsDir, AppName, PkgVsn, Source, IsLock, State), |
|
|
|
|
|
rebar_app_info:resource_type(rebar_app_info:deps(AppInfo, Deps), pkg). |
|
|
|
|
|
|
|
|
dep_to_app(Parent, DepsDir, Name, Vsn, Source, IsLock, State) -> |
|
|
dep_to_app(Parent, DepsDir, Name, Vsn, Source, IsLock, State) -> |
|
|
CheckoutsDir = ec_cnv:to_list(rebar_dir:checkouts_dir(State, Name)), |
|
|
CheckoutsDir = ec_cnv:to_list(rebar_dir:checkouts_dir(State, Name)), |
|
|
BaseDir = rebar_state:get(State, base_dir, []), |
|
|
BaseDir = rebar_state:get(State, base_dir, []), |
|
|
{ok, Dep} = case rebar_app_info:discover(CheckoutsDir) of |
|
|
|
|
|
|
|
|
{ok, App1} = case rebar_app_info:discover(CheckoutsDir) of |
|
|
{ok, App} -> |
|
|
{ok, App} -> |
|
|
{ok, rebar_app_info:is_checkout(App, true)}; |
|
|
{ok, rebar_app_info:is_checkout(App, true)}; |
|
|
not_found -> |
|
|
not_found -> |
|
@ -207,24 +167,16 @@ dep_to_app(Parent, DepsDir, Name, Vsn, Source, IsLock, State) -> |
|
|
{ok, App} -> |
|
|
{ok, App} -> |
|
|
{ok, App}; |
|
|
{ok, App}; |
|
|
not_found -> |
|
|
not_found -> |
|
|
rebar_app_info:new(Name, Vsn, |
|
|
|
|
|
ec_cnv:to_list(filename:join(DepsDir, Name))) |
|
|
|
|
|
|
|
|
rebar_app_info:new(Parent, Name, Vsn, Dir, []) |
|
|
end |
|
|
end |
|
|
end, |
|
|
end, |
|
|
C = rebar_config:consult(rebar_app_info:dir(Dep)), |
|
|
|
|
|
S = rebar_state:new(rebar_state:new(), C, rebar_app_info:dir(Dep)), |
|
|
|
|
|
|
|
|
C = rebar_config:consult(rebar_app_info:dir(App1)), |
|
|
|
|
|
S = rebar_state:new(rebar_state:new(), C, App1), |
|
|
Overrides = rebar_state:get(State, overrides, []), |
|
|
Overrides = rebar_state:get(State, overrides, []), |
|
|
ParentOverrides = rebar_state:overrides(State), |
|
|
ParentOverrides = rebar_state:overrides(State), |
|
|
S1 = rebar_state:set(rebar_state:overrides(S, ParentOverrides++Overrides), base_dir, BaseDir), |
|
|
S1 = rebar_state:set(rebar_state:overrides(S, ParentOverrides++Overrides), base_dir, BaseDir), |
|
|
Dep1 = rebar_app_info:state(Dep, S1), |
|
|
|
|
|
AppInfo = rebar_app_info:is_lock(rebar_app_info:source(Dep1, Source), IsLock), |
|
|
|
|
|
ResourceType = case Source of |
|
|
|
|
|
{pkg, _, _} -> |
|
|
|
|
|
pkg; |
|
|
|
|
|
_ -> |
|
|
|
|
|
src |
|
|
|
|
|
end, |
|
|
|
|
|
rebar_app_info:resource_type(rebar_app_info:parent(AppInfo, Parent), ResourceType). |
|
|
|
|
|
|
|
|
App2 = rebar_app_info:state(App1, S1), |
|
|
|
|
|
rebar_app_info:is_lock(rebar_app_info:source(App2, Source), IsLock). |
|
|
|
|
|
|
|
|
format_error({missing_package, Package}) -> |
|
|
format_error({missing_package, Package}) -> |
|
|
io_lib:format("Package not found in registry: ~s", [Package]); |
|
|
io_lib:format("Package not found in registry: ~s", [Package]); |
|
|