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::Loader
40 Loader(Builder &, const Msp::FS::Path &);
42 void binpkg(const std::string &);
43 void cross_prefix(const std::string &, const std::string &);
44 void profile(const std::string &);
45 void package(const std::string &);
48 class ProfileLoader: public Msp::DataFile::Loader
54 ProfileLoader(StringMap &);
56 void option(const std::string &, const std::string &);
60 typedef std::map<std::string, Target *> TargetMap;
61 typedef std::list<Target *> TargetList;
64 typedef std::map<std::string, StringMap> ProfileTemplateMap;
66 StringList cmdline_targets;
67 StringMap cmdline_options;
70 PackageManager package_manager;
71 SourcePackage *main_pkg;
75 Architecture native_arch;
76 Architecture *current_arch;
77 StringMap cross_prefixes;
78 ProfileTemplateMap profile_tmpl;
80 VirtualFileSystem vfs;
90 std::string build_file;
100 static std::string usagemsg;
101 static std::string helpmsg;
104 Builder(int, char **);
108 bool get_dry_run() const { return dry_run; }
110 PackageManager &get_package_manager() { return package_manager; }
111 SourcePackage *get_main_package() const { return main_pkg; }
113 /** Looks up a target by name. Returns 0 if no such target exists. */
114 Target *get_target(const std::string &) const;
116 const TargetMap &get_targets() const { return targets; }
118 const Msp::FS::Path &get_cwd() const { return cwd; }
119 const Architecture &get_current_arch() const { return *current_arch; }
120 const Architecture &get_native_arch() const { return native_arch; }
121 const Msp::FS::Path &get_prefix() const { return prefix; }
122 const StringList &get_warnings() const { return warnings; }
123 void apply_profile_template(Config &, const std::string &) const;
125 const Toolchain &get_toolchain() const { return toolchain; }
126 VirtualFileSystem &get_vfs() { return vfs; }
127 const Logger &get_logger() const { return logger; }
129 /** Adds a target to both the target map and the new target queue. Called
130 from Target constructor. */
131 void add_target(Target *);
132 void register_path(const Msp::FS::Path &, FileTarget *);
134 void problem(const std::string &, const std::string &);
136 static void usage(const char *, const char *, bool);
138 /** Loads a build file. Returns 0 on success or -1 if the file could not be
140 int load_build_file(const Msp::FS::Path &);
143 /** Creates targets for all packages and prepares them for building.
144 Returns 0 if everything went ok, -1 if something bad happened and a build
145 shouldn't be attempted. */
146 int create_targets();
148 /** Supervises the build process, starting new actions when slots become
152 /** Cleans buildable targets. If clean is 1, cleans only the default
153 package. If clean is 2 or greater, cleans all buildable packages.
157 int do_create_makefile();
159 /** Prints out information about the default package. */