]> git.tdb.fi Git - builder.git/blob - source/target.h
eb46d9fe7116125798f4e7920baf71f5c87c8260
[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 class Target
16 {
17 public:
18         const std::string  &get_name() const           { return name; }
19         Target             *get_buildable_target();
20         bool               get_rebuild() const         { return rebuild; }
21         const std::string  &get_rebuild_reason() const { return rebuild_reason; }
22         const Msp::Time::TimeStamp &get_mtime() const  { return mtime; }
23         virtual const char *get_type() const=0;
24         const TargetList   &get_depends() const        { return depends; }
25         const Package      *get_package() const        { return package; }
26         bool               get_depends_ready() const   { return deps_ready; }
27         void               add_depend(Target *);
28         virtual void       find_depends()              { deps_ready=true; }
29         virtual void       prepare();
30         virtual Action     *build()=0;
31         void               reset_count()               { counted=false; }
32         virtual unsigned   count_rebuild();
33         void               touch();
34         virtual ~Target() { }
35 protected:
36         Builder       &builder;
37         const Package *package;
38         std::string   name;
39         Msp::Time::TimeStamp mtime;
40
41         bool          buildable;
42         bool          building;
43         bool          rebuild;
44         std::string   rebuild_reason;
45
46         TargetList    depends;
47         TargetList    rdepends;
48         bool          deps_ready;
49
50         bool          prepared;
51         bool          counted;
52
53         Target(Builder &, const Package *, const std::string &);
54         void         mark_rebuild(const std::string &);
55         virtual void check_rebuild();
56         Action       *build(Action *);
57         virtual void build_done();
58 };
59
60 #endif