8 #include <msp/time/timestamp.h>
18 Targets make up the build graph. This class is a base for all target types and
19 handles many common tasks. See also FileTarget and VirtualTarget.
24 typedef std::list<Target *> Dependencies;
28 const Package *package;
35 std::string rebuild_reason;
43 Target(Builder &, const Package *, const std::string &);
47 virtual const char *get_type() const = 0;
48 const std::string &get_name() const { return name; }
49 const Package *get_package() const { return package; }
52 Tries to locate a target that will help getting this target built. If all
53 dependencies are up-to-date, returns this target. If there are no targets
54 ready to be built (maybe because they are being built right now), returns 0.
56 virtual Target *get_buildable_target();
59 If this target is a proxy for another (such as Install or Symlink), return
60 that target. Otherwise, return the target itself.
62 Implementors should call the function recursively to find the final target.
64 virtual Target *get_real_target() { return this; }
66 void set_tool(const Tool &);
67 const Tool *get_tool() const { return tool; }
69 bool is_buildable() const { return buildable; }
70 bool get_rebuild() const { return rebuild; }
71 const std::string &get_rebuild_reason() const { return rebuild_reason; }
72 void add_depend(Target *);
73 const Dependencies &get_depends() const { return depends; }
74 bool get_depends_ready() const { return deps_ready; }
77 Finds dependencies for the target. When all dependencies have been found,
78 the function should set deps_ready to true.
80 virtual void find_depends() { deps_ready = true; }
83 Prepares the target by recursively preparing dependencies, then checking
84 whether rebuilding is needed. A flag is used to prevent unnecessary
87 virtual void prepare();
90 Starts building the target. Returns the Action used for building.
94 void mark_rebuild(const std::string &);
97 Checks if the target needs to be rebuilt and why.
99 virtual void check_rebuild() = 0;
102 Handler for the build_finished signal of Task.
104 virtual void build_finished(bool);