]> git.tdb.fi Git - builder.git/blob - source/buildgraph.h
Refactor build graph into its own class
[builder.git] / source / buildgraph.h
1 #ifndef BUILDGRAPH_H_
2 #define BUILDGRAPH_H_
3
4 #include "virtualfilesystem.h"
5
6 class Builder;
7 class Target;
8
9 /**
10 Manages a graph of targets.
11 */
12 class BuildGraph
13 {
14 public:
15         typedef std::map<std::string, Target *> TargetMap;
16
17 private:
18         Builder &builder;
19         TargetMap targets;
20
21 public:
22         BuildGraph(Builder &);
23         ~BuildGraph();
24
25         /** Looks up a target by name.  Returns 0 if no such target exists. */
26         Target *get_target(const std::string &) const;
27
28         const TargetMap &get_targets() const { return targets; }
29
30         /** Adds a target.  It can later be retrieved by name.  Called from Target
31         constructor. */
32         void add_target(Target *);
33
34         /** Adds a target that is a primary build goal.  Such targets will be added
35         as dependencies of the "world" virtual target.  If the target belongs to a
36         default component of the main package, it's also added to the "default"
37         virtual target. */
38         void add_primary_target(Target &);
39
40         /** Adds a target that will be installed.  A new InstalledFile target is
41         created and added as a dependency to the "install" virtual target. */
42         void add_installed_target(Target &);
43 };
44
45 #endif