]> git.tdb.fi Git - builder.git/blob - source/sourcepackage.h
a60c9d2bee94509287f510b5849ed973f4a10b40
[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 <string>
12 #include "buildinfo.h"
13 #include "component.h"
14 #include "condition.h"
15 #include "config.h"
16 #include "dependencycache.h"
17 #include "feature.h"
18 #include "package.h"
19
20 class Builder;
21
22 /**
23 A package that can be built by Builder.
24 */
25 class SourcePackage: public Package
26 {
27 public:
28         enum InstallFlags
29         {
30                 INCLUDE=1,
31                 BIN=2,
32                 LIB=4,
33                 DATA=8
34         };
35
36         class Loader: public Package::Loader
37         {
38         public:
39                 Loader(Package &);
40                 SourcePackage &get_object() { return static_cast<SourcePackage &>(pkg); }
41         private:
42                 virtual void finish();
43                 void feature(const std::string &, const std::string &);
44                 void condition(const std::string &);
45                 void program(const std::string &);
46                 void library(const std::string &);
47                 void module(const std::string &);
48                 void headers(const std::string &);
49                 void build_info();
50                 void tarball(const std::string &);
51                 void tar_file(const std::string &);
52         };
53
54 private:
55         std::string version;
56         std::string description;
57
58         Msp::FS::Path source;
59         PackageList base_reqs;
60         FeatureList features;
61         BuildInfo build_info;
62         ConditionList conditions;
63         ComponentList components;
64         Config config;
65         bool conf_done;
66         mutable DependencyCache deps_cache;
67
68 public:
69         SourcePackage(Builder &, const std::string &, const Msp::FS::Path &);
70         const std::string &get_name() const { return name; }
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() const { return source; }
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         const BuildInfo &get_build_info() const { return build_info; }
79         const BuildInfo &get_exported_binfo() const { return export_binfo; }
80         Builder &get_builder() const { return builder; }
81
82         /** Returns a bitmask indicating which kinds of things the components of
83         this package install. */
84         unsigned get_install_flags();
85
86         LibMode get_library_mode() const;
87         DependencyCache &get_deps_cache() const { return deps_cache; }
88 private:
89         virtual void do_configure(const StringMap &, unsigned);
90
91         /** Initializes configuration options. */
92         void init_config();
93
94         /** Fills in build info based on configuration.  All required packages must be
95         configured when this is called. */
96         virtual void create_build_info();
97 };
98
99 #endif