7 #include <msp/core/application.h>
8 #include <msp/datafile/loader.h>
9 #include <msp/fs/path.h>
10 #include "architecture.h"
11 #include "buildtype.h"
15 #include "packagemanager.h"
18 #include "toolchain.h"
19 #include "virtualfilesystem.h"
28 The main application class. Handles command line options and supervises the
31 class Builder: public Msp::RegisteredApplication<Builder>
34 class Loader: public Msp::DataFile::ObjectLoader<Builder>
40 Loader(Builder &, const Msp::FS::Path &);
42 void architecture(const std::string &);
43 void binpkg(const std::string &);
44 void build_type(const std::string &);
45 void profile(const std::string &);
46 void package(const std::string &);
50 typedef std::map<std::string, Target *> TargetMap;
53 typedef std::map<std::string, BuildType> BuildTypeMap;
55 StringList cmdline_targets;
56 StringMap cmdline_options;
59 PackageManager package_manager;
60 SourcePackage *main_pkg;
64 Architecture native_arch;
65 Architecture *current_arch;
66 BuildTypeMap build_types;
67 BuildType *build_type;
69 VirtualFileSystem vfs;
79 std::string build_file;
89 static std::string usagemsg;
90 static std::string helpmsg;
93 Builder(int, char **);
97 bool get_dry_run() const { return dry_run; }
99 PackageManager &get_package_manager() { return package_manager; }
100 SourcePackage *get_main_package() const { return main_pkg; }
102 /** Looks up a target by name. Returns 0 if no such target exists. */
103 Target *get_target(const std::string &) const;
105 const TargetMap &get_targets() const { return targets; }
107 const Msp::FS::Path &get_cwd() const { return cwd; }
108 const Architecture &get_current_arch() const { return *current_arch; }
109 const Architecture &get_native_arch() const { return native_arch; }
110 const Msp::FS::Path &get_prefix() const { return prefix; }
111 const StringList &get_warnings() const { return warnings; }
113 const Toolchain &get_toolchain() const { return toolchain; }
114 VirtualFileSystem &get_vfs() { return vfs; }
115 const Logger &get_logger() const { return logger; }
117 /** Adds a target to both the target map and the new target queue. Called
118 from Target constructor. */
119 void add_target(Target *);
121 void problem(const std::string &, const std::string &);
123 static void usage(const char *, const char *, bool);
125 /** Loads a build file. Returns 0 on success or -1 if the file could not be
127 int load_build_file(const Msp::FS::Path &);
130 /** Creates targets for all packages and prepares them for building.
131 Returns 0 if everything went ok, -1 if something bad happened and a build
132 shouldn't be attempted. */
133 int create_targets();
135 /** Supervises the build process, starting new actions when slots become
139 /** Cleans buildable targets. If clean is 1, cleans only the default
140 package. If clean is 2 or greater, cleans all buildable packages.
144 int do_create_makefile();
146 /** Prints out information about the default package. */