]> git.tdb.fi Git - builder.git/blobdiff - source/tool.cpp
Rework Tool::prepare to be able to work on other objects than self
[builder.git] / source / tool.cpp
index cd002379ccc110c3cc13569563695077bea48b79..d7b27ff275e39cfbdd908ffbc21119474a40d540 100644 (file)
@@ -37,19 +37,24 @@ Target *Tool::create_target(Target &source, const string &arg)
        return create_target(sources, arg);
 }
 
-void Tool::prepare()
+void Tool::prepare(Tool *tool)
 {
-       if(prepared)
+       if(!tool)
+               tool = this;
+       else if(tool->get_base_tool()!=this)
+               throw invalid_argument("Tool::prepare");
+
+       if(tool->prepared)
                return;
 
-       prepared = true;
-       if(!command.empty())
-               executable = builder.get_vfs().find_binary(command);
-       do_prepare();
+       tool->prepared = true;
+       if(!tool->command.empty())
+               tool->executable = builder.get_vfs().find_binary(tool->command);
+       do_prepare(*tool);
        if(!command.empty() && !executable)
        {
-               builder.get_logger().log("problems", "Can't find executable %s for %s", command, tag);
-               problems.push_back(format("Can't find executable %s", command));
+               builder.get_logger().log("problems", "Can't find executable %s for %s", tool->command, tool->tag);
+               tool->problems.push_back(format("Can't find executable %s", tool->command));
        }
 }