summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2014-10-13 16:23:50 -0500
committerTristan Sloughter <t@crashfast.com>2014-10-13 16:23:50 -0500
commitf1a0249bcf12f08b7aae21aec373fec4cd583dbe (patch)
tree4075fba2bb68dbebce923abaf971cb9f17250b2f
parent99bdc8786b363648eb9cfdb293a1692e3ad79894 (diff)
preliminary _checkouts/ support
-rw-r--r--include/rebar.hrl2
-rw-r--r--priv/templates/gitignore.dtl1
-rw-r--r--src/rebar_app_discover.erl3
-rw-r--r--src/rebar_erlydtl_compiler.erl5
-rw-r--r--src/rebar_prv_install_deps.erl68
-rw-r--r--src/rebar_topo.erl8
6 files changed, 50 insertions, 37 deletions
diff --git a/include/rebar.hrl b/include/rebar.hrl
index 4263fb9..bae974d 100644
--- a/include/rebar.hrl
+++ b/include/rebar.hrl
@@ -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").
diff --git a/priv/templates/gitignore.dtl b/priv/templates/gitignore.dtl
index 0eb9ed8..23123d4 100644
--- a/priv/templates/gitignore.dtl
+++ b/priv/templates/gitignore.dtl
@@ -1,7 +1,6 @@
_*
.eunit
deps
-priv
*.o
*.beam
*.plt
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl
index 9fa7b4a..147bc92 100644
--- a/src/rebar_app_discover.erl
+++ b/src/rebar_app_discover.erl
@@ -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()).
diff --git a/src/rebar_erlydtl_compiler.erl b/src/rebar_erlydtl_compiler.erl
index 88ffb96..5fecd48 100644
--- a/src/rebar_erlydtl_compiler.erl
+++ b/src/rebar_erlydtl_compiler.erl
@@ -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;
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()]}.
diff --git a/src/rebar_topo.erl b/src/rebar_topo.erl
index 9ab4c28..e4a3e26 100644
--- a/src/rebar_topo.erl
+++ b/src/rebar_topo.erl
@@ -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.