]> git.tdb.fi Git - builder.git/blob - source/component.h
e1df73a5b232aefd9c554010b2767f9f7697c297
[builder.git] / source / component.h
1 #ifndef COMPONENT_H_
2 #define COMPONENT_H_
3
4 #include <string>
5 #include <msp/parser/loader.h>
6 #include <msp/path/path.h>
7 #include "buildinfo.h"
8 #include "misc.h"
9 #include "packageref.h"
10
11 class Package;
12
13 /**
14 Components specify things to be built.  Each component may build one binary (it
15 may also build none), as well as install a bunch of headers.  Components inherit
16 dependencies and build info from the package they belong to, and may also add
17 their own.
18 */
19 class Component
20 {
21 public:
22         /// Loads a Component from file.  Used from Package::Loader.
23         class Loader: public Msp::Parser::Loader
24         {
25         public:
26                 Loader(Component &);
27                 Component &get_object() { return comp; }
28         private:
29                 Component &comp;
30
31                 void source(const std::string &);
32                 void require(const std::string &);
33                 void modular();
34                 void host(const std::string &);
35                 void build_info();
36         };
37         
38         enum Type
39         {
40                 PROGRAM,
41                 LIBRARY,
42                 MODULE,
43                 HEADERS
44         };
45
46         Component(Package &, Type, const std::string &);
47         const Package     &get_package() const         { return pkg; }
48         Type              get_type() const             { return type; }
49         const std::string &get_name() const            { return name; }
50         const PathList    &get_sources() const         { return sources; }
51         const BuildInfo   &get_build_info() const      { return build_info; }
52         bool              get_install() const          { return install; }
53         const std::string &get_install_headers() const { return install_headers; }
54         bool              get_modular() const          { return modular; }
55         const PkgRefList  &get_requires() const        { return requires; }
56         void              resolve_refs();
57         void              create_build_info();
58 protected:
59         Package     &pkg;
60         Type        type;
61         std::string name;
62         PathList    sources;
63         bool        install;
64         std::string install_headers;
65         const Component *module_host;
66         bool        modular;
67         BuildInfo   build_info;
68         PkgRefList  requires;
69 };
70 typedef std::list<Component> ComponentList;
71
72 #endif