X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftoolchain.cpp;h=953fe1147a660df9f429f7a8f7e9f7cef2f709bc;hb=HEAD;hp=c5b8caa9ffb6dbe2b9e13b79eb9dd6e43083318e;hpb=d917c5fd92e7ae50b35e7024a0a2365438bead72;p=builder.git diff --git a/source/toolchain.cpp b/source/toolchain.cpp deleted file mode 100644 index c5b8caa..0000000 --- a/source/toolchain.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include -#include "tool.h" -#include "toolchain.h" - -using namespace std; -using namespace Msp; - -Toolchain::~Toolchain() -{ - for(const auto &kvp: tools) - delete kvp.second; - for(Toolchain *c: chains) - delete c; -} - -void Toolchain::add_tool(Tool *tool) -{ - insert_unique(tools, tool->get_tag(), tool); -} - -void Toolchain::add_toolchain(Toolchain *chain) -{ - auto i = upper_bound(chains, chain->get_priority(), [](int p, Toolchain *tc){ return p>tc->get_priority(); }); - chains.insert(i, chain); -} - -bool Toolchain::has_tool(const string &tag) const -{ - if(tools.count(tag)) - return true; - return any_of(chains.begin(), chains.end(), [&tag](Toolchain *tc){ return tc->has_tool(tag); }); -} - -Tool &Toolchain::get_tool(const string &tag) const -{ - if(!tools.count(tag)) - { - for(const Toolchain *c: chains) - if(c->has_tool(tag)) - return c->get_tool(tag); - } - - return *get_item(tools, tag); -} - -Tool *Toolchain::get_tool_for_suffix(const string &suffix, bool aux) const -{ - for(const auto &kvp: tools) - if(kvp.second->accepts_suffix(suffix, aux)) - return kvp.second; - - for(const Toolchain *c: chains) - if(Tool *tool = c->get_tool_for_suffix(suffix, aux)) - return tool; - - return 0; -}