6 #include <msp/datafile/loader.h>
7 #include <msp/fs/path.h>
8 #include "architecture.h"
9 #include "buildgraph.h"
10 #include "buildtype.h"
13 #include "packagemanager.h"
15 #include "toolchain.h"
16 #include "virtualfilesystem.h"
23 This class ties everything else together. It also contains code for loading
24 build files and supervising the build process.
29 class Loader: public Msp::DataFile::ObjectLoader<Builder>
32 const Config::InputOptions *options;
36 Loader(Builder &, const Config::InputOptions * = 0, bool = false);
40 void architecture(const std::string &);
41 void binpkg(const std::string &);
42 void build_type(const std::string &);
43 void package(const std::string &);
47 PackageManager package_manager;
49 Architecture native_arch;
50 Architecture *current_arch = 0;
51 std::map<std::string, BuildType> build_types;
52 BuildType *build_type = 0;
54 VirtualFileSystem vfs;
55 BuildGraph build_graph;
56 Logger default_logger;
59 bool auto_prefix = true;
61 Msp::FS::Path tempdir = "temp";
63 Loader *top_loader = 0;
69 PackageManager &get_package_manager() { return package_manager; }
71 void set_architecture(const std::string &);
72 const Architecture &get_current_arch() const { return *current_arch; }
73 const Architecture &get_native_arch() const { return native_arch; }
74 void set_build_type(const std::string &);
75 std::vector<std::string> get_build_types() const;
76 const BuildType &get_build_type() const;
77 BuildGraph &get_build_graph() { return build_graph; }
78 void set_prefix(const Msp::FS::Path &);
79 void set_temp_directory(const Msp::FS::Path &);
80 const Msp::FS::Path &get_prefix() const { return prefix; }
81 const Msp::FS::Path &get_temp_directory() const { return tempdir; }
84 void update_auto_prefix();
87 void add_default_tools();
88 const Toolchain &get_toolchain() const { return toolchain; }
89 VirtualFileSystem &get_vfs() { return vfs; }
90 void set_logger(const Logger *);
91 const Logger &get_logger() const { return *logger; }
93 std::vector<std::string> collect_problems() const;
95 /** Loads a build file. If opts is not null, it is used to configure any
96 packages loaded from this file. If all is true, external packages are also
98 void load_build_file(const Msp::FS::Path &, const Config::InputOptions *opts = 0, bool all = false);
100 /** Saves package configuration and dependency caches. */
103 /** Builds the goal targets. The build graph must be prepared first. */
104 int build(unsigned jobs = 1, bool dry_run = false, bool show_progress = false);
106 /** Cleans buildable targets. If all is true, cleans all packages.
107 Otherwise cleans only the default package. */
108 int clean(bool all = false, bool dry_run = false);
110 int do_create_makefile();