]> git.tdb.fi Git - builder.git/blob - source/builder.h
Better encapsulation of config inside Package
[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/parser/loader.h>
9 #include <msp/path/path.h>
10 #include "config.h"
11 #include "misc.h"
12 #include "target.h"
13
14 class Analyzer;
15 class Package;
16
17 /**
18 The main application class.  Controls and owns everything.  Rules the world.
19 */
20 class Builder: public Msp::Application
21 {
22 public:
23         Builder(int, char **);
24         unsigned get_verbose() const   { return verbose; }
25         bool     get_dry_run() const   { return dry_run; }
26         bool     get_build_all() const { return build_all; }
27         Package  *get_package(const std::string &);
28         Target   *get_target(const std::string &);
29         Target   *get_header(const std::string &, const std::string &, const StringList &);
30         Target   *get_library(const std::string &, const StringList &, LibMode);
31         const Msp::Path::Path &get_cwd() const { return cwd; }
32         const std::string &get_arch_prefix(const std::string &) const;
33         int      main();
34         ~Builder();
35
36         static void usage(const char *, const char *, bool);
37 private:
38         class Loader: public Msp::Parser::Loader
39         {
40         public:
41                 Loader(Builder &, const Msp::Path::Path &);
42         private:
43                 Builder         &bld;
44                 Msp::Path::Path src;
45                 
46                 void package(const std::string &);
47         };
48
49         typedef std::list<Package *>               PackageList;
50         typedef std::map<std::string, Package *>   PackageMap;
51         typedef std::map<std::string, Target *>    TargetMap;
52         typedef std::map<std::string, std::string> ToolMap;
53         
54         StringList   cmdline_targets;
55         RawOptionMap cmdline_options;
56         Msp::Path::Path cwd;
57         
58         PackageMap   packages;
59         PackageList  new_pkgs;
60         Package      *default_pkg;
61
62         TargetMap    targets;
63         TargetList   new_tgts;
64         TargetMap    includes;
65         TargetMap    libraries;
66
67         ToolMap      tools;    /// Not used yet
68         StringMap    archs;    /// arch -> prefix
69         
70         Analyzer        *analyzer;
71         bool            do_build;
72         bool            dry_run;
73         bool            help;
74         unsigned        verbose;
75         bool            chrome;
76         std::string     build_file;
77         unsigned        jobs;
78         StringList      what_if;
79         bool            conf_all;
80         bool            conf_only;
81         bool            build_all;
82
83         int    load_build_file(const Msp::Path::Path &);
84         int    create_targets();
85         Target *get_header(const Msp::Path::Path &);
86         Target *get_library(const std::string &, const Msp::Path::Path &, LibMode);
87         void   add_target(Target *);
88         void   update_hash(std::string &, const std::string &);
89         int    build();
90         void   package_help();
91         
92         static Msp::Application::RegApp<Builder> reg;
93 };
94
95 #endif