]> git.tdb.fi Git - builder.git/blob - source/builder.h
Split class Package into SourcePackage and BinaryPackage
[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/datafile/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 class SourcePackage;
25
26 /**
27 The main application class.  Controls and owns everything.  Rules the world.
28 */
29 class Builder: public Msp::Application
30 {
31 public:
32         Builder(int, char **);
33         unsigned get_verbose() const   { return verbose; }
34         bool     get_dry_run() const   { return dry_run; }
35         bool     get_build_all() const { return build_all; }
36         Package  *get_package(const std::string &);
37         SourcePackage *get_default_package() const { return default_pkg; }
38         Target   *get_target(const std::string &) const;
39         const TargetMap &get_targets() const { return targets; }
40         Target   *get_header(const std::string &, const std::string &, const std::string &, const StringList &);
41         Target   *get_library(const std::string &, const std::string &, const StringList &, LibMode);
42         const Msp::Path::Path &get_cwd() const { return cwd; }
43         const std::string &get_arch_prefix(const std::string &) const;
44         std::string get_tool(const std::string &, const std::string &);
45         void     apply_profile_template(Config &, const std::string &) const;
46         void     add_target(Target *);
47         int      main();
48         ~Builder();
49
50         static void usage(const char *, const char *, bool);
51 private:
52         class Loader: public Msp::DataFile::Loader
53         {
54         public:
55                 Loader(Builder &, const Msp::Path::Path &);
56         private:
57                 Builder         &bld;
58                 Msp::Path::Path src;
59
60                 void architecture(const std::string &, const std::string &);
61                 void binpkg(const std::string &);
62                 void profile(const std::string &);
63                 void package(const std::string &);
64         };
65
66         class ProfileLoader: public Msp::DataFile::Loader
67         {
68         public:
69                 ProfileLoader(StringMap &);
70         private:
71                 StringMap &profile;
72
73                 void option(const std::string &, const std::string &);
74         };
75
76         typedef std::list<Package *>               PackageList;
77         typedef std::map<std::string, Package *>   PackageMap;
78         typedef std::map<std::string, StringMap>   ToolMap;
79         typedef std::map<std::string, StringMap>   ProfileTemplateMap;
80
81         StringList   cmdline_targets;
82         StringMap    cmdline_options;
83         Msp::Path::Path cwd;
84
85         PackageMap   packages;
86         PackageList  new_pkgs;
87         SourcePackage *default_pkg;
88
89         TargetMap    targets;
90         TargetList   new_tgts;
91         TargetMap    includes;
92         TargetMap    libraries;
93
94         ToolMap      tools;    //< arch, tool name -> program name
95         StringMap    archs;    //< arch -> prefix
96         ProfileTemplateMap profile_tmpl;
97
98         Analyzer        *analyzer;
99         bool            build;
100         unsigned        clean;
101         bool            dry_run;
102         bool            help;
103         unsigned        verbose;
104         bool            chrome;
105         std::string     build_file;
106         unsigned        jobs;
107         StringList      what_if;
108         bool            conf_all;
109         bool            conf_only;
110         bool            build_all;
111         bool            create_makefile;
112
113         int    load_build_file(const Msp::Path::Path &);
114         int    create_targets();
115         Target *get_header(const Msp::Path::Path &);
116         Target *get_library(const std::string &, const std::string &, const Msp::Path::Path &, LibMode);
117         void   update_hash(std::string &, const std::string &);
118         int    do_build();
119         int    do_clean();
120         int    do_create_makefile();
121         void   package_help();
122
123         static Msp::Application::RegApp<Builder> reg;
124 };
125
126 #endif