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"
27 The main application class. Handles command line options and supervises the
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 build_type(const std::string &);
44 void profile(const std::string &);
45 void package(const std::string &);
49 typedef std::map<std::string, Target *> TargetMap;
52 typedef std::map<std::string, BuildType> BuildTypeMap;
54 StringList cmdline_targets;
55 Config::InputOptions cmdline_options;
58 PackageManager package_manager;
59 SourcePackage *main_pkg;
63 Architecture native_arch;
64 Architecture *current_arch;
65 BuildTypeMap build_types;
66 BuildType *build_type;
68 VirtualFileSystem vfs;
78 std::string build_file;
86 Msp::FS::Path tempdir;
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_work_directory() 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 Msp::FS::Path &get_temp_directory() const { return tempdir; }
112 const StringList &get_warnings() const { return warnings; }
114 const Toolchain &get_toolchain() const { return toolchain; }
115 VirtualFileSystem &get_vfs() { return vfs; }
116 const Logger &get_logger() const { return logger; }
118 /** Adds a target to both the target map and the new target queue. Called
119 from Target constructor. */
120 void add_target(Target *);
122 void problem(const std::string &, const std::string &);
124 static void usage(const char *, const char *, bool);
126 /** Loads a build file. Returns 0 on success or -1 if the file could not be
128 int load_build_file(const Msp::FS::Path &);
131 /** Prepares packages and targets for building. Returns true if everything
132 went ok, or false if something bad happened and a build shouldn't be
134 bool prepare_build();
136 /** Supervises the build process, starting new tasks when slots become
140 /** Cleans buildable targets. If clean is 1, cleans only the default
141 package. If clean is 2 or greater, cleans all buildable packages.
145 int do_create_makefile();
147 /** Prints out information about the default package. */