]> git.tdb.fi Git - builder.git/blob - source/package.h
eb61f06b760e1fc21a4c62a3a34fda194837573e
[builder.git] / source / package.h
1 #ifndef PACKAGE_H_
2 #define PACKAGE_H_
3
4 #include <list>
5 #include <string>
6 #include <msp/datafile/objectloader.h>
7 #include "buildinfo.h"
8 #include "config.h"
9
10 class Builder;
11 class Package;
12
13 /**
14 A package is a distributable piece of software.  Package information may be
15 obtained in several ways: Build files of source packages, pkg-config for binary
16 packages and the builderrc file for binary packages with no pkg-config support.
17 */
18 class Package
19 {
20 public:
21         class Loader: public Msp::DataFile::ObjectLoader<Package>
22         {
23         public:
24                 Loader(Package &);
25         private:
26                 void if_arch(const std::string &);
27                 void require(const std::string &);
28         };
29
30         typedef std::list<Package *> Requirements;
31
32 protected:
33         Builder &builder;
34
35         std::string name;
36
37         Requirements requires;
38         BuildInfo export_binfo;
39         bool prepared;
40         std::list<std::string> problems;
41
42         bool use_pkgconfig;
43
44         Package(Builder &, const std::string &);
45 public:
46         virtual ~Package() { }
47
48         Builder &get_builder() const { return builder; }
49         const std::string &get_name() const { return name; }
50         const Requirements &get_required_packages() const { return requires; }
51
52         const BuildInfo &get_exported_build_info() const { return export_binfo; }
53
54         /// Indicates whether or not this package supports pkg-config
55         bool uses_pkgconfig() const { return use_pkgconfig; }
56
57         /** Prepares the package for building.  Recursively prepares all required
58         packages, populates build info and creates targets. */
59         void prepare();
60
61 protected:
62         virtual void do_prepare() { }
63
64 public:
65         bool is_prepared() const { return prepared; }
66
67         const std::list<std::string> &get_problems() const { return problems; }
68
69         virtual void save_caches() { }
70 };
71
72 #endif