summaryrefslogtreecommitdiff
path: root/src/tasks.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2024-10-02 21:20:40 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2024-10-02 22:02:51 +0200
commit0d13088ab99cf7d981932451d65034595949ebf8 (patch)
treec3e89b948afe2ac3191833d94c971a4456ccc1a1 /src/tasks.cc
parenta38c6682e4fb1f45aa1f37d10c2480aa517ea3bc (diff)
Ensure the initial task order is preserved. Fixes bad ordering during linking.
Diffstat (limited to 'src/tasks.cc')
-rw-r--r--src/tasks.cc38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/tasks.cc b/src/tasks.cc
index 22ad2d6..daf5a80 100644
--- a/src/tasks.cc
+++ b/src/tasks.cc
@@ -70,11 +70,11 @@ const std::deque<Target>& getTargets(const ctor::settings& settings,
return targets;
}
-std::set<std::shared_ptr<Task>> taskFactory(const ctor::build_configuration& config,
- const ctor::settings& settings,
- const std::string& sourceDir)
+std::vector<std::shared_ptr<Task>> taskFactory(const ctor::build_configuration& config,
+ const ctor::settings& settings,
+ const std::string& sourceDir)
{
- std::set<std::shared_ptr<Task>> tasks;
+ std::vector<std::shared_ptr<Task>> tasks;
std::filesystem::path targetFile(config.target);
@@ -97,7 +97,7 @@ std::set<std::shared_ptr<Task>> taskFactory(const ctor::build_configuration& con
for(const auto& file : config.sources)
{
auto task = std::make_shared<TaskCC>(config, settings, sourceDir, file);
- tasks.insert(task);
+ tasks.push_back(task);
objects.push_back(task->targetFile().string());
}
}
@@ -107,7 +107,7 @@ std::set<std::shared_ptr<Task>> taskFactory(const ctor::build_configuration& con
for(const auto& file : config.sources)
{
auto task = std::make_shared<TaskFn>(config, settings, sourceDir, file);
- tasks.insert(task);
+ tasks.push_back(task);
objects.push_back(task->target());
}
}
@@ -127,8 +127,8 @@ std::set<std::shared_ptr<Task>> taskFactory(const ctor::build_configuration& con
case ctor::target_type::static_library:
case ctor::target_type::unit_test_library:
- tasks.insert(std::make_shared<TaskAR>(config, settings, config.target,
- objects, sourceDir));
+ tasks.push_back(std::make_shared<TaskAR>(config, settings, config.target,
+ objects, sourceDir));
break;
#ifndef BOOTSTRAP
case ctor::target_type::dynamic_library:
@@ -138,14 +138,14 @@ std::set<std::shared_ptr<Task>> taskFactory(const ctor::build_configuration& con
std::cerr << "Dynamic library target must have 'lib' prefix\n";
exit(1);
}
- tasks.insert(std::make_shared<TaskSO>(config, settings, config.target,
- objects, sourceDir));
+ tasks.push_back(std::make_shared<TaskSO>(config, settings, config.target,
+ objects, sourceDir));
break;
case ctor::target_type::executable:
case ctor::target_type::unit_test:
- tasks.insert(std::make_shared<TaskLD>(config, settings, config.target,
- objects, sourceDir));
+ tasks.push_back(std::make_shared<TaskLD>(config, settings, config.target,
+ objects, sourceDir));
break;
case ctor::target_type::object:
@@ -160,8 +160,8 @@ std::set<std::shared_ptr<Task>> taskFactory(const ctor::build_configuration& con
return tasks;
}
-std::shared_ptr<Task> getNextTask(const std::set<std::shared_ptr<Task>>& allTasks,
- std::set<std::shared_ptr<Task>>& dirtyTasks)
+std::shared_ptr<Task> getNextTask(const std::vector<std::shared_ptr<Task>>& allTasks,
+ std::vector<std::shared_ptr<Task>>& dirtyTasks)
{
for(auto dirtyTask = dirtyTasks.begin();
dirtyTask != dirtyTasks.end();
@@ -179,12 +179,12 @@ std::shared_ptr<Task> getNextTask(const std::set<std::shared_ptr<Task>>& allTask
return nullptr;
}
-std::set<std::shared_ptr<Task>> getTasks(const ctor::settings& settings,
- const std::vector<std::string> names,
- bool resolve_externals)
+std::vector<std::shared_ptr<Task>> getTasks(const ctor::settings& settings,
+ const std::vector<std::string> names,
+ bool resolve_externals)
{
auto& targets = getTargets(settings, resolve_externals);
- std::set<std::shared_ptr<Task>> tasks;
+ std::vector<std::shared_ptr<Task>> tasks;
for(const auto& target : targets)
{
if(names.empty() ||
@@ -192,7 +192,7 @@ std::set<std::shared_ptr<Task>> getTasks(const ctor::settings& settings,
{
std::vector<std::string> objects;
auto t = taskFactory(target.config, settings, target.path);
- tasks.insert(t.begin(), t.end());
+ tasks.insert(tasks.end(), t.begin(), t.end());
}
}