Yet another Erlang Make implementation

Table of Contents

https://travis-ci.org/k32/task_graph.svg?branch=master

1 TODO Description

Yet another library reinventing good old make, implemented in pure Erlang. This library aims to do one thing right: it runs tasks in parallel in topological order. Hence it doesn't do globing, templating, it doesn't provide any DSLs, etc…

2 Features

2.1 Dynamic tasks

Tasks may spawn other tasks or discover their own dependencies dynamically

2.2 Painstakingly tested

Random task graph topologies are tested using proper.

Absence of race conditions is exhaustively 1 verified using concuerror.

2.3 Written with build flow optimization in mind

2.3.1 Dependency graph visualization

3 Examples

Basic usage:

-include_lib("task_graph/include/task_graph.hrl").

main() ->
    %% Define tasks:
    Tasks = [#task{ task_id = I
                  , execute = fun(MyId, MyData) ->
                                  io:format("I'm ~p, doing ~p~n", [MyId, MyData])
                              end,
                  , data = something
                  }
             || I <- lists:seq(1, 4)],
    %% Define dependnecies ({A, B} reads as "B depends on A"):
    Edges = [{1, 2}, {1, 3}, {2, 3}, {2, 4}],
    %% Execute graph:
    {ok, _} = task_graph:run_graph(my_graph, {Tasks, Edges}).

Got lost in the dependencies? It's possible to visualize the graph:

Opts = #{event_handlers =>
             [{task_graph_draw_deps, #{ filename => "dependencies.dot"
                                      %% You can optionally customize shape and color of vertices:
                                      , color => fun(#task{}) ->
                                                     green
                                                 end
                                      , shape => fun(#task{}) ->
                                                     oval
                                                 end
                                      }}]},
{ok, _} = task_graph:run_graph(my_graph, Opts, {Tasks, Edges}).

Render the resulting file using graphviz:

dot -Tpng -O dependencies.dot

Footnotes:

1

Concuerror tests all possible schedulings of a single test graph

Created: 2018-07-01 Sun 20:31

Validate