]> git.tdb.fi Git - builder.git/blob - source/package.h
Replace per-file copyright notices with a single file
[builder.git] / source / package.h
1 #ifndef PACKAGE_H_
2 #define PACKAGE_H_
3
4 #include <list>
5 #include <string>
6 #include <msp/datafile/loader.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::Loader
23         {
24         public:
25                 Loader(Package &);
26                 Package &get_object() { return pkg; }
27         protected:
28                 Package &pkg;
29
30                 void require(const std::string &);
31         };
32
33 protected:
34         Builder &builder;
35
36         std::string name;
37
38         PackageList requires;
39         BuildInfo export_binfo;
40         bool conf_done;
41
42         bool use_pkgconfig;
43
44         Package(Builder &, const std::string &);
45 public:
46         virtual ~Package() { }
47
48         const std::string &get_name() const { return name; }
49         Builder &get_builder() const { return builder; }
50         const PackageList &get_requires() const { return requires; }
51
52         const BuildInfo &get_exported_binfo() const { return export_binfo; }
53
54         /// Indicates whether or not this package supports pkg-config
55         bool get_use_pkgconfig() const { return use_pkgconfig; }
56
57         /** Processes configuration options that were most likely obtained from the
58         command line. */
59         void configure(const StringMap &, unsigned);
60
61         bool is_configured() const { return conf_done; }
62 protected:
63         virtual void do_configure(const StringMap &, unsigned) { }
64         virtual void create_build_info() { }
65 };
66
67 #endif