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 std::vector<std::string> overlays;
43 Package::Requirements required_pkgs;
45 InstallMap install_map;
47 std::vector<std::string> problems;
49 Component(SourcePackage &p, const std::string &n): package(p), name(n) { }
51 virtual ~Component() { }
53 const SourcePackage &get_package() const { return package; }
54 const std::string &get_name() const { return name; }
56 /** Returns a list of sources for the component. They may refer to
57 directories or individual files. */
58 const std::vector<Msp::FS::Path> &get_sources() const { return sources; }
60 const std::vector<std::string> &get_overlays() const { return overlays; }
63 /** Returns a list of all source files for the component. */
64 std::vector<Msp::FS::Path> collect_source_files() const;
67 bool get_install() const { return install; }
68 const InstallMap &get_install_map() const { return install_map; }
69 const Package::Requirements &get_required_packages() const { return required_pkgs; }
70 bool is_default() const { return deflt; }
71 bool is_broken() const { return broken; }
72 const std::vector<std::string> &get_problems() const { return problems; }
74 /** Prepares any required packages. */
77 Msp::FS::Path get_temp_directory() const;
78 std::string flatten_source_path(const Msp::FS::Path &) const;
80 /** Prepares the build information for building. Pulls build info from the
81 parent and dependency packages, and adds any component-specific flags. */
82 virtual void create_build_info();
84 virtual void update_exported_build_info(BuildInfo &) const { }
86 const BuildInfo &get_build_info() const { return build_info; }
88 BuildInfo get_build_info_for_path(const Msp::FS::Path &) const;
90 virtual void create_targets() const = 0;