]> git.tdb.fi Git - builder.git/blob - source/sourcepackage.h
Clean up some unused cruft
[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
16 class bad_expansion: public std::runtime_error
17 {
18 public:
19         bad_expansion(const std::string &w): std::runtime_error(w) { }
20         virtual ~bad_expansion() throw() { }
21 };
22
23 /**
24 A package that can be built by Builder.
25 */
26 class SourcePackage: public Package
27 {
28 public:
29         class Loader: public Msp::DataFile::DerivedObjectLoader<SourcePackage, Package>
30         {
31         private:
32                 std::map<std::string, std::string> install_map;
33
34         public:
35                 Loader(SourcePackage &);
36         private:
37                 virtual void finish();
38                 void feature(const std::string &, const std::string &);
39                 template<Component::Type>
40                 void component(const std::string &);
41                 void condition(const std::string &);
42                 void build_info();
43                 void headers(const std::string &);
44                 void tarball(const std::string &);
45                 void tar_file(const std::string &);
46         };
47
48 private:
49         std::string version;
50         std::string description;
51
52         Msp::FS::Path source;
53         FeatureList features;
54         BuildInfo build_info;
55         ConditionList conditions;
56         ComponentList components;
57         Config config;
58         mutable DependencyCache deps_cache;
59
60 public:
61         SourcePackage(Builder &, const std::string &, const Msp::FS::Path &);
62         const std::string &get_version() const { return version; }
63         const std::string &get_description() const { return description; }
64         const Msp::FS::Path &get_source() const { return source; }
65         Msp::FS::Path get_temp_dir() const;
66         Msp::FS::Path get_out_dir() const;
67         const ComponentList &get_components() const { return components; }
68         const Config &get_config() const { return config; }
69         const BuildInfo &get_build_info() const { return build_info; }
70         Builder &get_builder() const { return builder; }
71
72         LibMode get_library_mode() const;
73         DependencyCache &get_deps_cache() const { return deps_cache; }
74         std::string expand_string(const std::string &) const;
75 private:
76         virtual void do_configure(const StringMap &, unsigned);
77
78         /** Initializes configuration options. */
79         void init_config();
80
81         /** Fills in build info based on configuration.  All required packages must be
82         configured when this is called. */
83         virtual void create_build_info();
84
85         virtual void create_targets();
86
87         virtual void save_caches();
88 };
89
90 #endif