]> git.tdb.fi Git - builder.git/blob - source/architecture.cpp
Move architecture information from Builder to class Architecture
[builder.git] / source / architecture.cpp
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 #include "architecture.h"
9 #include "builder.h"
10
11 using namespace std;
12 using namespace Msp;
13
14 Architecture::Architecture(Builder &b, const string &n):
15         builder(b),
16         name(n)
17 { }
18
19 void Architecture::set_tool(const string &t, const string &p)
20 {
21         tools[t]=p;
22 }
23
24 std::string Architecture::get_tool(const string &t) const
25 {
26         StringMap::const_iterator i=tools.find(t);
27         if(i!=tools.end())
28         {
29                 if(i->second[0]=='-')
30                         return prefix+i->second;
31                 else
32                         return i->second;
33         }
34
35         if(name!="native")
36         {
37                 const Architecture &native=builder.get_architecture("native");
38                 return prefix+"-"+native.get_tool(t);
39         }
40         else
41                 throw KeyError("Unknown tool");
42 }
43
44
45 Architecture::Loader::Loader(Architecture &a):
46         arch(a)
47 {
48         add("prefix", &Architecture::prefix);
49         add("tool",   &Loader::tool);
50 }
51
52 void Architecture::Loader::tool(const string &t, const string &p)
53 {
54         arch.tools[t]=p;
55 }