]> git.tdb.fi Git - builder.git/blobdiff - source/compilecommandsgenerator.cpp
Redesign how tools are run
[builder.git] / source / compilecommandsgenerator.cpp
index 2f4e07b4c2dccdc2d6b62f4d07df9999f7ee7380..bbd4e980742c70c96621d234ff7eeda0845a1c0c 100644 (file)
@@ -4,6 +4,7 @@
 #include "builder.h"
 #include "compilecommandsgenerator.h"
 #include "compilecommandsjson.h"
+#include "internaltask.h"
 #include "objectfile.h"
 #include "sourcefile.h"
 
@@ -12,32 +13,22 @@ using namespace Msp;
 
 CompileCommandsGenerator::CompileCommandsGenerator(Builder &b):
        Tool(b, "CCJG")
-{ }
-
-Target *CompileCommandsGenerator::create_target(const list<Target *> &, const string &)
 {
-       throw logic_error("Not implemented");
+       set_run_internal(_run);
 }
 
-Task *CompileCommandsGenerator::run(const Target &target) const
+Target *CompileCommandsGenerator::create_target(const vector<Target *> &, const string &)
 {
-       const CompileCommandsJson &cmds = dynamic_cast<const CompileCommandsJson &>(target);
-       Worker *worker = new Worker(cmds);
-       return new InternalTask(worker);
+       throw logic_error("Not implemented");
 }
 
-
-CompileCommandsGenerator::Worker::Worker(const CompileCommandsJson &t):
-       target(t)
-{ }
-
-void CompileCommandsGenerator::Worker::main()
+bool CompileCommandsGenerator::_run(const CompileCommandsJson &cmds)
 {
-       Builder &builder = target.get_package()->get_builder();
-       const SourcePackage &spkg = *target.get_package();
+       Builder &builder = cmds.get_package()->get_builder();
+       const SourcePackage &spkg = *cmds.get_package();
        string work_dir = c_escape(spkg.get_source_directory().str());
 
-       IO::BufferedFile out(target.get_path().str(), IO::M_WRITE);
+       IO::BufferedFile out(cmds.get_path().str(), IO::M_WRITE);
        IO::print(out, "[");
 
        bool first = true;
@@ -60,5 +51,5 @@ void CompileCommandsGenerator::Worker::main()
 
        IO::print(out, "\n]\n");
 
-       status = Task::SUCCESS;
+       return true;
 }