]> git.tdb.fi Git - builder.git/blob - source/package.h
Un-abbreviate some function and variable names
[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 require(const std::string &);
29         };
30
31 protected:
32         Builder &builder;
33
34         std::string name;
35
36         PackageList requires;
37         BuildInfo export_binfo;
38         bool prepared;
39
40         bool use_pkgconfig;
41
42         Package(Builder &, const std::string &);
43 public:
44         virtual ~Package() { }
45
46         const std::string &get_name() const { return name; }
47         Builder &get_builder() const { return builder; }
48         const PackageList &get_required_packages() const { return requires; }
49
50         const BuildInfo &get_exported_build_info() const { return export_binfo; }
51
52         /// Indicates whether or not this package supports pkg-config
53         bool get_use_pkgconfig() const { return use_pkgconfig; }
54
55         /** Prepares the package for building.  Recursively prepares all required
56         packages, populates build info and creates targets. */
57         void prepare();
58
59         bool is_prepared() const { return prepared; }
60 protected:
61         virtual void create_build_info() { }
62
63         virtual void create_targets() { }
64
65 public:
66         virtual void save_caches() { }
67 };
68
69 #endif