8 #include <sigc++/signal.h>
9 #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;
37 sigc::signal<void> signal_bubble_rebuild;
41 const SourcePackage *package;
42 const Component *component;
47 std::string rebuild_reason;
51 Target(Builder &, const std::string &);
55 virtual const char *get_type() const = 0;
56 const std::string &get_name() const { return name; }
57 const SourcePackage *get_package() const { return package; }
58 const Component *get_component() const { return component; }
60 /** Tries to locate a target that will help getting this target built. If
61 all dependencies are up-to-date, returns this target. If there are no
62 targets ready to be built (maybe because they are being built right now),
64 virtual Target *get_buildable_target();
66 /** If this target is a proxy for another (such as Install), return that
67 target. Otherwise, return the target itself.
69 Implementors should call the function recursively to find the final target. */
70 virtual Target *get_real_target() { return this; }
72 void set_tool(const Tool &);
73 const Tool *get_tool() const { return tool; }
75 /** Indicates if it's possible to build this target. */
76 bool is_buildable() const { return tool!=0; }
78 /** Indicates if this target needs rebuilding. Only makes sense after the
79 target has been prepared. */
80 bool needs_rebuild() const { return state>PREPARING && state<UPTODATE; }
82 /** Returns the reason for rebuilding this target. Only makes sense after
83 the target has been prepared. */
84 const std::string &get_rebuild_reason() const { return rebuild_reason; }
86 /** Forces rebuild of the target. */
89 void add_depend(Target *);
90 const Dependencies &get_depends() const { return depends; }
92 /** Finds dependencies for the target. */
93 virtual void find_depends() { }
95 /** Prepares the target by finding dependencies, recursively preparing them
96 and then checking whether rebuilding is needed. */
97 virtual void prepare();
99 /** Starts building the target. Returns the Action used for building. */
102 void mark_rebuild(const std::string &);
104 /** Checks if the target needs to be rebuilt and why. */
105 virtual void check_rebuild() = 0;
107 /** Handler for Task::signal_finished. */
108 virtual void build_finished(bool);