Ver código fonte

preliminary _checkouts/ support

pull/3/head
Tristan Sloughter 10 anos atrás
pai
commit
f1a0249bcf
6 arquivos alterados com 50 adições e 37 exclusões
  1. +1
    -1
      include/rebar.hrl
  2. +0
    -1
      priv/templates/gitignore.dtl
  3. +2
    -1
      src/rebar_app_discover.erl
  4. +3
    -2
      src/rebar_erlydtl_compiler.erl
  5. +40
    -28
      src/rebar_prv_install_deps.erl
  6. +4
    -4
      src/rebar_topo.erl

+ 1
- 1
include/rebar.hrl Ver arquivo

@ -13,7 +13,7 @@
-define(FMT(Str, Args), lists:flatten(io_lib:format(Str, Args))).
-define(DEFAULT_LIB_DIRS, ["apps", "libs", "."]).
-define(DEFAULT_LIB_DIRS, ["_checkouts", "apps", "libs", "."]).
-define(DEFAULT_DEPS_DIR, "_deps").
-define(DEFAULT_PLUGINS_DIR, "_plugins").
-define(DEFAULT_CONFIG_FILE, "rebar.config").

+ 0
- 1
priv/templates/gitignore.dtl Ver arquivo

@ -1,7 +1,6 @@
_*
.eunit
deps
priv
*.o
*.beam
*.plt

+ 2
- 1
src/rebar_app_discover.erl Ver arquivo

@ -13,7 +13,8 @@ do(State, LibDirs) ->
Apps = find_apps(Dirs, all),
ProjectDeps = rebar_state:deps_names(State),
lists:foldl(fun(AppInfo, StateAcc) ->
rebar_state:project_apps(StateAcc, rebar_app_info:deps(AppInfo, ProjectDeps))
ProjectDeps1 = lists:delete(rebar_app_info:name(AppInfo), ProjectDeps),
rebar_state:project_apps(StateAcc, rebar_app_info:deps(AppInfo, ProjectDeps1))
end, State, Apps).
-spec all_app_dirs(list(file:name())) -> list(file:name()).

+ 3
- 2
src/rebar_erlydtl_compiler.erl Ver arquivo

@ -126,9 +126,10 @@ init(State) ->
do(Config) ->
MultiDtlOpts = erlydtl_opts(Config),
OrigPath = code:get_path(),
true = code:add_path(rebar_utils:ebin_dir()),
%true = code:add_path(rebar_utils:ebin_dir()),
Result = lists:foldl(fun(DtlOpts, _) ->
file:make_dir(option(out_dir, DtlOpts)),
rebar_base_compiler:run(Config, [],
option(doc_root, DtlOpts),
option(source_ext, DtlOpts),
@ -231,7 +232,7 @@ do_compile(Config, Source, Target, DtlOpts) ->
?INFO("Compiling \"~s\" -> \"~s\" with options:~n ~s~n",
[Source, Target, io_lib:format("~p", [Opts])]),
case erlydtl:compile(ec_cnv:to_binary(Source),
ec_cnv:to_atom(module_name(Target)),
list_to_atom(module_name(Target)),
Opts) of
{ok, _Mod} ->
ok;

+ 40
- 28
src/rebar_prv_install_deps.erl Ver arquivo

@ -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()]}.

+ 4
- 4
src/rebar_topo.erl Ver arquivo

@ -76,10 +76,10 @@ format_error({cycle, Pairs}) ->
"before we can continue:\n",
case Pairs of
[{P1, P2}] ->
[rebar_util:indent(2), erlang:atom_to_list(P2), "->", erlang:atom_to_list(P1)];
[rebar_utils:indent(2), P2, "->", P1];
[{P1, P2} | Rest] ->
[rebar_util:indent(2), erlang:atom_to_list(P2), "->", erlang:atom_to_list(P1),
[["-> ", erlang:atom_to_list(PP2), " -> ", erlang:atom_to_list(PP1)] || {PP1, PP2} <- Rest]];
[rebar_utils:indent(2), P2, "->", P1,
[["-> ", PP2, " -> ", PP1] || {PP1, PP2} <- Rest]];
[] ->
[]
end].
@ -116,7 +116,7 @@ iterate([], L, All) ->
iterate(Pairs, L, All) ->
case subtract(lhs(Pairs), rhs(Pairs)) of
[] ->
?ERROR(format_error({cycle, Pairs}), []);
format_error({cycle, Pairs});
Lhs ->
iterate(remove_pairs(Lhs, Pairs), L ++ Lhs, All)
end.

Carregando…
Cancelar
Salvar