diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2019-04-04 10:49:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-04 10:49:25 -0400 |
commit | 0843c19bceca2f18c2b84129551a412135cc9608 (patch) | |
tree | 376d2348c81cc07819ce05ee280f2d49f2074d42 /src/rebar_compiler_erl.erl | |
parent | 67ca662364a7571b890a7aaef22c1cbf81e4643f (diff) | |
parent | 9f81a5754e0dc4d3ce968d02facdfa5c87dcea3c (diff) |
Merge pull request #2040 from ferd/max-au-rebar_compiler_parallel
Enable parallel build
Diffstat (limited to 'src/rebar_compiler_erl.erl')
-rw-r--r-- | src/rebar_compiler_erl.erl | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/rebar_compiler_erl.erl b/src/rebar_compiler_erl.erl index 759305c..1ad16d8 100644 --- a/src/rebar_compiler_erl.erl +++ b/src/rebar_compiler_erl.erl @@ -55,7 +55,14 @@ needed_files(Graph, FoundFiles, _, AppInfo) -> {ErlFirstFiles, ErlOptsFirst} = erl_first_files(RebarOpts, ErlOpts, Dir, NeededErlFiles), SubGraph = digraph_utils:subgraph(Graph, NeededErlFiles), DepErlsOrdered = digraph_utils:topsort(SubGraph), - OtherErls = lists:reverse(DepErlsOrdered), + %% Break out the files required by other modules from those + %% that none other depend of; the former must be sequentially + %% built, the rest is parallelizable. + OtherErls = lists:partition( + fun(Erl) -> digraph:in_degree(Graph, Erl) > 0 end, + lists:reverse([Dep || Dep <- DepErlsOrdered, + not lists:member(Dep, ErlFirstFiles)]) + ), PrivIncludes = [{i, filename:join(OutDir, Src)} || Src <- rebar_dir:all_src_dirs(RebarOpts, ["src"], [])], @@ -64,8 +71,7 @@ needed_files(Graph, FoundFiles, _, AppInfo) -> true = digraph:delete(SubGraph), {{ErlFirstFiles, ErlOptsFirst ++ AdditionalOpts}, - {[Erl || Erl <- OtherErls, - not lists:member(Erl, ErlFirstFiles)], ErlOpts ++ AdditionalOpts}}. + {OtherErls, ErlOpts ++ AdditionalOpts}}. dependencies(Source, SourceDir, Dirs) -> {ok, Fd} = file:open(Source, [read]), |