From: Mikko Rasa Date: Mon, 9 Jan 2023 09:15:10 +0000 (+0200) Subject: Associate targets with FileTargets instead of paths X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c88127503ec454a8f4d68dc55dd32f964d2a7e1a;p=builder.git Associate targets with FileTargets instead of paths --- diff --git a/source/lib/filetarget.cpp b/source/lib/filetarget.cpp index f799f49..7ab13c3 100644 --- a/source/lib/filetarget.cpp +++ b/source/lib/filetarget.cpp @@ -147,7 +147,7 @@ string FileTarget::create_build_signature() const void FileTarget::build(Task &task) { - task.add_file(path); + task.add_target(*this); task.set_unlink(true); } diff --git a/source/lib/task.cpp b/source/lib/task.cpp index e72a741..870e068 100644 --- a/source/lib/task.cpp +++ b/source/lib/task.cpp @@ -1,14 +1,15 @@ #include #include #include +#include "filetarget.h" #include "task.h" using namespace std; using namespace Msp; -void Task::add_file(const FS::Path &f) +void Task::add_target(const FileTarget &t) { - files.push_back(f); + targets.push_back(&t); } void Task::set_unlink(bool u) @@ -18,8 +19,9 @@ void Task::set_unlink(bool u) void Task::prepare() { - for(const FS::Path &f: files) + for(const FileTarget *t: targets) { + const FS::Path &f = t->get_path(); if(FS::exists(f)) { // If the file exists, the directory it's in must exist too diff --git a/source/lib/task.h b/source/lib/task.h index b0f56f4..3520a91 100644 --- a/source/lib/task.h +++ b/source/lib/task.h @@ -2,10 +2,12 @@ #define TASK_H_ #include +#include #include -#include #include "libbuilder_api.h" +class FileTarget; + /** Tasks are used to manage other programs and worker threads involved in the build process. They are run asynchronously by default, but a wait() method is @@ -24,15 +26,15 @@ public: sigc::signal signal_finished; protected: - std::vector files; + std::vector targets; bool unlink = false; Task() = default; public: virtual ~Task() { } - /** Associate the task with a file. */ - void add_file(const Msp::FS::Path &); + /** Associate the task with a target. */ + void add_target(const FileTarget &); /** If set to true, the associated files are removed before the task is started. */