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