8 #include <msp/time/timestamp.h>
19 Targets make up the build graph. This class is a base for all target types and
20 handles many common tasks. See also FileTarget and VirtualTarget.
25 typedef std::list<Target *> Dependencies;
38 const Package *package;
39 const Component *component;
44 std::string rebuild_reason;
45 std::string install_location;
49 Target(Builder &, const std::string &);
53 virtual const char *get_type() const = 0;
54 const std::string &get_name() const { return name; }
55 const Package *get_package() const { return package; }
56 const Component *get_component() const { return component; }
58 /** Tries to locate a target that will help getting this target built. If
59 all dependencies are up-to-date, returns this target. If there are no
60 targets ready to be built (maybe because they are being built right now),
62 virtual Target *get_buildable_target();
64 /** If this target is a proxy for another (such as Install), return that
65 target. Otherwise, return the target itself.
67 Implementors should call the function recursively to find the final target. */
68 virtual Target *get_real_target() { return this; }
70 void set_tool(const Tool &);
71 const Tool *get_tool() const { return tool; }
73 bool is_buildable() const { return tool!=0; }
74 bool needs_rebuild() const { return state>PREPARING && state<UPTODATE; }
75 const std::string &get_rebuild_reason() const { return rebuild_reason; }
76 bool is_installable() const { return !install_location.empty(); }
77 const std::string &get_install_location() const { return install_location; }
78 void add_depend(Target *);
79 const Dependencies &get_depends() const { return depends; }
81 /** Finds dependencies for the target. */
82 virtual void find_depends() { }
84 /** Prepares the target by finding dependencies, recursively preparing them
85 and then checking whether rebuilding is needed. */
86 virtual void prepare();
88 /** Starts building the target. Returns the Action used for building. */
91 void mark_rebuild(const std::string &);
93 /** Checks if the target needs to be rebuilt and why. */
94 virtual void check_rebuild() = 0;
96 /** Handler for Task::signal_finished. */
97 virtual void build_finished(bool);