Rohit
Rohit

Reputation: 3638

What are the algorithms to solve dependency build?

I am build a system that is similar to project builds. A project has set of inputs and outputs. A project may depend on other projects. I can use topological sort and find the sequence in which I must evaluate projects. But, how do I parallel build. Toposort does not give same ranks to projects that can build in parallel. Also, how do I do incremental builds.

Upvotes: 3

Views: 387

Answers (1)

BWA
BWA

Reputation: 5764

You can parallel build all projects which have not any dependencies. After build remove builded project from graph and again build projects without dependencies. Repeat until graph is empty.

In pseudo code

  1. Build project graph
  2. Validate graph (e.g. circular dependencies)
  3. Find all projects without dependencies and not under build
  4. Start build all found in 3 and mark them under build
  5. Wait for one of builds end and romove builded project from graph
  6. if graph not empty go to 3
  7. Wait for rest builds

Upvotes: 1

Related Questions