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