]> git.tdb.fi Git - builder.git/blob - source/package.h
Builder can build itself now.
[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
11 class Builder;
12 class Package;
13
14 class PackageRef
15 {
16 public:
17         PackageRef(Builder &, const std::string &);
18         const std::string &get_name() const { return name; }
19         Package *get_package() const { return package; }
20         Package *resolve();
21 private:
22         Builder     &builder;
23         std::string name;
24         Package     *package;
25 };
26
27 class Package
28 {
29 public:
30         class Loader: public Msp::Parser::Loader
31         {
32         public:
33                 Loader(Package &);
34                 Package &get_object() { return pkg; }
35                 ~Loader();
36         private:
37                 Package &pkg;
38                 
39                 void require(const std::string &);
40                 void program(const std::string &);
41                 void library(const std::string &);
42         };
43
44         Package(Builder &, const std::string &, const Msp::Path::Path &);
45         Package(Builder &, const std::string &, const std::vector<std::string> &);
46         const std::string   &get_name() const       { return name; }
47         const Msp::Path::Path &get_source() const   { return source; }
48         const ComponentList &get_components() const { return components; }
49         bool                get_buildable() const   { return buildable; }
50         const Config        &get_config() const     { return config; }
51         const std::list<PackageRef> &get_requires() const { return requires; }
52         const BuildInfo     &get_build_info() const { return build_info; }
53         const BuildInfo     &get_exported_binfo() const { return export_binfo; }
54         void                resolve_refs();
55         void                create_build_info();
56         void                process_options(const RawOptionMap &);
57
58         static Package *create(Builder &, const std::string &);
59 private:
60         enum InstallFlags
61         {
62                 INCLUDE=1,
63                 BIN=2,
64                 LIB=4,
65                 DATA=8
66         };
67         
68         Builder       &builder;
69         std::string   name;
70         std::string   version;
71         std::string   description;
72         std::list<PackageRef> requires;
73         BuildInfo     build_info;
74         BuildInfo     export_binfo;
75         Msp::Path::Path source;
76         bool          buildable;
77         ComponentList components;
78         Config        config;
79         bool          build_info_ready;
80
81         void init_buildable();
82         unsigned get_install_flags();
83 };
84
85 #endif