From dceec8d95c63aaf4d8d4b367c9846caf9e32a6bf Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 9 Jun 2012 01:47:17 +0300 Subject: [PATCH] Add a list of auxiliary suffixes to Tool --- source/gnuccompiler.cpp | 1 + source/gnucxxcompiler.cpp | 1 + source/tool.cpp | 9 +++++++-- source/tool.h | 11 ++++++++--- source/toolchain.cpp | 4 ++-- source/toolchain.h | 2 +- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/source/gnuccompiler.cpp b/source/gnuccompiler.cpp index 8fc8b6c..5c21413 100644 --- a/source/gnuccompiler.cpp +++ b/source/gnuccompiler.cpp @@ -8,6 +8,7 @@ GnuCCompiler::GnuCCompiler(Builder &b): GnuCompiler(b, "CC", "gcc") { input_suffixes.push_back(".c"); + aux_suffixes.push_back(".h"); } Target *GnuCCompiler::create_source(const Component &comp, const FS::Path &path) const diff --git a/source/gnucxxcompiler.cpp b/source/gnucxxcompiler.cpp index 7c863a5..fb7fbdc 100644 --- a/source/gnucxxcompiler.cpp +++ b/source/gnucxxcompiler.cpp @@ -8,6 +8,7 @@ GnuCxxCompiler::GnuCxxCompiler(Builder &b): { input_suffixes.push_back(".cpp"); input_suffixes.push_back(".cc"); + aux_suffixes.push_back(".hpp"); } Target *GnuCxxCompiler::create_source(const Component &comp, const FS::Path &path) const diff --git a/source/tool.cpp b/source/tool.cpp index e185849..5556cb3 100644 --- a/source/tool.cpp +++ b/source/tool.cpp @@ -8,9 +8,14 @@ Tool::Tool(Builder &b, const string &t): tag(t) { } -bool Tool::accepts_suffix(const string &suffix) const +bool Tool::accepts_suffix(const string &suffix, bool aux) const { - return find(input_suffixes.begin(), input_suffixes.end(), suffix)!=input_suffixes.end(); + if(find(input_suffixes.begin(), input_suffixes.end(), suffix)!=input_suffixes.end()) + return true; + else if(aux) + return find(aux_suffixes.begin(), aux_suffixes.end(), suffix)!=aux_suffixes.end(); + else + return false; } Target *Tool::create_target(Target &source, const string &arg) const diff --git a/source/tool.h b/source/tool.h index 5f21065..22fc3b2 100644 --- a/source/tool.h +++ b/source/tool.h @@ -12,18 +12,23 @@ class Task; class Tool { +public: + typedef std::list SuffixList; + protected: Builder &builder; std::string tag; - std::list input_suffixes; + SuffixList input_suffixes; + SuffixList aux_suffixes; Tool(Builder &, const std::string &); public: virtual ~Tool() { } const std::string &get_tag() const { return tag; } - const std::list &get_input_suffixes() const { return input_suffixes; } - bool accepts_suffix(const std::string &) const; + const SuffixList &get_input_suffixes() const { return input_suffixes; } + const SuffixList &get_auxiliary_suffixes() const { return aux_suffixes; } + bool accepts_suffix(const std::string &, bool = false) const; virtual Target *create_source(const Component &, const Msp::FS::Path &) const { return 0; } Target *create_target(Target &, const std::string & = std::string()) const; diff --git a/source/toolchain.cpp b/source/toolchain.cpp index 6c7dae1..cdbc7aa 100644 --- a/source/toolchain.cpp +++ b/source/toolchain.cpp @@ -21,10 +21,10 @@ const Tool &Toolchain::get_tool(const string &tag) const return *get_item(tools, tag); } -const Tool *Toolchain::get_tool_for_suffix(const string &suffix) const +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; return 0; diff --git a/source/toolchain.h b/source/toolchain.h index 1060e09..3da6cda 100644 --- a/source/toolchain.h +++ b/source/toolchain.h @@ -18,7 +18,7 @@ public: void add_tool(Tool *); const Tool &get_tool(const std::string &) const; - const Tool *get_tool_for_suffix(const std::string &) const; + const Tool *get_tool_for_suffix(const std::string &, bool = false) const; }; #endif -- 2.45.2