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"
28 The main application class. Controls and owns everything. Rules the world.
30 class Builder: public Msp::RegisteredApplication<Builder>
33 class Loader: public Msp::DataFile::ObjectLoader<Builder>
39 Loader(Builder &, const Msp::FS::Path &);
41 void architecture(const std::string &);
42 void binpkg(const std::string &);
43 void profile(const std::string &);
44 void package(const std::string &);
47 class ProfileLoader: public Msp::DataFile::Loader
53 ProfileLoader(StringMap &);
55 void option(const std::string &, const std::string &);
59 typedef std::map<std::string, Target *> TargetMap;
60 typedef std::list<Target *> TargetList;
63 typedef std::map<std::string, StringMap> ProfileTemplateMap;
65 StringList cmdline_targets;
66 StringMap cmdline_options;
69 PackageManager package_manager;
70 SourcePackage *main_pkg;
74 Architecture native_arch;
75 Architecture *current_arch;
76 ProfileTemplateMap profile_tmpl;
78 VirtualFileSystem vfs;
88 std::string build_file;
98 static std::string usagemsg;
99 static std::string helpmsg;
102 Builder(int, char **);
106 bool get_dry_run() const { return dry_run; }
108 PackageManager &get_package_manager() { return package_manager; }
109 SourcePackage *get_main_package() const { return main_pkg; }
111 /** Looks up a target by name. Returns 0 if no such target exists. */
112 Target *get_target(const std::string &) const;
114 const TargetMap &get_targets() const { return targets; }
116 const Msp::FS::Path &get_cwd() const { return cwd; }
117 const Architecture &get_current_arch() const { return *current_arch; }
118 const Architecture &get_native_arch() const { return native_arch; }
119 const Msp::FS::Path &get_prefix() const { return prefix; }
120 const StringList &get_warnings() const { return warnings; }
121 void apply_profile_template(Config &, const std::string &) const;
123 const Toolchain &get_toolchain() const { return toolchain; }
124 VirtualFileSystem &get_vfs() { return vfs; }
125 const Logger &get_logger() const { return logger; }
127 /** Adds a target to both the target map and the new target queue. Called
128 from Target constructor. */
129 void add_target(Target *);
130 void register_path(const Msp::FS::Path &, FileTarget *);
132 void problem(const std::string &, const std::string &);
134 static void usage(const char *, const char *, bool);
136 /** Loads a build file. Returns 0 on success or -1 if the file could not be
138 int load_build_file(const Msp::FS::Path &);
141 /** Creates targets for all packages and prepares them for building.
142 Returns 0 if everything went ok, -1 if something bad happened and a build
143 shouldn't be attempted. */
144 int create_targets();
146 /** Supervises the build process, starting new actions when slots become
150 /** Cleans buildable targets. If clean is 1, cleans only the default
151 package. If clean is 2 or greater, cleans all buildable packages.
155 int do_create_makefile();
157 /** Prints out information about the default package. */