]> git.tdb.fi Git - builder.git/blob - source/target.h
Adjust requires to library changes
[builder.git] / source / target.h
1 #ifndef TARGET_H_
2 #define TARGET_H_
3
4 #include <list>
5 #include <string>
6 #include <msp/time/timestamp.h>
7
8 class Action;
9 class Builder;
10 class Package;
11
12 class Target;
13 typedef std::list<Target *> TargetList;
14
15 /**
16 Targets make up the build graph.  This class is a base for all target types and
17 handles many common tasks.  Most targets are associated with a file.
18 */
19 class Target
20 {
21 public:
22         const std::string  &get_name() const           { return name; }
23         Target             *get_buildable_target();
24         bool               get_buildable() const       { return buildable; }
25         bool               get_rebuild() const         { return rebuild; }
26         const std::string  &get_rebuild_reason() const { return rebuild_reason; }
27         const Msp::Time::TimeStamp &get_mtime() const  { return mtime; }
28         virtual const char *get_type() const=0;
29         const TargetList   &get_depends() const        { return depends; }
30         const Package      *get_package() const        { return package; }
31         bool               get_depends_ready() const   { return deps_ready; }
32         void               add_depend(Target *);
33         virtual void       find_depends()              { deps_ready=true; }
34         virtual void       prepare();
35
36         /**
37         Creates and returns an Action suitable for building this target.
38         */
39         virtual Action     *build()=0;
40
41         void               reset_count()               { counted=false; }
42         virtual unsigned   count_rebuild();
43         void               touch();
44         virtual ~Target() { }
45 protected:
46         Builder       &builder;
47         const Package *package;
48         std::string   name;
49         Msp::Time::TimeStamp mtime;
50
51         bool          buildable;
52         bool          building;
53         bool          rebuild;
54         std::string   rebuild_reason;
55
56         TargetList    depends;
57         TargetList    rdepends;
58         bool          deps_ready;
59
60         bool          prepared;
61         bool          counted;
62
63         Target(Builder &, const Package *, const std::string &);
64         void         mark_rebuild(const std::string &);
65         virtual void check_rebuild();
66         Action       *build(Action *);
67         virtual void build_done();
68 };
69
70 #endif