]> git.tdb.fi Git - builder.git/blob - source/builder.h
Builder can build itself now.
[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 Package;
13 class Target;
14
15 class Builder: public Msp::Application
16 {
17 public:
18         Builder(int, char **);
19         unsigned get_verbose() const { return verbose; }
20         Package  *get_package(const std::string &);
21         Target   *get_target(const std::string &);
22         Target   *get_header(const std::string &, const std::string &, const std::list<std::string> &);
23         int      main();
24 private:
25         class Loader: public Msp::Parser::Loader
26         {
27         public:
28                 Loader(Builder &, const Msp::Path::Path &);
29         private:
30                 Builder &bld;
31                 Msp::Path::Path src;
32                 
33                 void package(const std::string &);
34         };
35
36         typedef std::map<std::string, Package *>   PackageMap;
37         typedef std::map<std::string, Target *>    TargetMap;
38         typedef std::map<std::string, std::string> ToolMap;
39         
40         std::list<std::string> cmdline_targets;
41         RawOptionMap cmdline_options;
42         TargetMap  targets;
43         PackageMap packages;
44         unsigned   verbose;
45         Package    *default_pkg;
46         Msp::Path::Path cwd;
47         std::list<Package *> new_pkgs;
48         TargetMap  includes;
49         std::list<Target *> new_tgts;
50         ToolMap    tools;
51
52         int load_build_file(const Msp::Path::Path &);
53         int create_targets();
54         Target *check_header(const Msp::Path::Path &);
55         void add_target(Target *);
56         int build();
57         
58         static Msp::Application::RegApp<Builder> reg;
59 };
60
61 #endif