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):
78 void operator>>(const LexicalConverter &conv, Tool::ProcessingUnit &unit)
80 const string &str = conv.get();
82 unit = Tool::ONE_FILE;
83 else if(str=="DIRECTORY")
84 unit = Tool::DIRECTORY;
85 else if(str=="COMPONENT")
86 unit = Tool::COMPONENT;
88 throw lexical_error(format("conversion of '%s' to ProcessingUnit", str));