]> git.tdb.fi Git - builder.git/blob - source/architecture.h
Add a generic internal alias system to Architecture
[builder.git] / source / architecture.h
1 /* $Id$
2
3 This file is part of builder
4 Copyright © 2007-2010  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef ARCHITECTURE_H_
9 #define ARCHITECTURE_H_
10
11 #include <msp/datafile/loader.h>
12 #include "buildinfo.h"
13 #include "misc.h"
14
15 class Builder;
16
17 // XXX Add lib/exe prefix/suffix fields.  Some archs may need multiple alternatives, how to handle this?
18 class Architecture
19 {
20 public:
21         class Loader: public Msp::DataFile::Loader
22         {
23         private:
24                 Architecture &arch;
25
26         public:
27                 Loader(Architecture &);
28                 Architecture &get_object() { return arch; }
29         private:
30                 void tool(const std::string &t, const std::string &p);
31         };
32
33 private:
34         Builder &builder;
35         std::string type;
36         std::string cpu;
37         std::string system;
38         unsigned bits;
39         std::string name;
40         bool native;
41         std::string cross_prefix;
42         StringMap tools;
43         BuildInfo build_info;
44
45 public:
46         Architecture(Builder &b, const std::string &spec);
47
48         const std::string &get_name() const { return name; }
49         const std::string &get_system() const { return system; }
50         bool match_name(const std::string &) const;
51         bool is_native() const { return native; }
52
53         void set_tool(const std::string &t, const std::string &p);
54         void set_cross_prefix(const std::string &);
55         std::string get_tool(const std::string &t) const;
56         const std::string &get_cross_prefix() const { return cross_prefix; }
57
58         const BuildInfo &get_build_info() const { return build_info; }
59
60 private:
61         std::string resolve_alias(const std::string &) const;
62         void parse_specification(const std::string &);
63 };
64
65 typedef std::map<std::string, Architecture> ArchMap;
66
67 #endif