]> git.tdb.fi Git - builder.git/blob - source/package.h
Refactor package configuration
[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 class Package;
14
15 typedef std::list<Package *> PackageList;
16
17 /**
18 A package is a distributable piece of software.  They consist of one or more
19 Components and may depend on other packages.  Packages also have configuration
20 to determine where files are installed and which features to include (features
21 NYI).
22 */
23 class Package
24 {
25 public:
26         /// Loads a package from a file.
27         class Loader: public Msp::Parser::Loader
28         {
29         public:
30                 Loader(Package &);
31                 Package &get_object() { return pkg; }
32         private:
33                 Package &pkg;
34                 
35                 void require(const std::string &);
36                 void program(const std::string &);
37                 void library(const std::string &);
38                 void headers(const std::string &);
39                 void build_info();
40         };
41
42         Package(Builder &, const std::string &, const Msp::Path::Path &);
43         void                set_path(const Msp::Path::Path &);
44         const std::string   &get_name() const           { return name; }
45         const Msp::Path::Path &get_source() const       { return source; }
46         const ComponentList &get_components() const     { return components; }
47         bool                get_buildable() const       { return buildable; }
48         const Config        &get_config() const         { return config; }
49         const PkgRefList    &get_requires() const       { return requires; }
50         const BuildInfo     &get_build_info() const     { return build_info; }
51         const BuildInfo     &get_exported_binfo() const { return export_binfo; }
52         Builder             &get_builder() const        { return builder; }
53         bool                get_need_path() const       { return need_path; }
54         void                resolve_refs();
55         void                configure(const RawOptionMap &, unsigned);
56
57         static Package *create(Builder &, const std::string &);
58 private:
59         enum InstallFlags
60         {
61                 INCLUDE=1,
62                 BIN=2,
63                 LIB=4,
64                 DATA=8
65         };
66         
67         Builder       &builder;
68         
69         std::string   name;
70         std::string   version;
71         std::string   description;
72         
73         bool          buildable;
74         Msp::Path::Path source;
75         PkgRefList    requires;
76         PackageList   all_reqs;
77         BuildInfo     build_info;
78         BuildInfo     export_binfo;
79         ComponentList components;
80         Config        config;
81         bool          conf_done;
82
83         bool          need_path;
84         Msp::Path::Path path;
85
86         Package(Builder &, const std::string &, const std::vector<std::string> &);
87         void     init_config();
88         void     create_build_info();
89         unsigned get_install_flags();
90 };
91
92 #endif