浏览代码

Extract artifact tracking to DAG module

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
pull/2282/head
Fred Hebert 5 年前
父节点
当前提交
90bead2310
共有 2 个文件被更改,包括 10 次插入6 次删除
  1. +5
    -5
      src/rebar_compiler.erl
  2. +5
    -1
      src/rebar_compiler_dag.erl

+ 5
- 5
src/rebar_compiler.erl 查看文件

@ -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),
@ -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);
@ -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) ->

+ 5
- 1
src/rebar_compiler_dag.erl 查看文件

@ -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").
@ -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 %%%
%%%%%%%%%%%%%%%

正在加载...
取消
保存