]> git.tdb.fi Git - builder.git/blob - source/builder.h
Remove an unused member
[builder.git] / source / builder.h
1 #ifndef BUILDER_H_
2 #define BUILDER_H_
3
4 #include <list>
5 #include <map>
6 #include <string>
7 #include <msp/core/application.h>
8 #include <msp/datafile/loader.h>
9 #include <msp/fs/path.h>
10 #include "architecture.h"
11 #include "config.h"
12 #include "misc.h"
13 #include "packagemanager.h"
14 #include "problem.h"
15 #include "target.h"
16 #include "toolchain.h"
17 #include "virtualfilesystem.h"
18
19 class Analyzer;
20 class Config;
21 class FileTarget;
22 class Package;
23 class SourcePackage;
24 class VirtualTarget;
25
26 /**
27 The main application class.  Controls and owns everything.  Rules the world.
28 */
29 class Builder: public Msp::RegisteredApplication<Builder>
30 {
31 private:
32         class Loader: public Msp::DataFile::Loader
33         {
34         private:
35                 Builder &bld;
36                 Msp::FS::Path src;
37
38         public:
39                 Loader(Builder &, const Msp::FS::Path &);
40         private:
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 &);
45         };
46
47         class ProfileLoader: public Msp::DataFile::Loader
48         {
49         private:
50                 StringMap &profile;
51
52         public:
53                 ProfileLoader(StringMap &);
54         private:
55                 void option(const std::string &, const std::string &);
56         };
57
58 public:
59         typedef std::map<std::string, Target *> TargetMap;
60         typedef std::list<Target *> TargetList;
61
62 private:
63         typedef std::map<std::string, StringMap> ProfileTemplateMap;
64
65         StringList cmdline_targets;
66         StringMap cmdline_options;
67         Msp::FS::Path cwd;
68
69         PackageManager package_manager;
70         SourcePackage *main_pkg;
71
72         TargetMap targets;
73
74         Architecture native_arch;
75         Architecture *current_arch;
76         StringMap cross_prefixes;
77         ProfileTemplateMap profile_tmpl;
78         Toolchain toolchain;
79         VirtualFileSystem vfs;
80
81         ProblemList problems;
82         Analyzer *analyzer;
83         bool build;
84         unsigned clean;
85         bool dry_run;
86         bool help;
87         unsigned verbose;
88         bool show_progress;
89         std::string build_file;
90         unsigned jobs;
91         StringList what_if;
92         bool conf_all;
93         bool conf_only;
94         bool build_all;
95         bool create_makefile;
96         Msp::FS::Path prefix;
97         StringList warnings;
98
99         static std::string usagemsg;
100         static std::string helpmsg;
101
102 public:
103         Builder(int, char **);
104         ~Builder();
105
106         int main();
107         unsigned get_verbose() const { return verbose; }
108         bool get_dry_run() const { return dry_run; }
109
110         PackageManager &get_package_manager() { return package_manager; }
111         SourcePackage *get_main_package() const { return main_pkg; }
112
113         /** Looks up a target by name.  Returns 0 if no such target exists. */
114         Target *get_target(const std::string &) const;
115
116         const TargetMap &get_targets() const { return targets; }
117
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;
124
125         const Toolchain &get_toolchain() const { return toolchain; }
126         VirtualFileSystem &get_vfs() { return vfs; }
127
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 *);
132
133         void problem(const std::string &, const std::string &);
134
135         static void usage(const char *, const char *, bool);
136
137         /** Loads a build file.  Returns 0 on success or -1 if the file could not be
138         opened. */
139         int load_build_file(const Msp::FS::Path &);
140
141 private:
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();
146
147         /** Supervises the build process, starting new actions when slots become
148         available. */
149         int do_build();
150
151         /** Cleans buildable targets.  If clean is 1, cleans only the default
152         package.  If clean is 2 or greater, cleans all buildable packages.
153         */
154         int do_clean();
155
156         int do_create_makefile();
157
158         /** Prints out information about the default package. */
159         void package_help();
160 };
161
162 #endif