--- /dev/null
+#ifndef FILETARGET_H_
+#define FILETARGET_H_
+
+#include <msp/fs/path.h>
+#include "target.h"
+
+/**
+An intermediate base class for targets that represent files. Almost all target
+classes are derived from this.
+*/
+class FileTarget: public Target
+{
+protected:
+ Msp::FS::Path path;
+ Msp::Time::TimeStamp mtime;
+ unsigned size = 0;
+ Msp::FS::Path install_location;
+ std::string install_filename;
+ bool nested_build_sig = false;
+ bool arch_in_build_sig = false;
+
+ FileTarget(Builder &b, const Msp::FS::Path &a): FileTarget(b, 0, a) { }
+ FileTarget(Builder &b, const SourcePackage &p, const Msp::FS::Path &a): FileTarget(b, &p, a) { }
+private:
+ FileTarget(Builder &, const SourcePackage *, const Msp::FS::Path &);
+ void stat();
+ static std::string generate_name(Builder &, const SourcePackage *, const Msp::FS::Path &);
+
+public:
+ const Msp::FS::Path &get_path() const { return path; }
+ const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
+ unsigned get_size() const { return size; }
+
+ bool is_installable() const { return !install_location.empty(); }
+ const Msp::FS::Path &get_install_location() const { return install_location; }
+ const std::string &get_install_filename() const { return install_filename; }
+
+ /// Changes the mtime of the target to the current time.
+ void touch();
+
+protected:
+ void check_rebuild() override;
+
+ virtual std::string create_build_signature() const;
+
+ void build(Task &) override;
+
+ void build_finished(bool) override;
+
+public:
+ void clean() override;
+};
+
+#endif