]> git.tdb.fi Git - builder.git/blob - source/component.h
Remove dead code
[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                 HEADERS,
41                 LIBRARY,
42                 PROGRAM,
43                 MODULE,
44                 DATAFILE,
45                 INSTALL,
46                 TARBALL
47         };
48
49 protected:
50         SourcePackage &pkg;
51         Type type;
52         std::string name;
53         StringList sources;
54         bool install;
55         BuildInfo build_info;
56         PackageList requires;
57         bool deflt;
58         InstallMap install_map;
59
60 public:
61         Component(SourcePackage &, Type, const std::string &);
62         const SourcePackage &get_package() const { return pkg; }
63         Type get_type() const { return type; }
64         const std::string &get_name() const { return name; }
65         const StringList &get_sources() const { return sources; }
66         const BuildInfo &get_build_info() const { return build_info; }
67         bool get_install() const { return install; }
68         const PackageList &get_requires() const { return requires; }
69         bool is_default() const { return deflt; }
70         const InstallMap &get_install_map() const { return install_map; }
71
72         void configure(const StringMap &, unsigned);
73
74         /** Prepares the build information for building.  Pulls build info from the
75         parent and dependency packages, and adds any component-specific flags. */
76         void create_build_info();
77
78         void create_targets() const;
79
80 protected:
81         /** Returns a list of all source files for the component. */
82         PathList collect_source_files() const;
83 };
84
85 typedef std::list<Component> ComponentList;
86
87 #endif