]> git.tdb.fi Git - builder.git/blob - source/sourcepackage.h
Refactor transitive dependencies to work on all targets
[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 &);
33                 Loader(SourcePackage &, const Config::InputOptions &);
34         private:
35                 void init(const Config::InputOptions *);
36                 virtual void finish();
37                 void feature(const std::string &, const std::string &);
38                 template<typename C>
39                 void component(const std::string &);
40                 template<typename C, typename A, A>
41                 void component_arg(const std::string &);
42                 void build_info();
43                 void generate(const std::string &);
44                 void interface_version(const std::string &);
45                 void source_archive();
46                 void tarball(const std::string &);
47                 void version(const std::string &);
48         };
49
50         typedef std::list<Component *> ComponentList;
51
52 private:
53         typedef std::list<Feature> FeatureList;
54
55         std::string version;
56         std::string interface_version;
57         std::string description;
58
59         FileTarget *build_file;
60         Msp::FS::Path source_dir;
61         const BuildType *build_type;
62         Toolchain local_tools;
63         FeatureList features;
64         BuildInfo build_info;
65         ComponentList components;
66         SourceArchiveComponent *source_archive;
67         Config config;
68         mutable Cache cache;
69
70 public:
71         SourcePackage(Builder &, const std::string &, const Msp::FS::Path &);
72         ~SourcePackage();
73
74         const std::string &get_version() const { return version; }
75         const std::string &get_interface_version() const { return interface_version; }
76         const std::string &get_description() const { return description; }
77
78         FileTarget &get_build_file() const { return *build_file; }
79         const Msp::FS::Path &get_source_directory() const { return source_dir; }
80         Msp::FS::Path get_temp_directory() const;
81         Msp::FS::Path get_output_directory() const;
82
83         const Toolchain &get_toolchain() const { return local_tools; }
84         const Component &get_component(const std::string &) const;
85         const Config &get_config() const { return config; }
86         bool match_feature(const std::string &, const std::string *) const;
87         void set_build_type(const BuildType &);
88         const BuildInfo &get_build_info() const { return build_info; }
89 private:
90         virtual void do_prepare();
91
92 public:
93         Cache &get_cache() const { return cache; }
94 private:
95         virtual void save_caches();
96 };
97
98 #endif