1 #include <msp/core/algorithm.h>
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 return (any_equals(input_suffixes, suffix) || (aux && any_equals(aux_suffixes, suffix)));
44 Target *Tool::create_target(Target &source, const string &arg)
46 list<Target *> sources;
47 sources.push_back(&source);
48 return create_target(sources, arg);
58 if(!executable && !command.empty())
60 executable = builder.get_vfs().find_binary(command);
63 builder.get_logger().log("problems", format("Can't find executable %s for %s", command, tag));
64 problems.push_back(format("Can't find executable %s", command));
70 SubTool::SubTool(Tool &p):
75 Target *SubTool::create_source(const Component &c, const FS::Path &p) const
77 return parent.create_source(c, p);
80 Target *SubTool::create_source(const FS::Path &p) const
82 return parent.create_source(p);
85 Target *SubTool::create_target(const list<Target *> &s, const string &a)
87 return parent.create_target(s, a);
90 Target *SubTool::create_install(Target &t) const
92 return parent.create_install(t);
95 string SubTool::create_build_signature(const BuildInfo &bi) const
97 return parent.create_build_signature(bi);
101 void operator>>(const LexicalConverter &conv, Tool::ProcessingUnit &unit)
103 const string &str = conv.get();
105 unit = Tool::ONE_FILE;
106 else if(str=="DIRECTORY")
107 unit = Tool::DIRECTORY;
108 else if(str=="COMPONENT")
109 unit = Tool::COMPONENT;
111 throw lexical_error(format("conversion of '%s' to ProcessingUnit", str));