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