]> git.tdb.fi Git - builder.git/blob - source/builder.h
Replace the chrome mode with a more useful progress display
[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/path/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 std::string &, const StringList &);
43         Target   *get_library(const std::string &, const std::string &, const StringList &, LibMode);
44         const Msp::Path::Path &get_cwd() const { return cwd; }
45         const Architecture &get_architecture(const std::string &) const;
46         void     apply_profile_template(Config &, const std::string &) const;
47         void     add_target(Target *);
48         void     problem(const std::string &, const std::string &);
49         int      main();
50         ~Builder();
51
52         static void usage(const char *, const char *, bool);
53 private:
54         class Loader: public Msp::DataFile::Loader
55         {
56         public:
57                 Loader(Builder &, const Msp::Path::Path &);
58         private:
59                 Builder         &bld;
60                 Msp::Path::Path src;
61
62                 void architecture(const std::string &);
63                 void binpkg(const std::string &);
64                 void profile(const std::string &);
65                 void package(const std::string &);
66         };
67
68         class ProfileLoader: public Msp::DataFile::Loader
69         {
70         public:
71                 ProfileLoader(StringMap &);
72         private:
73                 StringMap &profile;
74
75                 void option(const std::string &, const std::string &);
76         };
77
78         typedef std::list<Package *>               PackageList;
79         typedef std::map<std::string, Package *>   PackageMap;
80         typedef std::map<std::string, StringMap>   ProfileTemplateMap;
81
82         StringList   cmdline_targets;
83         StringMap    cmdline_options;
84         Msp::Path::Path cwd;
85
86         PackageMap   packages;
87         SourcePackage *main_pkg;
88
89         TargetMap    targets;
90         TargetList   new_tgts;
91         TargetMap    includes;
92         TargetMap    libraries;
93
94         ArchMap      archs;
95         ProfileTemplateMap profile_tmpl;
96
97         ProblemList     problems;
98         Analyzer        *analyzer;
99         bool            build;
100         unsigned        clean;
101         bool            dry_run;
102         bool            help;
103         unsigned        verbose;
104         bool            show_progress;
105         std::string     build_file;
106         unsigned        jobs;
107         StringList      what_if;
108         bool            conf_all;
109         bool            conf_only;
110         bool            build_all;
111         bool            create_makefile;
112
113         int    load_build_file(const Msp::Path::Path &);
114         int    create_targets();
115         Target *get_header(const Msp::Path::Path &);
116         Target *get_library(const std::string &, const std::string &, const Msp::Path::Path &, LibMode);
117         void   update_hash(std::string &, const std::string &);
118         int    do_build();
119         int    do_clean();
120         int    do_create_makefile();
121         void   package_help();
122
123         static Msp::Application::RegApp<Builder> reg;
124 };
125
126 #endif