6 #include <msp/core/module.h>
7 #include <msp/datafile/loader.h>
8 #include <msp/fs/path.h>
9 #include "architecture.h"
10 #include "buildgraph.h"
11 #include "buildtype.h"
14 #include "packagemanager.h"
16 #include "toolchain.h"
17 #include "virtualfilesystem.h"
25 This class ties everything else together. It also contains code for loading
26 build files and supervising the build process.
31 class Loader: public Msp::DataFile::ObjectLoader<Builder>
34 const Config::InputOptions *options;
38 Loader(Builder &, const Config::InputOptions * = 0, bool = false);
42 void architecture(const std::string &);
43 void binpkg(const std::string &);
44 void build_type(const std::string &);
45 void package(const std::string &);
52 Msp::Module *module = nullptr;
53 Plugin *plugin = nullptr;
55 LoadedPlugin() = default;
56 LoadedPlugin(LoadedPlugin &&);
60 std::vector<LoadedPlugin> plugins;
61 PackageManager package_manager;
63 Architecture native_arch;
64 Architecture *current_arch = 0;
65 std::map<std::string, BuildType> build_types;
66 BuildType *build_type = 0;
68 VirtualFileSystem vfs;
69 BuildGraph build_graph;
70 Logger default_logger;
73 bool auto_prefix = true;
75 Msp::FS::Path tempdir = "temp";
77 Loader *top_loader = 0;
84 PackageManager &get_package_manager() { return package_manager; }
86 void set_architecture(const std::string &);
87 const Architecture &get_current_arch() const { return *current_arch; }
88 const Architecture &get_native_arch() const { return native_arch; }
89 void set_build_type(const std::string &);
90 std::vector<std::string> get_build_types() const;
91 const BuildType &get_build_type() const;
92 BuildGraph &get_build_graph() { return build_graph; }
93 void set_prefix(const Msp::FS::Path &);
94 void set_temp_directory(const Msp::FS::Path &);
95 const Msp::FS::Path &get_prefix() const { return prefix; }
96 const Msp::FS::Path &get_temp_directory() const { return tempdir; }
99 void update_auto_prefix();
102 void add_default_tools();
103 const Toolchain &get_toolchain() const { return toolchain; }
104 VirtualFileSystem &get_vfs() { return vfs; }
105 void set_logger(const Logger *);
106 const Logger &get_logger() const { return *logger; }
108 std::vector<std::string> collect_problems() const;
110 /** Loads a build file. If opts is not null, it is used to configure any
111 packages loaded from this file. If all is true, external packages are also
113 void load_build_file(const Msp::FS::Path &, const Config::InputOptions *opts = 0, bool all = false);
115 /** Saves package configuration and dependency caches. */
118 /** Builds the goal targets. The build graph must be prepared first. */
119 int build(unsigned jobs = 1, bool dry_run = false, bool show_progress = false);
121 /** Cleans buildable targets. If all is true, cleans all packages.
122 Otherwise cleans only the default package. */
123 int clean(bool all = false, bool dry_run = false);
125 int do_create_makefile();