]> git.tdb.fi Git - builder.git/blob - source/builder.h
Add tarball building
[builder.git] / source / builder.h
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef BUILDER_H_
9 #define BUILDER_H_
10
11 #include <list>
12 #include <map>
13 #include <string>
14 #include <msp/core/application.h>
15 #include <msp/parser/loader.h>
16 #include <msp/path/path.h>
17 #include "config.h"
18 #include "misc.h"
19 #include "target.h"
20
21 class Analyzer;
22 class Config;
23 class Package;
24
25 /**
26 The main application class.  Controls and owns everything.  Rules the world.
27 */
28 class Builder: public Msp::Application
29 {
30 public:
31         Builder(int, char **);
32         unsigned get_verbose() const   { return verbose; }
33         bool     get_dry_run() const   { return dry_run; }
34         bool     get_build_all() const { return build_all; }
35         Package  *get_package(const std::string &);
36         Package  *get_default_package() const { return default_pkg; }
37         Target   *get_target(const std::string &) const;
38         const TargetMap &get_targets() const { return targets; }
39         Target   *get_header(const std::string &, const std::string &, const std::string &, const StringList &);
40         Target   *get_library(const std::string &, const std::string &, const StringList &, LibMode);
41         const Msp::Path::Path &get_cwd() const { return cwd; }
42         const std::string &get_arch_prefix(const std::string &) const;
43         std::string get_tool(const std::string &, const std::string &);
44         void     apply_profile_template(Config &, const std::string &) const;
45         void     add_target(Target *);
46         int      main();
47         ~Builder();
48
49         static void usage(const char *, const char *, bool);
50 private:
51         class Loader: public Msp::Parser::Loader
52         {
53         public:
54                 Loader(Builder &, const Msp::Path::Path &);
55         private:
56                 Builder         &bld;
57                 Msp::Path::Path src;
58
59                 void package(const std::string &);
60         };
61
62         typedef std::list<Package *>               PackageList;
63         typedef std::map<std::string, Package *>   PackageMap;
64         typedef std::map<std::string, StringMap>   ToolMap;
65         typedef std::map<std::string, StringMap>   ProfileTemplateMap;
66
67         StringList   cmdline_targets;
68         StringMap    cmdline_options;
69         Msp::Path::Path cwd;
70
71         PackageMap   packages;
72         PackageList  new_pkgs;
73         Package      *default_pkg;
74
75         TargetMap    targets;
76         TargetList   new_tgts;
77         TargetMap    includes;
78         TargetMap    libraries;
79
80         ToolMap      tools;    //< arch, tool name -> program name
81         StringMap    archs;    //< arch -> prefix
82         ProfileTemplateMap profile_tmpl;
83
84         Analyzer        *analyzer;
85         bool            build;
86         unsigned        clean;
87         bool            dry_run;
88         bool            help;
89         unsigned        verbose;
90         bool            chrome;
91         std::string     build_file;
92         unsigned        jobs;
93         StringList      what_if;
94         bool            conf_all;
95         bool            conf_only;
96         bool            build_all;
97         bool            create_makefile;
98
99         int    load_build_file(const Msp::Path::Path &);
100         int    create_targets();
101         Target *get_header(const Msp::Path::Path &);
102         Target *get_library(const std::string &, const std::string &, const Msp::Path::Path &, LibMode);
103         void   update_hash(std::string &, const std::string &);
104         int    do_build();
105         int    do_clean();
106         int    do_create_makefile();
107         void   package_help();
108
109         static Msp::Application::RegApp<Builder> reg;
110 };
111
112 #endif