]> git.tdb.fi Git - builder.git/blob - source/package.h
Collapse the virtual functions used during package preparation into one
[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 typedef std::list<Package *> PackageList;
14
15 /**
16 A package is a distributable piece of software.  Package information may be
17 obtained in several ways: Build files of source packages, pkg-config for binary
18 packages and the builderrc file for binary packages with no pkg-config support.
19 */
20 class Package
21 {
22 public:
23         class Loader: public Msp::DataFile::ObjectLoader<Package>
24         {
25         public:
26                 Loader(Package &);
27         private:
28                 void if_arch(const std::string &);
29                 void require(const std::string &);
30         };
31
32 protected:
33         Builder &builder;
34
35         std::string name;
36
37         PackageList requires;
38         BuildInfo export_binfo;
39         bool prepared;
40
41         bool use_pkgconfig;
42
43         Package(Builder &, const std::string &);
44 public:
45         virtual ~Package() { }
46
47         const std::string &get_name() const { return name; }
48         Builder &get_builder() const { return builder; }
49         const PackageList &get_required_packages() const { return requires; }
50
51         const BuildInfo &get_exported_build_info() const { return export_binfo; }
52
53         /// Indicates whether or not this package supports pkg-config
54         bool get_use_pkgconfig() const { return use_pkgconfig; }
55
56         /** Prepares the package for building.  Recursively prepares all required
57         packages, populates build info and creates targets. */
58         void prepare();
59
60 protected:
61         virtual void do_prepare() { }
62
63 public:
64         bool is_prepared() const { return prepared; }
65
66         virtual void save_caches() { }
67 };
68
69 #endif