]> git.tdb.fi Git - builder.git/blob - source/sourcepackage.h
Un-abbreviate some function and variable names
[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 "component.h"
8 #include "condition.h"
9 #include "config.h"
10 #include "dependencycache.h"
11 #include "feature.h"
12 #include "package.h"
13
14 class Builder;
15 class BuildType;
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>
31         {
32         private:
33                 const Config::InputOptions *options;
34                 std::map<std::string, std::string> install_map;
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 condition(const std::string &);
46                 void build_info();
47                 void headers(const std::string &);
48                 void if_arch(const std::string &);
49                 void if_feature(const std::string &);
50                 void tarball(const std::string &);
51                 void tar_file(const std::string &);
52         };
53
54         typedef std::list<Component> ComponentList;
55
56 private:
57         std::string version;
58         std::string description;
59
60         Msp::FS::Path source_dir;
61         const BuildType *build_type;
62         FeatureList features;
63         BuildInfo build_info;
64         ComponentList components;
65         Config config;
66         mutable DependencyCache deps_cache;
67
68 public:
69         SourcePackage(Builder &, const std::string &, const Msp::FS::Path &);
70
71         const std::string &get_version() const { return version; }
72         const std::string &get_description() const { return description; }
73         const Msp::FS::Path &get_source_directory() const { return source_dir; }
74         Msp::FS::Path get_temp_dir() const;
75         Msp::FS::Path get_out_dir() const;
76         const ComponentList &get_components() const { return components; }
77         const Config &get_config() const { return config; }
78         void set_build_type(const BuildType &);
79         const BuildInfo &get_build_info() const { return build_info; }
80         Builder &get_builder() const { return builder; }
81
82         DependencyCache &get_dependency_cache() const { return deps_cache; }
83 private:
84         virtual void create_build_info();
85
86         virtual void create_targets();
87
88         virtual void save_caches();
89 };
90
91 #endif