]> git.tdb.fi Git - builder.git/blob - source/lib/package.h
Add visibility decorations to the library and plugins
[builder.git] / source / lib / package.h
1 #ifndef PACKAGE_H_
2 #define PACKAGE_H_
3
4 #include <string>
5 #include <vector>
6 #include <msp/datafile/objectloader.h>
7 #include "buildinfo.h"
8 #include "conditionalloader.h"
9 #include "config.h"
10 #include "libbuilder_api.h"
11
12 class Builder;
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 LIBBUILDER_API Package
20 {
21 public:
22         class Loader: public Msp::DataFile::ObjectLoader<Package>, public ArchitectureConditional
23         {
24         public:
25                 Loader(Package &);
26         private:
27                 void require(const std::string &);
28         };
29
30         using Requirements = std::vector<Package *>;
31
32 protected:
33         Builder &builder;
34
35         std::string name;
36         std::string label;
37
38         Requirements requires;
39         BuildInfo export_binfo;
40         bool prepared = false;
41         bool broken = false;
42         std::vector<std::string> problems;
43
44         bool use_pkgconfig = true;
45
46         Package(Builder &, const std::string &);
47 public:
48         virtual ~Package() { }
49
50         Builder &get_builder() const { return builder; }
51         const std::string &get_name() const { return name; }
52         const std::string &get_label() const { return label; }
53         const Requirements &get_required_packages() const { return requires; }
54
55         const BuildInfo &get_exported_build_info() const { return export_binfo; }
56
57         /// Indicates whether or not this package supports pkg-config
58         bool uses_pkgconfig() const { return use_pkgconfig; }
59
60         /** Prepares the package for building.  Recursively prepares all required
61         packages, populates build info and creates targets. */
62         void prepare();
63
64 protected:
65         virtual void do_prepare() { }
66
67 public:
68         bool is_prepared() const { return prepared; }
69
70         bool is_broken() const { return broken; }
71         const std::vector<std::string> &get_problems() const { return problems; }
72
73         virtual void save_caches() { }
74 };
75
76 #endif