diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-08-28 18:59:29 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-08-28 18:59:29 +0200 |
commit | 5da56616cccf4e595ec6a556cf1aef40b37746e3 (patch) | |
tree | 8142e294a251ca2ab1697f7541fe67dfd31622e0 /src/task.h | |
parent | 0597cb9854d66d918762ff167148516b69c02e9a (diff) |
Move sources to ... well, src ;)
Diffstat (limited to 'src/task.h')
-rw-r--r-- | src/task.h | 60 |
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}; +}; |