]> git.tdb.fi Git - builder.git/blob - source/builder.h
2bfa32a429c7c9c137c19312616cd0f42972c643
[builder.git] / source / builder.h
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef BUILDER_H_
9 #define BUILDER_H_
10
11 #include <list>
12 #include <map>
13 #include <string>
14 #include <msp/core/application.h>
15 #include <msp/datafile/loader.h>
16 #include <msp/fs/path.h>
17 #include "architecture.h"
18 #include "config.h"
19 #include "misc.h"
20 #include "problem.h"
21 #include "target.h"
22
23 class Analyzer;
24 class Config;
25 class Package;
26 class SourcePackage;
27
28 /**
29 The main application class.  Controls and owns everything.  Rules the world.
30 */
31 class Builder: public Msp::Application
32 {
33 public:
34         Builder(int, char **);
35         unsigned get_verbose() const   { return verbose; }
36         bool     get_dry_run() const   { return dry_run; }
37         bool     get_build_all() const { return build_all; }
38         Package  *get_package(const std::string &);
39         SourcePackage *get_main_package() const { return main_pkg; }
40         Target   *get_target(const std::string &) const;
41         const TargetMap &get_targets() const { return targets; }
42         Target   *get_header(const std::string &, const std::string &, const StringList &);
43         Target   *get_library(const std::string &, const StringList &, LibMode);
44         const Msp::FS::Path &get_cwd() const { return cwd; }
45         const Architecture &get_architecture(const std::string &) const;
46         const Architecture &get_current_arch() const;
47         const Msp::FS::Path &get_prefix() const { return prefix; }
48         const StringList &get_warnings() const { return warnings; }
49         void     apply_profile_template(Config &, const std::string &) const;
50         void     add_target(Target *);
51         void     problem(const std::string &, const std::string &);
52         int      main();
53         ~Builder();
54
55         static void usage(const char *, const char *, bool);
56 private:
57         class Loader: public Msp::DataFile::Loader
58         {
59         public:
60                 Loader(Builder &, const Msp::FS::Path &);
61         private:
62                 Builder       &bld;
63                 Msp::FS::Path src;
64
65                 void architecture(const std::string &);
66                 void binpkg(const std::string &);
67                 void profile(const std::string &);
68                 void package(const std::string &);
69         };
70
71         class ProfileLoader: public Msp::DataFile::Loader
72         {
73         public:
74                 ProfileLoader(StringMap &);
75         private:
76                 StringMap &profile;
77
78                 void option(const std::string &, const std::string &);
79         };
80
81         typedef std::list<Package *>               PackageList;
82         typedef std::map<std::string, Package *>   PackageMap;
83         typedef std::map<std::string, StringMap>   ProfileTemplateMap;
84
85         StringList   cmdline_targets;
86         StringMap    cmdline_options;
87         Msp::FS::Path cwd;
88
89         PackageMap   packages;
90         SourcePackage *main_pkg;
91
92         TargetMap    targets;
93         TargetList   new_tgts;
94         TargetMap    includes;
95         TargetMap    libraries;
96
97         ArchMap      archs;
98         ProfileTemplateMap profile_tmpl;
99
100         ProblemList     problems;
101         Analyzer        *analyzer;
102         bool            build;
103         unsigned        clean;
104         bool            dry_run;
105         bool            help;
106         unsigned        verbose;
107         bool            show_progress;
108         std::string     build_file;
109         unsigned        jobs;
110         StringList      what_if;
111         bool            conf_all;
112         bool            conf_only;
113         bool            build_all;
114         bool            create_makefile;
115         std::string     current_arch;
116         Msp::FS::Path   prefix;
117         StringList      warnings;
118
119         int    load_build_file(const Msp::FS::Path &);
120         int    create_targets();
121         Target *get_header(const Msp::FS::Path &);
122         Target *get_library(const std::string &, const Msp::FS::Path &, LibMode);
123         void   update_hash(std::string &, const std::string &);
124         int    do_build();
125         int    do_clean();
126         int    do_create_makefile();
127         void   package_help();
128
129         static Msp::Application::RegApp<Builder> reg;
130 };
131
132 #endif