1 #include <msp/core/algorithm.h>
2 #include <msp/fs/utils.h>
3 #include <msp/strings/format.h>
4 #include "architecture.h"
6 #include "filetarget.h"
12 void Tool::set_command(const string &cmd, bool cross)
15 throw invalid_argument("Tool::set_command");
17 if(cross && architecture->is_cross() && !FS::Path(cmd).is_absolute())
18 command = format("%s-%s", architecture->get_cross_prefix(), cmd);
23 void Tool::set_run(function<Task *(const Target &)> f)
28 bool Tool::accepts_suffix(const string &suffix, bool aux) const
30 return (any_equals(input_suffixes, suffix) || (aux && any_equals(aux_suffixes, suffix)));
33 Target *Tool::create_target(Target &source, const string &arg)
35 vector<Target *> sources;
36 sources.push_back(&source);
37 return create_target(sources, arg);
48 executable = builder.get_vfs().find_binary(command);
50 if(!command.empty() && !executable)
52 builder.get_logger().log("problems", "Can't find executable %s for %s", command, tag);
53 problems.push_back(format("Can't find executable %s", command));
57 void Tool::prepare(Tool &tool) const
59 if(&tool!=this && tool.get_base_tool()!=this)
60 throw invalid_argument("Tool::prepare");
62 if(&tool!=this && !command.empty() && tool.command.empty())
63 throw logic_error("Derived tool has no command");
68 string Tool::create_build_signature(const BuildInfo &) const
71 return format("%s=%s", tag, FS::basename(executable->get_path()));
77 void operator>>(const LexicalConverter &conv, Tool::ProcessingUnit &unit)
79 const string &str = conv.get();
81 unit = Tool::ONE_FILE;
82 else if(str=="DIRECTORY")
83 unit = Tool::DIRECTORY;
84 else if(str=="COMPONENT")
85 unit = Tool::COMPONENT;
87 throw lexical_error(format("conversion of '%s' to ProcessingUnit", str));