7 #include <msp/core/application.h>
8 #include <msp/datafile/loader.h>
9 #include <msp/fs/path.h>
10 #include "architecture.h"
11 #include "buildgraph.h"
12 #include "buildtype.h"
15 #include "packagemanager.h"
18 #include "toolchain.h"
19 #include "virtualfilesystem.h"
27 The main application class. Handles command line options and supervises the
30 class Builder: public Msp::RegisteredApplication<Builder>
33 class Loader: public Msp::DataFile::ObjectLoader<Builder>
38 void architecture(const std::string &);
39 void binpkg(const std::string &);
40 void build_type(const std::string &);
41 void profile(const std::string &);
42 void package(const std::string &);
46 typedef std::list<std::string> NameList;
47 typedef std::map<std::string, BuildType> BuildTypeMap;
48 typedef std::list<Problem> ProblemList;
50 NameList cmdline_targets;
51 Config::InputOptions cmdline_options;
54 PackageManager package_manager;
56 Architecture native_arch;
57 Architecture *current_arch;
58 BuildTypeMap build_types;
59 BuildType *build_type;
61 VirtualFileSystem vfs;
62 BuildGraph build_graph;
72 std::string build_file;
80 Msp::FS::Path tempdir;
82 static std::string usagemsg;
83 static std::string helpmsg;
86 Builder(int, char **);
91 PackageManager &get_package_manager() { return package_manager; }
93 const Msp::FS::Path &get_work_directory() const { return cwd; }
94 const Architecture &get_current_arch() const { return *current_arch; }
95 const Architecture &get_native_arch() const { return native_arch; }
96 BuildGraph &get_build_graph() { return build_graph; }
97 const Msp::FS::Path &get_prefix() const { return prefix; }
98 const Msp::FS::Path &get_temp_directory() const { return tempdir; }
100 const Toolchain &get_toolchain() const { return toolchain; }
101 VirtualFileSystem &get_vfs() { return vfs; }
102 const Logger &get_logger() const { return logger; }
104 void problem(const std::string &, const std::string &);
106 static void usage(const char *, const char *, bool);
108 /** Loads a build file. Returns 0 on success or -1 if the file could not be
110 void load_build_file(const Msp::FS::Path &);
113 /** Prepares packages and targets for building. Returns true if everything
114 went ok, or false if something bad happened and a build shouldn't be
116 bool prepare_build();
118 /** Supervises the build process, starting new tasks when slots become
122 /** Cleans buildable targets. If clean is 1, cleans only the default
123 package. If clean is 2 or greater, cleans all buildable packages.
127 int do_create_makefile();
129 /** Prints out information about the default package. */