]> git.tdb.fi Git - builder.git/blob - source/sourcepackage.h
Various cleanups
[builder.git] / source / sourcepackage.h
1 #ifndef SOURCEPACKAGE_H_
2 #define SOURCEPACKAGE_H_
3
4 #include <stdexcept>
5 #include <string>
6 #include "buildinfo.h"
7 #include "cache.h"
8 #include "component.h"
9 #include "config.h"
10 #include "feature.h"
11 #include "package.h"
12 #include "toolchain.h"
13
14 class Builder;
15 class BuildType;
16 class FileTarget;
17
18 /**
19 A package that can be built by Builder.
20 */
21 class SourcePackage: public Package
22 {
23 public:
24         class Loader: public Msp::DataFile::DerivedObjectLoader<SourcePackage, Package::Loader>
25         {
26         private:
27                 const Config::InputOptions *options;
28
29         public:
30                 Loader(SourcePackage &);
31                 Loader(SourcePackage &, const Config::InputOptions &);
32         private:
33                 void init(const Config::InputOptions *);
34                 virtual void finish();
35                 void feature(const std::string &, const std::string &);
36                 template<Component::Type>
37                 void component(const std::string &);
38                 void build_info();
39                 void generate(const std::string &);
40                 void if_feature(const std::string &);
41                 void interface_version(const std::string &);
42                 void source_tarball();
43                 void tarball(const std::string &);
44                 void version(const std::string &);
45         };
46
47         typedef std::list<Component> ComponentList;
48
49 private:
50         typedef std::list<Feature> FeatureList;
51
52         std::string version;
53         std::string interface_version;
54         std::string description;
55
56         FileTarget *build_file;
57         Msp::FS::Path source_dir;
58         const BuildType *build_type;
59         Toolchain local_tools;
60         FeatureList features;
61         BuildInfo build_info;
62         ComponentList components;
63         Component *source_tarball;
64         Config config;
65         mutable Cache cache;
66
67 public:
68         SourcePackage(Builder &, const std::string &, const Msp::FS::Path &);
69
70         const std::string &get_version() const { return version; }
71         const std::string &get_interface_version() const { return interface_version; }
72         const std::string &get_description() const { return description; }
73
74         FileTarget &get_build_file() const { return *build_file; }
75         const Msp::FS::Path &get_source_directory() const { return source_dir; }
76         Msp::FS::Path get_temp_directory() const;
77         Msp::FS::Path get_output_directory() const;
78
79         const Toolchain &get_toolchain() const { return local_tools; }
80         const ComponentList &get_components() const { return components; }
81         const Config &get_config() const { return config; }
82         bool match_feature(const std::string &, const std::string *) const;
83         void set_build_type(const BuildType &);
84         const BuildInfo &get_build_info() const { return build_info; }
85 private:
86         virtual void do_prepare();
87
88 public:
89         Cache &get_cache() const { return cache; }
90 private:
91         virtual void save_caches();
92 };
93
94 #endif