]> git.tdb.fi Git - builder.git/blob - source/builder.h
830d356b28959c1d35e22c5eedbc1959256f7d5f
[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 &, unsigned);
31         const Msp::Path::Path &get_cwd() const { return cwd; }
32         int      main();
33         ~Builder();
34
35         static void usage(const char *, const char *, bool);
36 private:
37         class Loader: public Msp::Parser::Loader
38         {
39         public:
40                 Loader(Builder &, const Msp::Path::Path &);
41         private:
42                 Builder         &bld;
43                 Msp::Path::Path src;
44                 
45                 void package(const std::string &);
46         };
47
48         typedef std::list<Package *>               PackageList;
49         typedef std::map<std::string, Package *>   PackageMap;
50         typedef std::map<std::string, Target *>    TargetMap;
51         typedef std::map<std::string, std::string> ToolMap;
52         
53         StringList   cmdline_targets;
54         RawOptionMap cmdline_options;
55         Msp::Path::Path cwd;
56         
57         PackageMap   packages;
58         PackageList  new_pkgs;
59         Package      *default_pkg;
60
61         TargetMap    targets;
62         TargetList   new_tgts;
63         TargetMap    includes;
64         TargetMap    libraries;
65
66         ToolMap      tools;    /// Not used yet
67         
68         Analyzer        *analyzer;
69         bool            do_build;
70         bool            dry_run;
71         bool            help;
72         unsigned        verbose;
73         bool            chrome;
74         std::string     build_file;
75         unsigned        jobs;
76         StringList      what_if;
77         bool            conf_all;
78         bool            conf_only;
79         bool            build_all;
80
81         int    load_build_file(const Msp::Path::Path &);
82         int    create_targets();
83         Target *get_header(const Msp::Path::Path &);
84         Target *get_library(const std::string &, const Msp::Path::Path &, unsigned);
85         void   add_target(Target *);
86         void   update_hash(std::string &, const std::string &);
87         int    build();
88         void   package_help();
89         
90         static Msp::Application::RegApp<Builder> reg;
91 };
92
93 #endif