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