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 binpkg(const std::string &);
42 void cross_prefix(const std::string &, 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 StringMap cross_prefixes;
77 ProfileTemplateMap profile_tmpl;
79 VirtualFileSystem vfs;
89 std::string build_file;
99 static std::string usagemsg;
100 static std::string helpmsg;
103 Builder(int, char **);
107 bool get_dry_run() const { return dry_run; }
109 PackageManager &get_package_manager() { return package_manager; }
110 SourcePackage *get_main_package() const { return main_pkg; }
112 /** Looks up a target by name. Returns 0 if no such target exists. */
113 Target *get_target(const std::string &) const;
115 const TargetMap &get_targets() const { return targets; }
117 const Msp::FS::Path &get_cwd() const { return cwd; }
118 const Architecture &get_current_arch() const { return *current_arch; }
119 const Architecture &get_native_arch() const { return native_arch; }
120 const Msp::FS::Path &get_prefix() const { return prefix; }
121 const StringList &get_warnings() const { return warnings; }
122 void apply_profile_template(Config &, const std::string &) const;
124 const Toolchain &get_toolchain() const { return toolchain; }
125 VirtualFileSystem &get_vfs() { return vfs; }
126 const Logger &get_logger() const { return logger; }
128 /** Adds a target to both the target map and the new target queue. Called
129 from Target constructor. */
130 void add_target(Target *);
131 void register_path(const Msp::FS::Path &, FileTarget *);
133 void problem(const std::string &, const std::string &);
135 static void usage(const char *, const char *, bool);
137 /** Loads a build file. Returns 0 on success or -1 if the file could not be
139 int load_build_file(const Msp::FS::Path &);
142 /** Creates targets for all packages and prepares them for building.
143 Returns 0 if everything went ok, -1 if something bad happened and a build
144 shouldn't be attempted. */
145 int create_targets();
147 /** Supervises the build process, starting new actions when slots become
151 /** Cleans buildable targets. If clean is 1, cleans only the default
152 package. If clean is 2 or greater, cleans all buildable packages.
156 int do_create_makefile();
158 /** Prints out information about the default package. */