]> git.tdb.fi Git - builder.git/blob - source/package.h
Various fixes to package dependency and build info handling
[builder.git] / source / package.h
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2006-2007, 2009  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef PACKAGE_H_
9 #define PACKAGE_H_
10
11 #include <list>
12 #include <string>
13 #include <msp/datafile/loader.h>
14 #include "buildinfo.h"
15
16 class Builder;
17 class Package;
18
19 typedef std::list<Package *> PackageList;
20
21 /**
22 A package is a distributable piece of software.  Package information may be
23 obtained in several ways: Build files of source packages, pkg-config for binary
24 packages and the builderrc file for binary packages with no pkg-config support.
25 */
26 class Package
27 {
28 public:
29         class Loader: public Msp::DataFile::Loader
30         {
31         public:
32                 Loader(Package &);
33                 Package &get_object() { return pkg; }
34         protected:
35                 Package &pkg;
36
37                 void require(const std::string &);
38         };
39
40 protected:
41         Builder &builder;
42
43         std::string name;
44
45         PackageList requires;
46         BuildInfo export_binfo;
47         bool conf_done;
48
49         bool use_pkgconfig;
50
51         Package(Builder &, const std::string &);
52 public:
53         virtual ~Package() { }
54
55         const std::string &get_name() const { return name; }
56         Builder &get_builder() const { return builder; }
57         const PackageList &get_requires() const { return requires; }
58
59         const BuildInfo &get_exported_binfo() const { return export_binfo; }
60
61         /// Indicates whether or not this package supports pkg-config
62         bool get_use_pkgconfig() const { return use_pkgconfig; }
63
64         /** Processes configuration options that were most likely obtained from the
65         command line. */
66         void configure(const StringMap &, unsigned);
67
68         bool is_configured() const { return conf_done; }
69 protected:
70         virtual void do_configure(const StringMap &, unsigned) { }
71         virtual void create_build_info() { }
72 };
73
74 #endif