]> git.tdb.fi Git - builder.git/blob - source/sourcepackage.h
Move if_arch to Package so binary packages can use it too
[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 "condition.h"
10 #include "config.h"
11 #include "feature.h"
12 #include "package.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>
32         {
33         private:
34                 const Config::InputOptions *options;
35                 std::map<std::string, std::string> install_map;
36
37         public:
38                 Loader(SourcePackage &);
39                 Loader(SourcePackage &, const Config::InputOptions &);
40         private:
41                 void init(const Config::InputOptions *);
42                 virtual void finish();
43                 void feature(const std::string &, const std::string &);
44                 template<Component::Type>
45                 void component(const std::string &);
46                 void condition(const std::string &);
47                 void build_info();
48                 void headers(const std::string &);
49                 void if_feature(const std::string &);
50                 void source_tarball();
51                 void tarball(const std::string &);
52                 void tar_file(const std::string &);
53         };
54
55         typedef std::list<Component> ComponentList;
56
57 private:
58         std::string 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_description() const { return description; }
76         FileTarget &get_build_file() const { return *build_file; }
77         const Msp::FS::Path &get_source_directory() const { return source_dir; }
78         Msp::FS::Path get_temp_dir() const;
79         Msp::FS::Path get_out_dir() const;
80         const ComponentList &get_components() const { return components; }
81         const Config &get_config() const { return config; }
82         void set_build_type(const BuildType &);
83         const BuildInfo &get_build_info() const { return build_info; }
84         Builder &get_builder() const { return builder; }
85
86         Cache &get_cache() const { return cache; }
87 private:
88         virtual void create_build_info();
89
90         virtual void create_targets();
91
92         virtual void save_caches();
93 };
94
95 #endif