]> git.tdb.fi Git - builder.git/blob - source/builder.h
Adjust requires to library changes
[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 std::string &, const StringList &);
31         Target   *get_library(const std::string &, 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            build;
77         unsigned        clean;
78         bool            dry_run;
79         bool            help;
80         unsigned        verbose;
81         bool            chrome;
82         std::string     build_file;
83         unsigned        jobs;
84         StringList      what_if;
85         bool            conf_all;
86         bool            conf_only;
87         bool            build_all;
88         bool            create_makefile;
89
90         int    load_build_file(const Msp::Path::Path &);
91         int    create_targets();
92         Target *get_header(const Msp::Path::Path &);
93         Target *get_library(const std::string &, const std::string &, const Msp::Path::Path &, LibMode);
94         void   add_target(Target *);
95         void   update_hash(std::string &, const std::string &);
96         int    do_build();
97         int    do_clean();
98         int    do_create_makefile();
99         void   package_help();
100
101         static Msp::Application::RegApp<Builder> reg;
102 };
103
104 #endif