summaryrefslogtreecommitdiff
path: root/task.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-08-28 18:59:29 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2021-08-28 18:59:29 +0200
commit5da56616cccf4e595ec6a556cf1aef40b37746e3 (patch)
tree8142e294a251ca2ab1697f7541fe67dfd31622e0 /task.cc
parent0597cb9854d66d918762ff167148516b69c02e9a (diff)
Move sources to ... well, src ;)
Diffstat (limited to 'task.cc')
-rw-r--r--task.cc146
1 files changed, 0 insertions, 146 deletions
diff --git a/task.cc b/task.cc
deleted file mode 100644
index 962a02b..0000000
--- a/task.cc
+++ /dev/null
@@ -1,146 +0,0 @@
-#include "task.h"
-
-#include <unistd.h>
-#include <iostream>
-
-Task::Task(const BuildConfiguration& config,
- const std::vector<std::string>& depends)
- : dependsStr(depends)
- , config(config)
- , output_system(config.system)
-{
-}
-
-int Task::registerDepTasks(const std::list<std::shared_ptr<Task>>& tasks)
-{
- for(auto const& depStr : dependsStr)
- {
- bool found{false};
- for(const auto& task : tasks)
- {
- if(task->target() == depStr)
- {
- dependsTasks.push_back(task);
- found = true;
- }
- }
- if(!found)
- {
- std::cerr << "Could not find dependency " << depStr << " needed by " <<
- target() << " target\n";
- return 1;
- }
- }
-
- return 0;
-}
-
-std::string Task::name() const
-{
- return config.target;
-}
-
-bool Task::dirty()
-{
- for(const auto& task : dependsTasks)
- {
- if(task->dirty())
- {
- return true;
- }
- }
-
- return dirtyInner();
-}
-
-bool Task::ready()
-{
- for(const auto& task : dependsTasks)
- {
- if(task->dirty() || task->state() == State::Running)
- {
- return false;
- }
- }
-
- task_state.store(State::Ready);
- return true;
-}
-
-int Task::run()
-{
- if(task_state.load() == State::Done)
- {
- return 0;
- }
-
- task_state.store(State::Running);
- auto ret = runInner();
- if(ret == 0)
- {
- task_state.store(State::Done);
- }
- else
- {
- task_state.store(State::Error);
- }
-
- return ret;
-}
-
-State Task::state() const
-{
- return task_state.load();
-}
-
-const BuildConfiguration& Task::buildConfig() const
-{
- return config;
-}
-
-TargetType Task::targetType() const
-{
- return target_type;
-}
-
-Language Task::sourceLanguage() const
-{
- return source_language;
-}
-
-OutputSystem Task::outputSystem() const
-{
- return output_system;
-}
-
-std::string Task::compiler() const
-{
- switch(sourceLanguage())
- {
- case Language::C:
- switch(outputSystem())
- {
- case OutputSystem::Host:
- return getConfiguration(cfg::host_cc, "/usr/bin/gcc");
- case OutputSystem::Build:
- return getConfiguration(cfg::build_cc, "/usr/bin/gcc");
- }
- case Language::Cpp:
- switch(outputSystem())
- {
- case OutputSystem::Host:
- return getConfiguration(cfg::host_cxx, "/usr/bin/g++");
- case OutputSystem::Build:
- return getConfiguration(cfg::build_cxx, "/usr/bin/g++");
- }
- default:
- std::cerr << "Unknown CC target type\n";
- exit(1);
- break;
- }
-}
-
-std::list<std::shared_ptr<Task>> Task::getDependsTasks()
-{
- return dependsTasks;
-}