]> git.tdb.fi Git - builder.git/blob - source/sourcepackage.h
Deprecate the headers component type
[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         enum InstallFlags
30         {
31                 INCLUDE = 1,
32                 BIN = 2,
33                 LIB = 4,
34                 DATA = 8
35         };
36
37         class Loader: public Package::Loader
38         {
39         private:
40                 std::map<std::string, std::string> install_map;
41
42         public:
43                 Loader(Package &);
44                 SourcePackage &get_object() { return static_cast<SourcePackage &>(pkg); }
45         private:
46                 virtual void finish();
47                 void feature(const std::string &, const std::string &);
48                 template<Component::Type>
49                 void component(const std::string &);
50                 void condition(const std::string &);
51                 void build_info();
52                 void headers(const std::string &);
53                 void tarball(const std::string &);
54                 void tar_file(const std::string &);
55         };
56
57 private:
58         std::string version;
59         std::string description;
60
61         Msp::FS::Path source;
62         FeatureList features;
63         BuildInfo build_info;
64         ConditionList conditions;
65         ComponentList components;
66         Config config;
67         mutable DependencyCache deps_cache;
68
69 public:
70         SourcePackage(Builder &, const std::string &, const Msp::FS::Path &);
71         const std::string &get_name() const { return name; }
72         const std::string &get_version() const { return version; }
73         const std::string &get_description() const { return description; }
74         const Msp::FS::Path &get_source() const { return source; }
75         Msp::FS::Path get_temp_dir() const;
76         Msp::FS::Path get_out_dir() const;
77         const ComponentList &get_components() const { return components; }
78         const Config &get_config() const { return config; }
79         const BuildInfo &get_build_info() const { return build_info; }
80         const BuildInfo &get_exported_binfo() const { return export_binfo; }
81         Builder &get_builder() const { return builder; }
82
83         /** Returns a bitmask indicating which kinds of things the components of
84         this package install. */
85         unsigned get_install_flags();
86
87         LibMode get_library_mode() const;
88         DependencyCache &get_deps_cache() const { return deps_cache; }
89         std::string expand_string(const std::string &) const;
90 private:
91         virtual void do_configure(const StringMap &, unsigned);
92
93         /** Initializes configuration options. */
94         void init_config();
95
96         /** Fills in build info based on configuration.  All required packages must be
97         configured when this is called. */
98         virtual void create_build_info();
99
100         virtual void create_targets();
101 };
102
103 #endif