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 Tool::Tool(Builder &b, const string &t):
17 processing_unit(ONE_FILE),
21 Tool::Tool(Builder &b, const Architecture &a, const string &t):
26 processing_unit(ONE_FILE),
30 void Tool::set_command(const string &cmd, bool cross)
33 throw invalid_argument("Tool::set_command");
35 if(cross && architecture->is_cross() && !FS::Path(cmd).is_absolute())
36 command = format("%s-%s", architecture->get_cross_prefix(), cmd);
41 bool Tool::accepts_suffix(const string &suffix, bool aux) const
43 return (any_equals(input_suffixes, suffix) || (aux && any_equals(aux_suffixes, suffix)));
46 Target *Tool::create_target(Target &source, const string &arg)
48 vector<Target *> sources;
49 sources.push_back(&source);
50 return create_target(sources, arg);
60 if(!executable && !command.empty())
62 executable = builder.get_vfs().find_binary(command);
65 builder.get_logger().log("problems", format("Can't find executable %s for %s", command, tag));
66 problems.push_back(format("Can't find executable %s", command));
71 string Tool::create_build_signature(const BuildInfo &) const
74 return format("%s=%s", tag, FS::basename(executable->get_path()));
80 SubTool::SubTool(Tool &p):
85 Target *SubTool::create_source(const Component &c, const FS::Path &p) const
87 return parent.create_source(c, p);
90 Target *SubTool::create_source(const FS::Path &p) const
92 return parent.create_source(p);
95 Target *SubTool::create_target(const vector<Target *> &s, const string &a)
97 return parent.create_target(s, a);
100 Target *SubTool::create_install(Target &t) const
102 return parent.create_install(t);
105 string SubTool::create_build_signature(const BuildInfo &bi) const
107 return parent.create_build_signature(bi);
111 void operator>>(const LexicalConverter &conv, Tool::ProcessingUnit &unit)
113 const string &str = conv.get();
115 unit = Tool::ONE_FILE;
116 else if(str=="DIRECTORY")
117 unit = Tool::DIRECTORY;
118 else if(str=="COMPONENT")
119 unit = Tool::COMPONENT;
121 throw lexical_error(format("conversion of '%s' to ProcessingUnit", str));