]> git.tdb.fi Git - builder.git/blob - source/package.h
Add command line options (not all of them work yet)
[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                 void headers(const std::string &);
43         };
44
45         Package(Builder &, const std::string &, const Msp::Path::Path &);
46         Package(Builder &, const std::string &, const std::vector<std::string> &);
47         const std::string   &get_name() const       { return name; }
48         const Msp::Path::Path &get_source() const   { return source; }
49         const ComponentList &get_components() const { return components; }
50         bool                get_buildable() const   { return buildable; }
51         const Config        &get_config() const     { return config; }
52         const std::list<PackageRef> &get_requires() const { return requires; }
53         const BuildInfo     &get_build_info() const { return build_info; }
54         const BuildInfo     &get_exported_binfo() const { return export_binfo; }
55         void                resolve_refs();
56         void                create_build_info();
57         void                process_options(const RawOptionMap &);
58
59         static Package *create(Builder &, const std::string &);
60 private:
61         enum InstallFlags
62         {
63                 INCLUDE=1,
64                 BIN=2,
65                 LIB=4,
66                 DATA=8
67         };
68         
69         Builder       &builder;
70         std::string   name;
71         std::string   version;
72         std::string   description;
73         std::list<PackageRef> requires;
74         BuildInfo     build_info;
75         BuildInfo     export_binfo;
76         Msp::Path::Path source;
77         bool          buildable;
78         ComponentList components;
79         Config        config;
80         bool          build_info_ready;
81
82         void init_buildable();
83         unsigned get_install_flags();
84 };
85
86 #endif