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