7 #include <msp/core/application.h>
8 #include <msp/datafile/loader.h>
9 #include <msp/fs/path.h>
10 #include "architecture.h"
14 #include "packagemanager.h"
17 #include "toolchain.h"
18 #include "virtualfilesystem.h"
27 The main application class. Controls and owns everything. Rules the world.
29 class Builder: public Msp::RegisteredApplication<Builder>
32 class Loader: public Msp::DataFile::ObjectLoader<Builder>
38 Loader(Builder &, const Msp::FS::Path &);
40 void architecture(const std::string &);
41 void binpkg(const std::string &);
42 void profile(const std::string &);
43 void package(const std::string &);
46 class ProfileLoader: public Msp::DataFile::Loader
52 ProfileLoader(StringMap &);
54 void option(const std::string &, const std::string &);
58 typedef std::map<std::string, Target *> TargetMap;
61 typedef std::map<std::string, StringMap> ProfileTemplateMap;
63 StringList cmdline_targets;
64 StringMap cmdline_options;
67 PackageManager package_manager;
68 SourcePackage *main_pkg;
72 Architecture native_arch;
73 Architecture *current_arch;
74 ProfileTemplateMap profile_tmpl;
76 VirtualFileSystem vfs;
86 std::string build_file;
96 static std::string usagemsg;
97 static std::string helpmsg;
100 Builder(int, char **);
104 bool get_dry_run() const { return dry_run; }
106 PackageManager &get_package_manager() { return package_manager; }
107 SourcePackage *get_main_package() const { return main_pkg; }
109 /** Looks up a target by name. Returns 0 if no such target exists. */
110 Target *get_target(const std::string &) const;
112 const TargetMap &get_targets() const { return targets; }
114 const Msp::FS::Path &get_cwd() const { return cwd; }
115 const Architecture &get_current_arch() const { return *current_arch; }
116 const Architecture &get_native_arch() const { return native_arch; }
117 const Msp::FS::Path &get_prefix() const { return prefix; }
118 const StringList &get_warnings() const { return warnings; }
119 void apply_profile_template(Config &, const std::string &) const;
121 const Toolchain &get_toolchain() const { return toolchain; }
122 VirtualFileSystem &get_vfs() { return vfs; }
123 const Logger &get_logger() const { return logger; }
125 /** Adds a target to both the target map and the new target queue. Called
126 from Target constructor. */
127 void add_target(Target *);
129 void problem(const std::string &, const std::string &);
131 static void usage(const char *, const char *, bool);
133 /** Loads a build file. Returns 0 on success or -1 if the file could not be
135 int load_build_file(const Msp::FS::Path &);
138 /** Creates targets for all packages and prepares them for building.
139 Returns 0 if everything went ok, -1 if something bad happened and a build
140 shouldn't be attempted. */
141 int create_targets();
143 /** Supervises the build process, starting new actions when slots become
147 /** Cleans buildable targets. If clean is 1, cleans only the default
148 package. If clean is 2 or greater, cleans all buildable packages.
152 int do_create_makefile();
154 /** Prints out information about the default package. */