Bladeren bron

Fix Artifact tagging in DAG

The propagation was confusing source files and artifacts; the artifact
ordering was flipped, and the tagging non-mandatory (aside from as
edges), which made things hard to identify when plugins for compilers
are used.
pull/2246/head
Fred Hebert 5 jaren geleden
bovenliggende
commit
4e1c23abec
4 gewijzigde bestanden met toevoegingen van 16 en 10 verwijderingen
  1. +2
    -2
      src/rebar_compiler.erl
  2. +12
    -6
      src/rebar_compiler_dag.erl
  3. +1
    -1
      src/rebar_compiler_erl.erl
  4. +1
    -1
      test/rebar_compile_SUITE.erl

+ 2
- 2
src/rebar_compiler.erl Bestand weergeven

@ -246,8 +246,8 @@ store_artifacts(_G, []) ->
ok;
store_artifacts(G, [{Source, Target, Meta}|Rest]) ->
%% Assume the source exists since it was tracked to be compiled
digraph:add_vertex(G, Target, Meta),
digraph:add_edge(G, Source, Target, artifact),
digraph:add_vertex(G, Target, {artifact, Meta}),
digraph:add_edge(G, Target, Source, artifact),
store_artifacts(G, Rest).
compile_worker(QueuePid, Opts, Config, Outs, CompilerMod) ->

+ 12
- 6
src/rebar_compiler_dag.erl Bestand weergeven

@ -233,7 +233,7 @@ maybe_rm_artifact_and_edge(G, OutDir, SrcExt, Ext, Source) ->
%% Actually exists, don't delete
false;
false ->
Edges = digraph:out_edges(G, Source),
Edges = digraph:in_edges(G, Source),
Targets = [V2 || Edge <- Edges,
{_E, _V1, V2, artifact} <- [digraph:edge(G, Edge)]],
case Targets of
@ -281,8 +281,7 @@ prepopulate_deps(G, Compiler, InDirs, Source, DepOpts, Status) ->
%% drop edges from deps that aren't included!
[digraph:del_edge(G, Edge) || Status == old,
Edge <- digraph:out_edges(G, Source),
{_, _Src, Path, Label} <- [digraph:edge(G, Edge)],
Label =/= artifact,
{_, _Src, Path, _Label} <- [digraph:edge(G, Edge)],
not lists:member(Path, AbsIncls)],
%% Add the rest
[digraph:add_edge(G, Source, Incl) || Incl <- AbsIncls],
@ -296,11 +295,14 @@ refresh_dep(G, File) ->
%% Gone! Erase from the graph
digraph:del_vertex(G, File),
mark_dirty(G);
{artifact, _} ->
%% ignore artifacts
ok;
LastModified when LastUpdated < LastModified ->
digraph:add_vertex(G, File, LastModified),
mark_dirty(G);
_ ->
% unchanged
%% unchanged
ok
end.
@ -310,14 +312,18 @@ refresh_dep(G, File) ->
propagate_stamps(_G, []) ->
ok;
propagate_stamps(G, [File|Files]) ->
Stamps = [element(2, digraph:vertex(G, F))
|| F <- digraph:out_neighbours(G, File)],
Stamps = [Stamp
|| F <- digraph:out_neighbours(G, File),
{_, Stamp} <- [digraph:vertex(G, F)],
is_tuple(Stamp) andalso element(1, Stamp) =/= artifact],
case Stamps of
[] ->
ok;
_ ->
Max = lists:max(Stamps),
case digraph:vertex(G, File) of
{_, {artifact, _}} ->
ok;
{_, Smaller} when Smaller < Max ->
digraph:add_vertex(G, File, Max);
_ ->

+ 1
- 1
src/rebar_compiler_erl.erl Bestand weergeven

@ -235,7 +235,7 @@ opts_changed(Graph, NewOpts, Target, TargetBase) ->
false -> NewOpts
end,
TargetOpts = case digraph:vertex(Graph, Target) of
{_Target, Opts} -> % tracked dep is found
{_Target, {artifact, Opts}} -> % tracked dep is found
Opts;
false -> % not found; might be a non-tracked DAG
case compile_info(TargetBase) of

+ 1
- 1
test/rebar_compile_SUITE.erl Bestand weergeven

@ -939,7 +939,7 @@ recompile_when_dag_opts_change(Config) ->
DepsDir = filename:join([AppDir, "_build", "default", "lib"]),
G = rebar_compiler_dag:init(DepsDir, rebar_compiler_erl, "project_apps", []),
%% change the config in the DAG...
[digraph:add_vertex(G, Beam, [{d, some_define}]) || Beam <- Beams],
[digraph:add_vertex(G, Beam, {artifact, [{d, some_define}]}) || Beam <- Beams],
digraph:add_vertex(G, '$r3_dirty_bit', true), % trigger a save
rebar_compiler_dag:maybe_store(G, DepsDir, rebar_compiler_erl, "project_apps", []),
rebar_compiler_dag:terminate(G),

Laden…
Annuleren
Opslaan