]> git.tdb.fi Git - builder.git/blobdiff - source/tool.h
Rework Tool::prepare to be able to work on other objects than self
[builder.git] / source / tool.h
index 5ea63356a4028b0d6afac2dfe0b6be02fce1c65c..85bae55d88f2e063c9dd9ee7cef9d054f0bc21fd 100644 (file)
@@ -16,11 +16,20 @@ class Component;
 class FileTarget;
 class Target;
 
+class ToolData
+{
+public:
+       VirtualFileSystem::SearchPath system_path;
+       BuildInfo build_info;
+       Msp::Variant extra_data;
+       std::vector<std::string> problems;
+};
+
 /**
 Base class for tools.  Tools are used to turn targets into other targets.
 Examples include compilers and linkers.
 */
-class Tool
+class Tool: protected ToolData
 {
 public:
        enum ProcessingUnit
@@ -39,14 +48,12 @@ protected:
        std::vector<std::string> input_suffixes;
        std::vector<std::string> aux_suffixes;
        ProcessingUnit processing_unit = ONE_FILE;
-       VirtualFileSystem::SearchPath system_path;
-       BuildInfo build_info;
        std::function<Task *(const Target &)> run_func;
        bool prepared = false;
-       std::vector<std::string> problems;
 
        Tool(Builder &b, const std::string &t): Tool(b, 0, t) { }
        Tool(Builder &b, const Architecture *a, const std::string &t): builder(b), architecture(a), tag(t) { }
+
 public:
        virtual ~Tool() { }
 
@@ -58,6 +65,8 @@ public:
        tool is architecture-agnostic. */
        const Architecture *get_architecture() const { return architecture; }
 
+       virtual const Tool *get_base_tool() const { return this; }
+
 protected:
        void set_run(std::function<Task *(const Target &)>);
 
@@ -100,6 +109,8 @@ public:
        the chain. */
        const BuildInfo &get_build_info() const { return build_info; }
 
+       const Msp::Variant &get_extra_data() const { return extra_data; }
+
        /// Creates a source file appropriate for this tool.
        virtual Target *create_source(const Component &, const Msp::FS::Path &) const { return 0; }
 
@@ -122,10 +133,10 @@ public:
 
        virtual std::string create_build_signature(const BuildInfo &) const;
 
-       void prepare();
+       void prepare(Tool * = 0);
 
 protected:
-       virtual void do_prepare() { }
+       virtual void do_prepare(ToolData &) const { }
 
 public:
        const std::vector<std::string> &get_problems() const { return problems; }