Skip to content

Commit

Permalink
Extract artifact tracking to DAG module
Browse files Browse the repository at this point in the history
Cleans up some annoying broken abstraction.

Also fix erl_first_file artifact tracking, which will avoid seeking to
disk by finding the opts in the DAG
  • Loading branch information
ferd committed May 12, 2020
1 parent fb58aa1 commit 90bead2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/rebar_compiler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ sort_apps(Names, Apps) ->
{_, App} <- [lists:keyfind(Name, 1, NamedApps)]].

-spec compile_analyzed({module(), digraph:graph()}, rebar_app_info:t(), map()) -> ok.
compile_analyzed({Compiler, G}, AppInfo, Contexts) -> % > 3.13.0
compile_analyzed({Compiler, G}, AppInfo, Contexts) -> % > 3.13.2
run(G, Compiler, AppInfo, Contexts),
%% Extras are tricky and get their own mini-analysis
ExtraApps = annotate_extras(AppInfo),
Expand Down Expand Up @@ -183,8 +183,9 @@ run(G, CompilerMod, AppInfo, Contexts) ->
{{FirstFiles, FirstFileOpts},
{RestFiles, Opts}} = CompilerMod:needed_files(G, FoundFiles, Mappings, AppInfo),

compile_each(FirstFiles, FirstFileOpts, BaseOpts, Mappings, CompilerMod),
Tracked = case RestFiles of
Tracked =
compile_each(FirstFiles, FirstFileOpts, BaseOpts, Mappings, CompilerMod)
++ case RestFiles of
{Sequential, Parallel} -> % parallelizable form
compile_each(Sequential, Opts, BaseOpts, Mappings, CompilerMod) ++
compile_parallel(Parallel, Opts, BaseOpts, Mappings, CompilerMod);
Expand Down Expand Up @@ -246,8 +247,7 @@ 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, {artifact, Meta}),
digraph:add_edge(G, Target, Source, artifact),
rebar_compiler_dag:store_artifact(G, Source, Target, Meta),
store_artifacts(G, Rest).

compile_worker(QueuePid, Opts, Config, Outs, CompilerMod) ->
Expand Down
6 changes: 5 additions & 1 deletion src/rebar_compiler_dag.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-module(rebar_compiler_dag).
-export([init/4, maybe_store/5, terminate/1]).
-export([prune/5, populate_sources/5, populate_deps/3, propagate_stamps/1,
compile_order/2]).
compile_order/2, store_artifact/4]).

-include("rebar.hrl").

Expand Down Expand Up @@ -192,6 +192,10 @@ maybe_store(G, Dir, Compiler, Label, CritMeta) ->
terminate(G) ->
true = digraph:delete(G).

store_artifact(G, Source, Target, Meta) ->
digraph:add_vertex(G, Target, {artifact, Meta}),
digraph:add_edge(G, Target, Source, artifact).

%%%%%%%%%%%%%%%
%%% PRIVATE %%%
%%%%%%%%%%%%%%%
Expand Down

0 comments on commit 90bead2

Please sign in to comment.