summaryrefslogtreecommitdiff
path: root/src/task.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/task.h')
-rw-r--r--src/task.h34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/task.h b/src/task.h
index 78dc904..be3995f 100644
--- a/src/task.h
+++ b/src/task.h
@@ -6,8 +6,9 @@
#include <vector>
#include <string>
#include <atomic>
-#include <list>
+#include <set>
#include <memory>
+#include <filesystem>
#include "libctor.h"
@@ -20,12 +21,18 @@ enum class State
Error,
};
+struct Settings;
+
class Task
{
public:
- Task(const BuildConfiguration& config);
+ Task(const BuildConfiguration& config, const Settings& settings,
+ const std::string& sourceDir);
+
+ int registerDepTasks(const std::set<std::shared_ptr<Task>>& tasks);
+ virtual int registerDepTasksInner(const std::set<std::shared_ptr<Task>>& tasks) { return 0; }
- int registerDepTasks(const std::list<std::shared_ptr<Task>>& tasks);
+ bool operator==(const std::string& dep);
virtual std::string name() const;
bool dirty();
@@ -34,10 +41,23 @@ public:
State state() const;
virtual int clean() = 0 ;
virtual std::vector<std::string> depends() const = 0;
+
+ //! Raw target name as stated in ctor.cc config file or (in case of a derived
+ //! target) the calculated target without builddir prefix.
virtual std::string target() const = 0;
+ //! Target file with full path prefix
+ virtual std::filesystem::path targetFile() const = 0;
+
+ //! Returns true for tasks that are non-target tasks, ie. for example derived
+ //! objects files from target sources.
+ virtual bool derived() const = 0;
+
virtual std::string toJSON() const { return {}; };
+ //! Returns a reference to the originating build config.
+ //! Note: the build config of a derived task will be that of its parent
+ //! (target) task.
const BuildConfiguration& buildConfig() const;
TargetType targetType() const;
@@ -45,7 +65,9 @@ public:
OutputSystem outputSystem() const;
std::string compiler() const;
- std::list<std::shared_ptr<Task>> getDependsTasks();
+ std::set<std::shared_ptr<Task>> getDependsTasks();
+
+ virtual std::string source() const { return {}; }
protected:
std::atomic<State> task_state{State::Unknown};
@@ -53,9 +75,11 @@ protected:
virtual bool dirtyInner() { return false; }
std::vector<std::string> dependsStr;
- std::list<std::shared_ptr<Task>> dependsTasks;
+ std::set<std::shared_ptr<Task>> dependsTasks;
const BuildConfiguration& config;
TargetType target_type{TargetType::Auto};
Language source_language{Language::Auto};
OutputSystem output_system{OutputSystem::Host};
+ const Settings& settings;
+ std::string sourceDir;
};