]> git.tdb.fi Git - builder.git/blob - source/builder.h
385468210fc2590b433d6d426075dadc73a98224
[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 Config;
16 class Package;
17
18 /**
19 The main application class.  Controls and owns everything.  Rules the world.
20 */
21 class Builder: public Msp::Application
22 {
23 public:
24         Builder(int, char **);
25         unsigned get_verbose() const   { return verbose; }
26         bool     get_dry_run() const   { return dry_run; }
27         bool     get_build_all() const { return build_all; }
28         Package  *get_package(const std::string &);
29         Target   *get_target(const std::string &);
30         Target   *get_header(const std::string &, const std::string &, const StringList &);
31         Target   *get_library(const std::string &, const StringList &, LibMode);
32         const Msp::Path::Path &get_cwd() const { return cwd; }
33         const std::string &get_arch_prefix(const std::string &) const;
34         std::string get_tool(const std::string &, const std::string &);
35         void     apply_profile_template(Config &, const std::string &) const;
36         int      main();
37         ~Builder();
38
39         static void usage(const char *, const char *, bool);
40 private:
41         class Loader: public Msp::Parser::Loader
42         {
43         public:
44                 Loader(Builder &, const Msp::Path::Path &);
45         private:
46                 Builder         &bld;
47                 Msp::Path::Path src;
48                 
49                 void package(const std::string &);
50         };
51
52         typedef std::list<Package *>               PackageList;
53         typedef std::map<std::string, Package *>   PackageMap;
54         typedef std::map<std::string, Target *>    TargetMap;
55         typedef std::map<std::string, StringMap>   ToolMap;
56         typedef std::map<std::string, StringMap>   ProfileTemplateMap;
57         
58         StringList   cmdline_targets;
59         StringMap    cmdline_options;
60         Msp::Path::Path cwd;
61         
62         PackageMap   packages;
63         PackageList  new_pkgs;
64         Package      *default_pkg;
65
66         TargetMap    targets;
67         TargetList   new_tgts;
68         TargetMap    includes;
69         TargetMap    libraries;
70
71         ToolMap      tools;    //< arch, tool name -> program name
72         StringMap    archs;    //< arch -> prefix
73         ProfileTemplateMap profile_tmpl;
74         
75         Analyzer        *analyzer;
76         bool            do_build;
77         bool            dry_run;
78         bool            help;
79         unsigned        verbose;
80         bool            chrome;
81         std::string     build_file;
82         unsigned        jobs;
83         StringList      what_if;
84         bool            conf_all;
85         bool            conf_only;
86         bool            build_all;
87
88         int    load_build_file(const Msp::Path::Path &);
89         int    create_targets();
90         Target *get_header(const Msp::Path::Path &);
91         Target *get_library(const std::string &, const Msp::Path::Path &, LibMode);
92         void   add_target(Target *);
93         void   update_hash(std::string &, const std::string &);
94         int    build();
95         void   package_help();
96         
97         static Msp::Application::RegApp<Builder> reg;
98 };
99
100 #endif