]> git.tdb.fi Git - builder.git/blob - source/sourcepackage.h
Further changes for library compatibility
[builder.git] / source / sourcepackage.h
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2007-2009  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef SOURCEPACKAGE_H_
9 #define SOURCEPACKAGE_H_
10
11 #include <stdexcept>
12 #include <string>
13 #include "buildinfo.h"
14 #include "component.h"
15 #include "condition.h"
16 #include "config.h"
17 #include "dependencycache.h"
18 #include "feature.h"
19 #include "package.h"
20
21 class Builder;
22
23 class bad_expansion: public std::runtime_error
24 {
25 public:
26         bad_expansion(const std::string &w): std::runtime_error(w) { }
27         virtual ~bad_expansion() throw() { }
28 };
29
30 /**
31 A package that can be built by Builder.
32 */
33 class SourcePackage: public Package
34 {
35 public:
36         enum InstallFlags
37         {
38                 INCLUDE = 1,
39                 BIN = 2,
40                 LIB = 4,
41                 DATA = 8
42         };
43
44         class Loader: public Package::Loader
45         {
46         public:
47                 Loader(Package &);
48                 SourcePackage &get_object() { return static_cast<SourcePackage &>(pkg); }
49         private:
50                 virtual void finish();
51                 void feature(const std::string &, const std::string &);
52                 template<Component::Type>
53                 void component(const std::string &);
54                 void condition(const std::string &);
55                 void build_info();
56                 void tarball(const std::string &);
57                 void tar_file(const std::string &);
58         };
59
60 private:
61         std::string version;
62         std::string description;
63
64         Msp::FS::Path source;
65         FeatureList features;
66         BuildInfo build_info;
67         ConditionList conditions;
68         ComponentList components;
69         Config config;
70         mutable DependencyCache deps_cache;
71
72 public:
73         SourcePackage(Builder &, const std::string &, const Msp::FS::Path &);
74         const std::string &get_name() const { return name; }
75         const std::string &get_version() const { return version; }
76         const std::string &get_description() const { return description; }
77         const Msp::FS::Path &get_source() const { return source; }
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         const BuildInfo &get_build_info() const { return build_info; }
83         const BuildInfo &get_exported_binfo() const { return export_binfo; }
84         Builder &get_builder() const { return builder; }
85
86         /** Returns a bitmask indicating which kinds of things the components of
87         this package install. */
88         unsigned get_install_flags();
89
90         LibMode get_library_mode() const;
91         DependencyCache &get_deps_cache() const { return deps_cache; }
92         std::string expand_string(const std::string &) const;
93 private:
94         virtual void do_configure(const StringMap &, unsigned);
95
96         /** Initializes configuration options. */
97         void init_config();
98
99         /** Fills in build info based on configuration.  All required packages must be
100         configured when this is called. */
101         virtual void create_build_info();
102 };
103
104 #endif