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