Skip to content

Commit

Permalink
Merge pull request #2892 from ferd/prevent-DAG-edge-duplication
Browse files Browse the repository at this point in the history
Prevent infinite DAG growth
  • Loading branch information
ferd committed Jun 3, 2024
2 parents ac60196 + e917d00 commit 63e4e1f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/rebar/src/rebar_compiler_dag.erl
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,21 @@ finalise_populate_sources_(G, InDirs, [{Status, {deps, Source, AbsIncls}}|Acc])
{_, _Src, Path, _Label} <- [digraph:edge(G, Edge)],
not lists:member(Path, AbsIncls)],
%% Add the rest
[digraph:add_edge(G, Source, Incl) || Incl <- AbsIncls],
RemainingEdges = [digraph:edge(G, E) || E <- digraph:out_edges(G, Source),
AbsIncls =/= []],
[digraph:add_edge(G, Source, Incl) || Incl <- AbsIncls,
not in_edges(Source, Incl, RemainingEdges)],
%% mark the digraph dirty when there is any change in
%% dependencies, for any application in the project
mark_dirty(G),
finalise_populate_sources_(G, InDirs, Acc).

%% @private look if two vertices `V1' and `V2' exist in an unsorted set
%% of DAG edges (in expanded format).
in_edges(_, _, []) -> false;
in_edges(V1, V2, [{_, V1, V2, []}|_]) -> true;
in_edges(V1, V2, [_|T]) -> in_edges(V1, V2, T).

%% @doc this function scans all the source files found and looks into
%% all the `InDirs' for deps (other source files, or files that aren't source
%% but still returned by the compiler module) that are related
Expand Down

0 comments on commit 63e4e1f

Please sign in to comment.