]> git.tdb.fi Git - builder.git/blob - source/sourcepackage.h
Move library mode into BuildInfo
[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                 std::map<std::string, std::string> install_map;
34
35         public:
36                 Loader(SourcePackage &);
37         private:
38                 virtual void finish();
39                 void feature(const std::string &, const std::string &);
40                 template<Component::Type>
41                 void component(const std::string &);
42                 void condition(const std::string &);
43                 void build_info();
44                 void headers(const std::string &);
45                 void tarball(const std::string &);
46                 void tar_file(const std::string &);
47         };
48
49 private:
50         std::string version;
51         std::string description;
52
53         Msp::FS::Path source;
54         const BuildType *build_type;
55         FeatureList features;
56         BuildInfo build_info;
57         ConditionList conditions;
58         ComponentList components;
59         Config config;
60         mutable DependencyCache deps_cache;
61
62 public:
63         SourcePackage(Builder &, const std::string &, const Msp::FS::Path &);
64         const std::string &get_version() const { return version; }
65         const std::string &get_description() const { return description; }
66         const Msp::FS::Path &get_source() const { return source; }
67         Msp::FS::Path get_temp_dir() const;
68         Msp::FS::Path get_out_dir() const;
69         const ComponentList &get_components() const { return components; }
70         const Config &get_config() const { return config; }
71         void set_build_type(const BuildType &);
72         const BuildInfo &get_build_info() const { return build_info; }
73         Builder &get_builder() const { return builder; }
74
75         DependencyCache &get_deps_cache() const { return deps_cache; }
76         std::string expand_string(const std::string &) const;
77 private:
78         virtual void do_configure(const StringMap &, unsigned);
79
80         /** Initializes configuration options. */
81         void init_config();
82
83         /** Fills in build info based on configuration.  All required packages must be
84         configured when this is called. */
85         virtual void create_build_info();
86
87         virtual void create_targets();
88
89         virtual void save_caches();
90 };
91
92 #endif