]> git.tdb.fi Git - builder.git/blob - source/package.h
Externalize dry run handling from Config and DependencyCache
[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
9 class Builder;
10 class Package;
11
12 typedef std::list<Package *> PackageList;
13
14 /**
15 A package is a distributable piece of software.  Package information may be
16 obtained in several ways: Build files of source packages, pkg-config for binary
17 packages and the builderrc file for binary packages with no pkg-config support.
18 */
19 class Package
20 {
21 public:
22         class Loader: public Msp::DataFile::ObjectLoader<Package>
23         {
24         public:
25                 Loader(Package &);
26         private:
27                 void require(const std::string &);
28         };
29
30 protected:
31         Builder &builder;
32
33         std::string name;
34
35         PackageList requires;
36         BuildInfo export_binfo;
37         bool conf_done;
38
39         bool use_pkgconfig;
40
41         Package(Builder &, const std::string &);
42 public:
43         virtual ~Package() { }
44
45         const std::string &get_name() const { return name; }
46         Builder &get_builder() const { return builder; }
47         const PackageList &get_requires() const { return requires; }
48
49         const BuildInfo &get_exported_binfo() const { return export_binfo; }
50
51         /// Indicates whether or not this package supports pkg-config
52         bool get_use_pkgconfig() const { return use_pkgconfig; }
53
54         /** Processes configuration options that were most likely obtained from the
55         command line. */
56         void configure(const StringMap &, unsigned);
57
58         bool is_configured() const { return conf_done; }
59 protected:
60         virtual void do_configure(const StringMap &, unsigned) { }
61         virtual void create_build_info() { }
62
63 public:
64         virtual void create_targets() { }
65
66         virtual void save_caches() { }
67 };
68
69 #endif