X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftool.h;h=4bbbcf5595a8f3603e85901fb5bdb88503cba6f2;hb=75ac80cb255e4def7ee685ce9c46db7c2f6625aa;hp=1736e1c74f0f40207ebbc66f391bebbc7d59aba9;hpb=338eefb513953ae55e8e3614c009c242ba8ad74e;p=builder.git diff --git a/source/tool.h b/source/tool.h index 1736e1c..4bbbcf5 100644 --- a/source/tool.h +++ b/source/tool.h @@ -5,29 +5,63 @@ #include #include +class Architecture; class Builder; class Component; +class FileTarget; class Target; class Task; +/** +Base class for tools. Tools are used to turn targets into other targets. +Examples include compilers and linkers. +*/ class Tool { +public: + typedef std::list SearchPath; + typedef std::list SuffixList; + protected: Builder &builder; + const Architecture *architecture; std::string tag; - std::list input_suffixes; + FileTarget *executable; + SuffixList input_suffixes; + SuffixList aux_suffixes; + SearchPath system_path; Tool(Builder &, const std::string &); - + Tool(Builder &, const Architecture &, 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; + // XXX The executable target should be retrieved when first needed + FileTarget *get_executable() const { return executable; } + 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; + const SearchPath &get_system_path() const { return system_path; } virtual Target *create_source(const Component &, const Msp::FS::Path &) const { return 0; } + virtual Target *create_source(const Msp::FS::Path &) const { return 0; } Target *create_target(Target &, const std::string & = std::string()) const; virtual Target *create_target(const std::list &, const std::string & = std::string()) const = 0; virtual Task *run(const Target &) const = 0; }; +/** +Intermediate base class for tool facets. For example, a linker may need to +use different commands depending on whether C++ source files are present or +not, but their presence can't be directly determined from the object files. +*/ +class SubTool: public Tool +{ +protected: + Tool &parent; + + SubTool(Tool &); +}; + #endif