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