X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftoolchain.cpp;h=953fe1147a660df9f429f7a8f7e9f7cef2f709bc;hb=74ea8208bb1aa1d9afc9657a4cdfac6714241887;hp=6c7dae1e5c43dd4c5391fd822ff1d4aa50572978;hpb=338eefb513953ae55e8e3614c009c242ba8ad74e;p=builder.git diff --git a/source/toolchain.cpp b/source/toolchain.cpp index 6c7dae1..953fe11 100644 --- a/source/toolchain.cpp +++ b/source/toolchain.cpp @@ -9,6 +9,8 @@ Toolchain::~Toolchain() { for(ToolMap::iterator i=tools.begin(); i!=tools.end(); ++i) delete i->second; + for(ToolchainList::iterator i=chains.begin(); i!=chains.end(); ++i) + delete *i; } void Toolchain::add_tool(Tool *tool) @@ -16,16 +18,42 @@ void Toolchain::add_tool(Tool *tool) insert_unique(tools, tool->get_tag(), tool); } -const Tool &Toolchain::get_tool(const string &tag) const +void Toolchain::add_toolchain(Toolchain *chain) { + chains.push_back(chain); +} + +bool Toolchain::has_tool(const string &tag) const +{ + if(tools.count(tag)) + return true; + for(ToolchainList::const_iterator i=chains.begin(); i!=chains.end(); ++i) + if((*i)->has_tool(tag)) + return true; + return false; +} + +Tool &Toolchain::get_tool(const string &tag) const +{ + if(!tools.count(tag)) + { + for(ToolchainList::const_iterator i=chains.begin(); i!=chains.end(); ++i) + if((*i)->has_tool(tag)) + return (*i)->get_tool(tag); + } + return *get_item(tools, tag); } -const Tool *Toolchain::get_tool_for_suffix(const string &suffix) const +Tool *Toolchain::get_tool_for_suffix(const string &suffix, bool aux) const { for(ToolMap::const_iterator i=tools.begin(); i!=tools.end(); ++i) - if(i->second->accepts_suffix(suffix)) + if(i->second->accepts_suffix(suffix, aux)) return i->second; + for(ToolchainList::const_iterator i=chains.begin(); i!=chains.end(); ++i) + if(Tool *tool = (*i)->get_tool_for_suffix(suffix, aux)) + return tool; + return 0; }