]> git.tdb.fi Git - builder.git/blob - source/component.h
Change component order so that miscellaneous installed files get in tarball
[builder.git] / source / component.h
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2006-2009  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef COMPONENT_H_
9 #define COMPONENT_H_
10
11 #include <string>
12 #include <msp/datafile/loader.h>
13 #include <msp/fs/path.h>
14 #include "buildinfo.h"
15 #include "misc.h"
16 #include "package.h"
17
18 class SourcePackage;
19
20 /**
21 Components specify things to be built.  Each component may build one binary (it
22 may also build none), as well as install a bunch of headers.  Components inherit
23 dependencies and build info from the package they belong to, and may also add
24 their own.
25 */
26 class Component
27 {
28 public:
29         class Loader: public Msp::DataFile::Loader
30         {
31         private:
32                 Component &comp;
33                 std::string inst_hdr;
34
35         public:
36                 Loader(Component &);
37                 Component &get_object() { return comp; }
38         private:
39                 virtual void finish();
40                 void source(const std::string &);
41                 void require(const std::string &);
42                 void modular();
43                 void host(const std::string &);
44                 void install_headers(const std::string &);
45                 void build_info();
46         };
47
48         enum Type
49         {
50                 HEADERS,
51                 LIBRARY,
52                 PROGRAM,
53                 MODULE,
54                 DATAFILE,
55                 INSTALL,
56                 TARBALL
57         };
58
59 protected:
60         SourcePackage &pkg;
61         Type type;
62         std::string name;
63         PathList sources;
64         bool install;
65         const Component *module_host;
66         bool modular;
67         BuildInfo build_info;
68         PackageList requires;
69         bool deflt;
70
71 public:
72         Component(SourcePackage &, Type, const std::string &);
73         const SourcePackage &get_package() const { return pkg; }
74         Type get_type() const { return type; }
75         const std::string &get_name() const { return name; }
76         const PathList &get_sources() const { return sources; }
77         const BuildInfo &get_build_info() const { return build_info; }
78         bool get_install() const { return install; }
79         bool is_modular() const { return modular; }
80         const PackageList &get_requires() const { return requires; }
81         bool is_default() const { return deflt; }
82
83         /** Prepares the build information for building.  Pulls build info from the
84         parent and dependency packages, and adds any component-specific flags. */
85         void create_build_info();
86
87         void create_targets() const;
88
89 protected:
90         /** Returns a list of all source files for the component. */
91         PathList collect_source_files() const;
92 };
93
94 typedef std::list<Component> ComponentList;
95
96 #endif