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>
38 void architecture(const std::string &);
39 void binpkg(const std::string &);
40 void build_type(const std::string &);
41 void profile(const std::string &);
42 void package(const std::string &);
46 typedef std::map<std::string, Target *> TargetMap;
49 typedef std::map<std::string, BuildType> BuildTypeMap;
51 StringList cmdline_targets;
52 Config::InputOptions cmdline_options;
55 PackageManager package_manager;
56 SourcePackage *main_pkg;
60 Architecture native_arch;
61 Architecture *current_arch;
62 BuildTypeMap build_types;
63 BuildType *build_type;
65 VirtualFileSystem vfs;
75 std::string build_file;
83 Msp::FS::Path tempdir;
85 static std::string usagemsg;
86 static std::string helpmsg;
89 Builder(int, char **);
94 PackageManager &get_package_manager() { return package_manager; }
96 /** Looks up a target by name. Returns 0 if no such target exists. */
97 Target *get_target(const std::string &) const;
99 const TargetMap &get_targets() const { return targets; }
101 const Msp::FS::Path &get_work_directory() const { return cwd; }
102 const Architecture &get_current_arch() const { return *current_arch; }
103 const Architecture &get_native_arch() const { return native_arch; }
104 const Msp::FS::Path &get_prefix() const { return prefix; }
105 const Msp::FS::Path &get_temp_directory() const { return tempdir; }
107 const Toolchain &get_toolchain() const { return toolchain; }
108 VirtualFileSystem &get_vfs() { return vfs; }
109 const Logger &get_logger() const { return logger; }
111 /** Adds a target. It can later be retrieved by name. Called from Target
113 void add_target(Target *);
115 /** Adds a target that is a primary build goal. Such targets will be added
116 as dependencies of the "world" virtual target. If the target belongs to a
117 default component of the main package, it's also added to the "default"
119 void add_primary_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 void load_build_file(const Msp::FS::Path &);
130 /** Prepares packages and targets for building. Returns true if everything
131 went ok, or false if something bad happened and a build shouldn't be
133 bool prepare_build();
135 /** Supervises the build process, starting new tasks 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. */