]> git.tdb.fi Git - builder.git/blob - source/component.h
Drop support for generic tarball components
[builder.git] / source / component.h
1 #ifndef COMPONENT_H_
2 #define COMPONENT_H_
3
4 #include <string>
5 #include <msp/datafile/objectloader.h>
6 #include <msp/fs/path.h>
7 #include "buildinfo.h"
8 #include "installmap.h"
9 #include "package.h"
10
11 class SourcePackage;
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         class Loader: public Msp::DataFile::ObjectLoader<Component>
23         {
24         public:
25                 Loader(Component &);
26         private:
27                 void build_info();
28                 void if_arch(const std::string &);
29                 void if_feature(const std::string &);
30                 void install_map();
31                 void overlay(const std::string &);
32                 void require(const std::string &);
33                 void source(const std::string &);
34         };
35
36         typedef std::list<Msp::FS::Path> SourceList;
37         typedef std::list<std::string> OverlayList;
38
39 protected:
40         SourcePackage &package;
41         std::string name;
42         SourceList sources;
43         OverlayList overlays;
44         bool install;
45         BuildInfo build_info;
46         Package::Requirements requires;
47         bool deflt;
48         InstallMap install_map;
49         std::list<std::string> problems;
50
51         Component(SourcePackage &, const std::string &);
52 public:
53         virtual ~Component() { }
54
55         const SourcePackage &get_package() const { return package; }
56         const std::string &get_name() const { return name; }
57
58         /** Returns a list of sources for the component.  They may refer to
59         directories or individual files. */
60         const SourceList &get_sources() const { return sources; }
61
62         const OverlayList &get_overlays() const { return overlays; }
63
64 protected:
65         /** Returns a list of all source files for the component. */
66         SourceList collect_source_files() const;
67
68 public:
69         bool get_install() const { return install; }
70         const InstallMap &get_install_map() const { return install_map; }
71         const Package::Requirements &get_required_packages() const { return requires; }
72         bool is_default() const { return deflt; }
73         const std::list<std::string> &get_problems() const { return problems; }
74
75         /** Prepares any required packages. */
76         void prepare();
77
78         /** Prepares the build information for building.  Pulls build info from the
79         parent and dependency packages, and adds any component-specific flags. */
80         virtual void create_build_info();
81
82         virtual void update_exported_build_info(BuildInfo &) const { }
83
84         const BuildInfo &get_build_info() const { return build_info; }
85
86         BuildInfo get_build_info_for_path(const Msp::FS::Path &) const;
87
88         virtual void create_targets() const = 0;
89 };
90
91 #endif