Fix out of order dep builds

This commit is contained in:
Craig Everett 2023-07-01 22:44:34 +09:00
parent e397d57ef2
commit 6bce1ba536
53 changed files with 82 additions and 60 deletions

View File

@ -1 +1 @@
0.12.8 0.13.0

View File

@ -1,6 +1,6 @@
{application,zx, {application,zx,
[{description,"An Erlang development tool and Zomp user client"}, [{description,"An Erlang development tool and Zomp user client"},
{vsn,"0.12.8"}, {vsn,"0.13.0"},
{applications,[stdlib,kernel]}, {applications,[stdlib,kernel]},
{modules,[zx,zx_auth,zx_conn,zx_conn_sup,zx_daemon,zx_key, {modules,[zx,zx_auth,zx_conn,zx_conn_sup,zx_daemon,zx_key,
zx_lib,zx_local,zx_net,zx_peer,zx_peer_man, zx_lib,zx_local,zx_net,zx_peer,zx_peer_man,

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -24,7 +24,7 @@
%%% @end %%% @end
-module(zx). -module(zx).
-vsn("0.12.8"). -vsn("0.13.0").
-behavior(application). -behavior(application).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
@ -1049,66 +1049,86 @@ dep_split([C | Rest], Dep, Dir, Deps) ->
dep_split([], Dep, Dir, Deps) -> dep_split([], Dep, Dir, Deps) ->
{[], [{Dep, lists:reverse(Dir)} | Deps]}. {[], [{Dep, lists:reverse(Dir)} | Deps]}.
pre_prep2(Meta, LocalDeps, RunArgs) -> pre_prep2(Meta, Local, RunArgs) ->
Type = maps:get(type, Meta), Type = maps:get(type, Meta),
Deps = maps:get(deps, Meta), Deps = maps:get(deps, Meta),
case pre_prep3(Deps, LocalDeps) of MarkedDeps = lists:map(mark(Local), Deps),
{ok, NewDeps} -> {Type, NewDeps, RunArgs}; {Type, MarkedDeps, RunArgs}.
Error -> Error
mark(LocalDeps) ->
fun(Dep) ->
case is_local(Dep, LocalDeps) of
{true, Dir} -> {local, Dep, Dir};
false -> {fetch, Dep}
end
end. end.
pre_prep3(Deps, [{Dep, Dir} | Rest]) -> is_local({_, N, _}, [{N, Dir} | _]) -> {true, Dir};
case zx_lib:package_id(Dep) of is_local(D, [_ | T]) -> is_local(D, T);
{ok, PackageID} -> pre_prep4(Deps, PackageID, Dir, Rest); is_local(_, []) -> false.
Error -> Error
end;
pre_prep3(Deps, []) ->
{ok, Deps}.
pre_prep4(Deps, {Realm, Name, _}, Dir, Rest) ->
case file:set_cwd(Dir) of
ok ->
Scrub = fun({R, N, _}) -> not ((R == Realm) andalso (N == Name)) end,
NewDeps = lists:filter(Scrub, Deps),
true = os:putenv(Name ++ "_include", filename:join(Dir, "include")),
ok = zx_lib:build(),
pre_prep3(NewDeps, Rest);
Error = {error, enoent} ->
ok = tell(error, "Dir ~p does not exist!", [Dir]),
Error
end.
-spec prepare([zx:package_id()]) -> ok. -spec prepare(Deps) -> ok
when Deps :: [Dep],
Dep :: {local, zx:package_id(), file:filename()}
| {fetch, zx:package_id()}.
%% @private %% @private
%% Execution prep common to all packages. %% Execution prep common to all packages.
prepare(Deps) -> prepare(Deps) ->
ok = lists:foreach(fun include_env/1, Deps), ok = ensure(Deps),
NotInstalled = fun(P) -> not filelib:is_dir(zx_lib:ppath(lib, P)) end,
Needed = lists:filter(NotInstalled, Deps),
acquire(Needed, Deps).
acquire([Dep | Rest], Deps) ->
case fetch(Dep) of
ok -> acquire(Rest, Deps);
Error -> Error
end;
acquire([], Deps) ->
make(Deps). make(Deps).
make([Dep | Rest]) -> ensure([{fetch, Dep} | Rest]) ->
case filelib:is_dir(zx_lib:ppath(lib, Dep)) of
true ->
true = include_env(Dep),
ensure(Rest);
false ->
acquire(Dep, Rest)
end;
ensure([{local, {_, Name, _}, Dir} | Rest]) ->
IncludeName = Name ++ "_include",
IncludePath = filename:join(Dir, "include"),
true = os:putenv(IncludeName, IncludePath),
ensure(Rest);
ensure([]) ->
ok.
acquire(Dep, Rest) ->
case fetch(Dep) of
ok ->
true = include_env(Dep),
ensure(Rest);
Error ->
Error
end.
make([{fetch, Dep} | Rest]) ->
case zx_daemon:build(Dep) of case zx_daemon:build(Dep) of
ok -> make(Rest); ok -> make(Rest);
Error -> Error Error -> Error
end; end;
make([{local, _, Dir} | Rest]) ->
{ok, WorkingDir} = file:get_cwd(),
case file:set_cwd(Dir) of
ok ->
ok = zx_lib:build(),
ok = file:set_cwd(WorkingDir),
make(Rest);
Error = {error, enoent} ->
ok = tell(error, "Dir ~p does not exist!", [Dir]),
Error
end;
make([]) -> make([]) ->
ok. ok.
include_env(PackageID = {_, Name, _}) -> include_env(PackageID = {_, Name, _}) ->
Path = filename:join(zx_lib:ppath(lib, PackageID), "include"), IncludeName = Name ++ "_include",
os:putenv(Name ++ "_include", Path). IncludePath = filename:join(zx_lib:ppath(lib, PackageID), "include"),
os:putenv(IncludeName, IncludePath).
-spec upgrade() -> zx:outcome(). -spec upgrade() -> zx:outcome().
@ -1146,6 +1166,8 @@ upgrade() ->
-spec fetch(zx:package_id()) -> zx:outcome(). -spec fetch(zx:package_id()) -> zx:outcome().
fetch(PackageID) -> fetch(PackageID) ->
{ok, PackageName} = zx_lib:package_string(PackageID),
ok = tell("Fetching ~ts", [PackageName]),
{ok, ID} = zx_daemon:fetch(PackageID), {ok, ID} = zx_daemon:fetch(PackageID),
fetch2(ID). fetch2(ID).

View File

@ -9,7 +9,7 @@
%%% @end %%% @end
-module(zx_auth). -module(zx_auth).
-vsn("0.12.8"). -vsn("0.13.0").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -7,7 +7,7 @@
%%% @end %%% @end
-module(zx_conn). -module(zx_conn).
-vsn("0.12.8"). -vsn("0.13.0").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -5,7 +5,7 @@
%%% @end %%% @end
-module(zx_conn_sup). -module(zx_conn_sup).
-vsn("0.12.8"). -vsn("0.13.0").
-behavior(supervisor). -behavior(supervisor).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").

View File

@ -138,7 +138,7 @@
%%% @end %%% @end
-module(zx_daemon). -module(zx_daemon).
-vsn("0.12.8"). -vsn("0.13.0").
-behavior(gen_server). -behavior(gen_server).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").

View File

@ -8,7 +8,7 @@
%%% @end %%% @end
-module(zx_key). -module(zx_key).
-vsn("0.12.8"). -vsn("0.13.0").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -10,7 +10,7 @@
%%% @end %%% @end
-module(zx_lib). -module(zx_lib).
-vsn("0.12.8"). -vsn("0.13.0").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -6,7 +6,7 @@
%%% @end %%% @end
-module(zx_local). -module(zx_local).
-vsn("0.12.8"). -vsn("0.13.0").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -5,7 +5,7 @@
%%% @end %%% @end
-module(zx_net). -module(zx_net).
-vsn("0.12.8"). -vsn("0.13.0").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -8,7 +8,7 @@
%%% @end %%% @end
-module(zx_peer). -module(zx_peer).
-vsn("0.12.8"). -vsn("0.13.0").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -9,7 +9,7 @@
%%% @end %%% @end
-module(zx_peer_man). -module(zx_peer_man).
-vsn("0.12.8"). -vsn("0.13.0").
-behavior(gen_server). -behavior(gen_server).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").

View File

@ -6,7 +6,7 @@
%%% @end %%% @end
-module(zx_peer_sup). -module(zx_peer_sup).
-vsn("0.12.8"). -vsn("0.13.0").
-behaviour(supervisor). -behaviour(supervisor).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").

View File

@ -10,7 +10,7 @@
%%% @end %%% @end
-module(zx_peers). -module(zx_peers).
-vsn("0.12.8"). -vsn("0.13.0").
-behavior(supervisor). -behavior(supervisor).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").

View File

@ -5,7 +5,7 @@
%%% @end %%% @end
-module(zx_proxy). -module(zx_proxy).
-vsn("0.12.8"). -vsn("0.13.0").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -5,7 +5,7 @@
%%% @end %%% @end
-module(zx_sup). -module(zx_sup).
-vsn("0.12.8"). -vsn("0.13.0").
-behavior(supervisor). -behavior(supervisor).
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").

View File

@ -6,7 +6,7 @@
%%% @end %%% @end
-module(zx_tty). -module(zx_tty).
-vsn("0.12.8"). -vsn("0.13.0").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -5,7 +5,7 @@
%%% @end %%% @end
-module(zx_userconf). -module(zx_userconf).
-vsn("0.12.8"). -vsn("0.13.0").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -7,7 +7,7 @@
%%% @end %%% @end
-module(zx_zsp). -module(zx_zsp).
-vsn("0.12.8"). -vsn("0.13.0").
-author("Craig Everett <zxq9@zxq9.com>"). -author("Craig Everett <zxq9@zxq9.com>").
-copyright("Craig Everett <zxq9@zxq9.com>"). -copyright("Craig Everett <zxq9@zxq9.com>").
-license("GPL-3.0"). -license("GPL-3.0").

View File

@ -9,7 +9,7 @@
{license,"MIT"}. {license,"MIT"}.
{modules,[]}. {modules,[]}.
{name,"zx"}. {name,"zx"}.
{package_id,{"otpr","zx",{0,12,8}}}. {package_id,{"otpr","zx",{0,13,0}}}.
{prefix,"zx_"}. {prefix,"zx_"}.
{repo_url,"https://gitlab.com/zxq9/zx"}. {repo_url,"https://gitlab.com/zxq9/zx"}.
{tags,["tools","package manager","erlang"]}. {tags,["tools","package manager","erlang"]}.