5 #include <msp/datafile/objectloader.h>
6 #include <msp/fs/path.h>
8 #include "conditionalloader.h"
9 #include "installmap.h"
10 #include "libbuilder_api.h"
16 Components specify things to be built. Each component may build one binary (it
17 may also build none), as well as install a bunch of headers. Components inherit
18 dependencies and build info from the package they belong to, and may also add
21 class LIBBUILDER_API Component
24 class LIBBUILDER_API Loader: public Msp::DataFile::ObjectLoader<Component>, public ConditionalLoader
31 void overlay(const std::string &);
32 void require(const std::string &);
33 void source(const std::string &);
37 SourcePackage &package;
39 std::vector<Msp::FS::Path> sources;
40 Msp::FS::Path source_base_path;
41 std::vector<std::string> overlays;
44 Package::Requirements required_pkgs;
46 InstallMap install_map;
48 std::vector<std::string> problems;
50 Component(SourcePackage &p, const std::string &n): package(p), name(n) { }
52 virtual ~Component() { }
54 const SourcePackage &get_package() const { return package; }
55 const std::string &get_name() const { return name; }
57 /** Returns a list of sources for the component. They may refer to
58 directories or individual files. */
59 const std::vector<Msp::FS::Path> &get_sources() const { return sources; }
61 const std::vector<std::string> &get_overlays() const { return overlays; }
64 /** Returns a list of all source files for the component. */
65 std::vector<Msp::FS::Path> collect_source_files() const;
68 bool get_install() const { return install; }
69 const InstallMap &get_install_map() const { return install_map; }
70 const Package::Requirements &get_required_packages() const { return required_pkgs; }
71 bool is_default() const { return deflt; }
72 bool is_broken() const { return broken; }
73 const std::vector<std::string> &get_problems() const { return problems; }
75 /** Prepares any required packages. */
78 Msp::FS::Path get_temp_directory() const;
79 std::string flatten_source_path(const Msp::FS::Path &) const;
81 /** Prepares the build information for building. Pulls build info from the
82 parent and dependency packages, and adds any component-specific flags. */
83 virtual void create_build_info();
85 virtual void update_exported_build_info(BuildInfo &) const { }
87 const BuildInfo &get_build_info() const { return build_info; }
89 BuildInfo get_build_info_for_path(const Msp::FS::Path &) const;
91 virtual void create_targets() const = 0;