]> git.tdb.fi Git - builder.git/blob - source/filetarget.h
Remove all files in a side effect group when starting a task
[builder.git] / source / filetarget.h
1 #ifndef FILETARGET_H_
2 #define FILETARGET_H_
3
4 #include <msp/fs/path.h>
5 #include "target.h"
6
7 /**
8 An intermediate base class for targets that represent files.  Almost all target
9 classes are derived from this.
10 */
11 class FileTarget: public Target
12 {
13 protected:
14         Msp::FS::Path path;
15         Msp::Time::TimeStamp mtime;
16         unsigned size;
17         Msp::FS::Path install_location;
18         std::string install_filename;
19
20         FileTarget(Builder &, const Msp::FS::Path &);
21         FileTarget(Builder &, const SourcePackage &, const Msp::FS::Path &);
22 private:
23         void init(const SourcePackage *);
24         void stat();
25         static std::string generate_name(Builder &, const SourcePackage *, const Msp::FS::Path &);
26
27 public:
28         const Msp::FS::Path &get_path() const { return path; }
29         const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
30         unsigned get_size() const { return size; }
31
32         bool is_installable() const { return !install_location.empty(); }
33         const Msp::FS::Path &get_install_location() const { return install_location; }
34         const std::string &get_install_filename() const { return install_filename; }
35
36         /// Changes the mtime of the target to the current time.
37         void touch();
38
39 protected:
40         virtual void check_rebuild();
41
42         virtual std::string create_build_signature() const;
43
44         virtual void build(Task &);
45
46         virtual void build_finished(bool);
47
48 public:
49         virtual void clean();
50 };
51
52 #endif