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