]> git.tdb.fi Git - builder.git/blob - source/builder.h
3dba62920a48d1821f242c3d915e550e041aa843
[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
12 class Analyzer;
13 class Package;
14 class Target;
15
16 class Builder: public Msp::Application
17 {
18 public:
19         Builder(int, char **);
20         unsigned get_verbose() const { return verbose; }
21         bool     get_dry_run() const { return dry_run; }
22         bool     get_build_all() const { return build_all; }
23         Package  *get_package(const std::string &);
24         Target   *get_target(const std::string &);
25         Target   *get_header(const std::string &, const std::string &, const std::list<std::string> &);
26         Target   *get_library(const std::string &, const std::list<std::string> &);
27         const Msp::Path::Path &get_cwd() const { return cwd; }
28         int      main();
29         ~Builder();
30
31         static void usage(const char *, bool);
32 private:
33         class Loader: public Msp::Parser::Loader
34         {
35         public:
36                 Loader(Builder &, const Msp::Path::Path &);
37         private:
38                 Builder &bld;
39                 Msp::Path::Path src;
40                 
41                 void package(const std::string &);
42         };
43
44         typedef std::map<std::string, Package *>   PackageMap;
45         typedef std::map<std::string, Target *>    TargetMap;
46         typedef std::map<std::string, std::string> ToolMap;
47         
48         std::list<std::string> cmdline_targets;
49         RawOptionMap cmdline_options;
50         
51         PackageMap  packages;
52         std::list<Package *> new_pkgs;
53         Package     *default_pkg;
54
55         TargetMap   targets;
56         std::list<Target *> new_tgts;
57         TargetMap   includes;
58         TargetMap   libraries;
59
60         ToolMap     tools;
61         unsigned    verbose;
62         Msp::Path::Path cwd;
63         Msp::Path::Path build_file;
64         bool        do_build;
65         bool        dry_run;
66         Analyzer    *analyzer;
67         unsigned    jobs;
68         std::list<std::string> what_if;
69         bool        chrome;
70         bool        conf_all;
71         bool        build_all;
72         bool        help;
73
74         int load_build_file(const Msp::Path::Path &);
75         int create_targets();
76         Target *check_header(const Msp::Path::Path &);
77         void add_target(Target *);
78         void update_hash(std::string &, const std::string &);
79         int build();
80         void package_help();
81         
82         static Msp::Application::RegApp<Builder> reg;
83 };
84
85 #endif