1 #include <msp/core/algorithm.h>
2 #include <msp/core/maputils.h>
9 Toolchain::~Toolchain()
11 for(const auto &kvp: tools)
13 for(Toolchain *c: chains)
17 void Toolchain::add_tool(Tool *tool)
19 insert_unique(tools, tool->get_tag(), tool);
22 void Toolchain::add_toolchain(Toolchain *chain)
24 auto i = upper_bound(chains, chain->get_priority(), [](int p, Toolchain *tc){ return p>tc->get_priority(); });
25 chains.insert(i, chain);
28 bool Toolchain::has_tool(const string &tag) const
32 return any_of(chains.begin(), chains.end(), [&tag](Toolchain *tc){ return tc->has_tool(tag); });
35 Tool &Toolchain::get_tool(const string &tag) const
39 for(const Toolchain *c: chains)
41 return c->get_tool(tag);
44 return *get_item(tools, tag);
47 Tool *Toolchain::get_tool_for_suffix(const string &suffix, bool aux) const
49 for(const auto &kvp: tools)
50 if(kvp.second->accepts_suffix(suffix, aux))
53 for(const Toolchain *c: chains)
54 if(Tool *tool = c->get_tool_for_suffix(suffix, aux))