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