2 #include <msp/strings/format.h>
3 #include "architecture.h"
10 Tool::Tool(Builder &b, const string &t):
15 processing_unit(ONE_FILE),
19 Tool::Tool(Builder &b, const Architecture &a, const string &t):
24 processing_unit(ONE_FILE),
28 void Tool::set_command(const string &cmd, bool cross)
31 throw invalid_argument("Tool::set_command");
33 if(cross && architecture->is_cross() && !FS::Path(cmd).is_absolute())
34 command = format("%s-%s", architecture->get_cross_prefix(), cmd);
39 bool Tool::accepts_suffix(const string &suffix, bool aux) const
41 if(find(input_suffixes.begin(), input_suffixes.end(), suffix)!=input_suffixes.end())
44 return find(aux_suffixes.begin(), aux_suffixes.end(), suffix)!=aux_suffixes.end();
49 Target *Tool::create_target(Target &source, const string &arg)
51 list<Target *> sources;
52 sources.push_back(&source);
53 return create_target(sources, arg);
63 if(!executable && !command.empty())
65 executable = builder.get_vfs().find_binary(command);
67 problems.push_back(format("Can't find executable %s", command));
72 SubTool::SubTool(Tool &p):
77 Target *SubTool::create_source(const Component &c, const FS::Path &p) const
79 return parent.create_source(c, p);
82 Target *SubTool::create_source(const FS::Path &p) const
84 return parent.create_source(p);
87 Target *SubTool::create_target(const list<Target *> &s, const string &a)
89 return parent.create_target(s, a);
92 Target *SubTool::create_install(Target &t) const
94 return parent.create_install(t);
97 string SubTool::create_build_signature(const BuildInfo &bi) const
99 return parent.create_build_signature(bi);
103 void operator>>(const LexicalConverter &conv, Tool::ProcessingUnit &unit)
105 const string &str = conv.get();
107 unit = Tool::ONE_FILE;
108 else if(str=="DIRECTORY")
109 unit = Tool::DIRECTORY;
110 else if(str=="COMPONENT")
111 unit = Tool::COMPONENT;
113 throw lexical_error(format("conversion of '%s' to ProcessingUnit", str));