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>
36 const Config::InputOptions *options;
40 Loader(Builder &, const Config::InputOptions * = 0, bool = false);
44 void architecture(const std::string &);
45 void binpkg(const std::string &);
46 void build_type(const std::string &);
47 void profile(const std::string &);
48 void package(const std::string &);
52 typedef std::list<std::string> NameList;
53 typedef std::map<std::string, BuildType> BuildTypeMap;
54 typedef std::list<Problem> ProblemList;
56 NameList cmdline_targets;
57 Config::InputOptions cmdline_options;
60 PackageManager package_manager;
62 Architecture native_arch;
63 Architecture *current_arch;
64 BuildTypeMap build_types;
65 BuildType *build_type;
67 VirtualFileSystem vfs;
68 BuildGraph build_graph;
78 std::string build_file;
86 Msp::FS::Path tempdir;
90 static std::string usagemsg;
91 static std::string helpmsg;
94 Builder(int, char **);
99 PackageManager &get_package_manager() { return package_manager; }
101 const Architecture &get_current_arch() const { return *current_arch; }
102 const Architecture &get_native_arch() const { return native_arch; }
103 BuildGraph &get_build_graph() { return build_graph; }
104 const Msp::FS::Path &get_prefix() const { return prefix; }
105 const Msp::FS::Path &get_temp_directory() const { return tempdir; }
107 const Toolchain &get_toolchain() const { return toolchain; }
108 VirtualFileSystem &get_vfs() { return vfs; }
109 const Logger &get_logger() const { return logger; }
111 void problem(const std::string &, const std::string &);
113 static void usage(const char *, const char *, bool);
115 /** Loads a build file. If opts is not null, it is used to configure any
116 packages loaded from this file. If all is true, external packages are also
118 void load_build_file(const Msp::FS::Path &, const Config::InputOptions *opts = 0, bool all = false);
121 /** Prepares packages and targets for building. Returns true if everything
122 went ok, or false if something bad happened and a build shouldn't be
124 bool prepare_build();
126 /** Supervises the build process, starting new tasks when slots become
130 /** Cleans buildable targets. If clean is 1, cleans only the default
131 package. If clean is 2 or greater, cleans all buildable packages.
135 int do_create_makefile();
137 /** Prints out information about the default package. */