]> git.tdb.fi Git - builder.git/blob - source/package.h
Allow requirements for components
[builder.git] / source / package.h
1 #ifndef PACKAGE_H_
2 #define PACKAGE_H_
3
4 #include <list>
5 #include <string>
6 #include <msp/parser/loader.h>
7 #include "buildinfo.h"
8 #include "component.h"
9 #include "config.h"
10 #include "packageref.h"
11
12 class Builder;
13
14 class Package
15 {
16 public:
17         class Loader: public Msp::Parser::Loader
18         {
19         public:
20                 Loader(Package &);
21                 Package &get_object() { return pkg; }
22                 ~Loader();
23         private:
24                 Package &pkg;
25                 
26                 void require(const std::string &);
27                 void program(const std::string &);
28                 void library(const std::string &);
29                 void headers(const std::string &);
30                 void build_info();
31         };
32
33         Package(Builder &, const std::string &, const Msp::Path::Path &);
34         Package(Builder &, const std::string &, const std::vector<std::string> &);
35         const std::string   &get_name() const       { return name; }
36         const Msp::Path::Path &get_source() const   { return source; }
37         const ComponentList &get_components() const { return components; }
38         bool                get_buildable() const   { return buildable; }
39         const Config        &get_config() const     { return config; }
40         const std::list<PackageRef> &get_requires() const { return requires; }
41         const BuildInfo     &get_build_info() const { return build_info; }
42         const BuildInfo     &get_exported_binfo() const { return export_binfo; }
43         Builder             &get_builder() const    { return builder; }
44         void                resolve_refs();
45         void                create_build_info();
46         void                process_options(const RawOptionMap &);
47
48         static Package *create(Builder &, const std::string &);
49 private:
50         enum InstallFlags
51         {
52                 INCLUDE=1,
53                 BIN=2,
54                 LIB=4,
55                 DATA=8
56         };
57         
58         Builder       &builder;
59         std::string   name;
60         std::string   version;
61         std::string   description;
62         std::list<PackageRef> requires;
63         BuildInfo     build_info;
64         BuildInfo     export_binfo;
65         Msp::Path::Path source;
66         bool          buildable;
67         ComponentList components;
68         Config        config;
69         bool          build_info_ready;
70
71         void init_buildable();
72         unsigned get_install_flags();
73 };
74
75 #endif