summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar_digraph.erl31
-rw-r--r--src/rebar_erlc_compiler.erl5
-rw-r--r--src/rebar_prv_update.erl1
3 files changed, 22 insertions, 15 deletions
diff --git a/src/rebar_digraph.erl b/src/rebar_digraph.erl
index 1132a6c..d21ff77 100644
--- a/src/rebar_digraph.erl
+++ b/src/rebar_digraph.erl
@@ -16,20 +16,23 @@ compile_order(Apps) ->
Deps = all_apps_deps(App),
add(Graph, {Name, Deps})
end, Apps),
- case digraph_utils:topsort(Graph) of
- false ->
- case digraph_utils:is_acyclic(Graph) of
- true ->
- {error, no_sort};
- false ->
- Cycles = lists:sort(
- [lists:sort(Comp) || Comp <- digraph_utils:strong_components(Graph),
- length(Comp)>1]),
- {error, {cycles, Cycles}}
- end;
- V ->
- {ok, names_to_apps(lists:reverse(V), Apps)}
- end.
+ Order =
+ case digraph_utils:topsort(Graph) of
+ false ->
+ case digraph_utils:is_acyclic(Graph) of
+ true ->
+ {error, no_sort};
+ false ->
+ Cycles = lists:sort(
+ [lists:sort(Comp) || Comp <- digraph_utils:strong_components(Graph),
+ length(Comp)>1]),
+ {error, {cycles, Cycles}}
+ end;
+ V ->
+ {ok, names_to_apps(lists:reverse(V), Apps)}
+ end,
+ true = digraph:delete(Graph),
+ Order.
add(Graph, {PkgName, Deps}) ->
case digraph:vertex(Graph, PkgName) of
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index 624fe0b..4c76429 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -165,7 +165,8 @@ doterl_compile(Config, Dir, OutDir, MoreSources, ErlOpts) ->
{DepErls, OtherErls} = lists:partition(
fun(Source) -> digraph:in_degree(G, Source) > 0 end,
[File || File <- NeededErlFiles, not lists:member(File, ErlFirstFiles)]),
- DepErlsOrdered = digraph_utils:topsort(digraph_utils:subgraph(G, DepErls)),
+ SubGraph = digraph_utils:subgraph(G, DepErls),
+ DepErlsOrdered = digraph_utils:topsort(SubGraph),
FirstErls = ErlFirstFiles ++ lists:reverse(DepErlsOrdered),
?DEBUG("Files to compile first: ~p", [FirstErls]),
rebar_base_compiler:run(
@@ -177,6 +178,8 @@ doterl_compile(Config, Dir, OutDir, MoreSources, ErlOpts) ->
end,
internal_erl_compile(C, Dir, S, OutDir1, ErlOpts1)
end),
+ true = digraph:delete(SubGraph),
+ true = digraph:delete(G),
ok.
%% Get files which need to be compiled first, i.e. those specified in erl_first_files
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
index 049e78c..55c70e2 100644
--- a/src/rebar_prv_update.erl
+++ b/src/rebar_prv_update.erl
@@ -59,6 +59,7 @@ do(State) ->
ok = file:write_file(HexFile, Unzipped),
{Dict, Graph} = hex_to_graph(HexFile),
write_registry(Dict, Graph, State),
+ true = digraph:delete(Graph),
ok
catch
_E:C ->