]> git.tdb.fi Git - builder.git/blob - source/customizedtool.cpp
Add a helper class for tool customization
[builder.git] / source / customizedtool.cpp
1 #include "builder.h"
2 #include "customizedtool.h"
3 #include "target.h"
4
5 using namespace std;
6 using namespace Msp;
7
8 CustomizedTool::CustomizedTool(Builder &b, const std::string &t, const Architecture &a):
9         CustomizedTool(b.get_toolchain().get_tool(t), a)
10 { }
11
12 CustomizedTool::CustomizedTool(Tool &t, const Architecture &a):
13         Tool(t.get_builder(), &a, t.get_tag()),
14         parent(t)
15 {
16         input_suffixes = parent.get_input_suffixes();
17         aux_suffixes = parent.get_auxiliary_suffixes();
18         processing_unit = parent.get_processing_unit();
19
20         set_run([this](const Target &t){ return parent.run(t); });
21 }
22
23 Target *CustomizedTool::create_source(const Component &c, const FS::Path &p) const
24 {
25         return parent.create_source(c, p);
26 }
27
28 Target *CustomizedTool::create_source(const FS::Path &p) const
29 {
30         return parent.create_source(p);
31 }
32
33 Target *CustomizedTool::create_target(const vector<Target *> &s, const string &a)
34 {
35         Target *target = parent.create_target(s, a);
36         target->set_tool(*this);
37         return target;
38 }
39
40 Target *CustomizedTool::create_install(Target &t) const
41 {
42         return parent.create_install(t);
43 }
44
45 string CustomizedTool::create_build_signature(const BuildInfo &bi) const
46 {
47         string sig = Tool::create_build_signature(bi);
48         string parent_sig = parent.create_build_signature(bi);
49         string::size_type comma = parent_sig.find(',');
50         if(comma==string::npos)
51                 return sig;
52         else
53                 return sig+parent_sig.substr(comma);
54 }
55
56 void CustomizedTool::do_prepare(ToolData &tool) const
57 {
58         parent.prepare(&static_cast<Tool &>(tool));
59 }