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;
60 Msp::FS::Path tempdir = "temp";
62 Loader *top_loader = 0;
68 PackageManager &get_package_manager() { return package_manager; }
70 void set_architecture(const std::string &);
71 const Architecture &get_current_arch() const { return *current_arch; }
72 const Architecture &get_native_arch() const { return native_arch; }
73 void set_build_type(const std::string &);
74 std::vector<std::string> get_build_types() const;
75 const BuildType &get_build_type() const;
76 BuildGraph &get_build_graph() { return build_graph; }
77 void set_prefix(const Msp::FS::Path &);
78 void set_temp_directory(const Msp::FS::Path &);
79 const Msp::FS::Path &get_prefix() const { return prefix; }
80 const Msp::FS::Path &get_temp_directory() const { return tempdir; }
82 void add_default_tools();
83 const Toolchain &get_toolchain() const { return toolchain; }
84 VirtualFileSystem &get_vfs() { return vfs; }
85 void set_logger(const Logger *);
86 const Logger &get_logger() const { return *logger; }
88 std::vector<std::string> collect_problems() const;
90 /** Loads a build file. If opts is not null, it is used to configure any
91 packages loaded from this file. If all is true, external packages are also
93 void load_build_file(const Msp::FS::Path &, const Config::InputOptions *opts = 0, bool all = false);
95 /** Saves package configuration and dependency caches. */
98 /** Builds the goal targets. The build graph must be prepared first. */
99 int build(unsigned jobs = 1, bool dry_run = false, bool show_progress = false);
101 /** Cleans buildable targets. If all is true, cleans all packages.
102 Otherwise cleans only the default package. */
103 int clean(bool all = false, bool dry_run = false);
105 int do_create_makefile();