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