summaryrefslogtreecommitdiff
path: root/src/task.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/task.h')
-rw-r--r--src/task.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/task.h b/src/task.h
new file mode 100644
index 0000000..98363a1
--- /dev/null
+++ b/src/task.h
@@ -0,0 +1,60 @@
+// -*- c++ -*-
+#pragma once
+
+#include <vector>
+#include <string>
+#include <atomic>
+#include <list>
+#include <memory>
+
+#include "libcppbuild.h"
+
+enum class State
+{
+ Unknown,
+ Ready,
+ Running,
+ Done,
+ Error,
+};
+
+class Task
+{
+public:
+ Task(const BuildConfiguration& config,
+ const std::vector<std::string>& depends = {});
+
+ int registerDepTasks(const std::list<std::shared_ptr<Task>>& tasks);
+
+ virtual std::string name() const;
+ bool dirty();
+ bool ready();
+ int run();
+ State state() const;
+ virtual int clean() = 0 ;
+ virtual std::vector<std::string> depends() const = 0;
+ virtual std::string target() const = 0;
+
+ virtual std::string toJSON() const { return {}; };
+
+ const BuildConfiguration& buildConfig() const;
+
+ TargetType targetType() const;
+ Language sourceLanguage() const;
+ OutputSystem outputSystem() const;
+ std::string compiler() const;
+
+ std::list<std::shared_ptr<Task>> getDependsTasks();
+
+protected:
+ std::atomic<State> task_state{State::Unknown};
+ virtual int runInner() { return 0; };
+ virtual bool dirtyInner() { return false; }
+
+ std::vector<std::string> dependsStr;
+ std::list<std::shared_ptr<Task>> dependsTasks;
+ const BuildConfiguration& config;
+ TargetType target_type{TargetType::Auto};
+ Language source_language{Language::Auto};
+ OutputSystem output_system{OutputSystem::Host};
+};