summaryrefslogtreecommitdiff
path: root/src/build.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/build.cc
parenta38c6682e4fb1f45aa1f37d10c2480aa517ea3bc (diff)
Ensure the initial task order is preserved. Fixes bad ordering during linking.
Diffstat (limited to 'src/build.cc')
-rw-r--r--src/build.cc43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/build.cc b/src/build.cc
index ad30719..ea65656 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -4,12 +4,11 @@
#include "build.h"
#include <future>
-#include <vector>
#include <iostream>
#include <chrono>
-#include <set>
#include <thread>
#include <list>
+#include <algorithm>
#include "ctor.h"
@@ -17,8 +16,8 @@ using namespace std::chrono_literals;
int build(const ctor::settings& settings,
const std::string& name,
- const std::set<std::shared_ptr<Task>>& tasks,
- const std::set<std::shared_ptr<Task>>& all_tasks,
+ const std::vector<std::shared_ptr<Task>>& tasks,
+ const std::vector<std::shared_ptr<Task>>& all_tasks,
bool dryrun)
{
if(settings.verbose > 1)
@@ -26,12 +25,13 @@ int build(const ctor::settings& settings,
std::cout << "Building '" << name << "'\n";
}
- std::set<std::shared_ptr<Task>> dirtyTasks;
+ std::vector<std::shared_ptr<Task>> dirtyTasks;
for(auto task : tasks)
{
- if(task->dirty())
+ if(task->dirty() &&
+ std::find(dirtyTasks.begin(), dirtyTasks.end(), task) == dirtyTasks.end())
{
- dirtyTasks.insert(task);
+ dirtyTasks.push_back(task);
}
}
@@ -135,10 +135,10 @@ int build(const ctor::settings& settings,
namespace
{
-std::set<std::shared_ptr<Task>> getDepTasks(std::shared_ptr<Task> task)
+std::vector<std::shared_ptr<Task>> getDepTasks(std::shared_ptr<Task> task)
{
- std::set<std::shared_ptr<Task>> tasks;
- tasks.insert(task);
+ std::vector<std::shared_ptr<Task>> tasks;
+ tasks.push_back(task);
auto deps = task->getDependsTasks();
for(const auto& dep : deps)
@@ -146,7 +146,10 @@ std::set<std::shared_ptr<Task>> getDepTasks(std::shared_ptr<Task> task)
auto depSet = getDepTasks(dep);
for(const auto& dep : depSet)
{
- tasks.insert(dep);
+ if(std::find(tasks.begin(), tasks.end(), dep) == tasks.end())
+ {
+ tasks.push_back(dep);
+ }
}
}
@@ -156,7 +159,7 @@ std::set<std::shared_ptr<Task>> getDepTasks(std::shared_ptr<Task> task)
int build(const ctor::settings& settings,
const std::string& name,
- const std::set<std::shared_ptr<Task>>& all_tasks,
+ const std::vector<std::shared_ptr<Task>>& all_tasks,
bool dryrun)
{
bool task_found{false};
@@ -167,10 +170,13 @@ int build(const ctor::settings& settings,
task_found = true;
auto depSet = getDepTasks(task);
- std::set<std::shared_ptr<Task>> ts;
+ std::vector<std::shared_ptr<Task>> ts;
for(const auto& task : depSet)
{
- ts.insert(task);
+ if(std::find(ts.begin(), ts.end(), task) == ts.end())
+ {
+ ts.push_back(task);
+ }
}
auto ret = build(settings, name, ts, all_tasks, dryrun);
@@ -195,11 +201,11 @@ int build(const ctor::settings& settings,
int build(const ctor::settings& settings,
const std::string& name,
const std::vector<Target>& targets,
- const std::set<std::shared_ptr<Task>>& all_tasks,
+ const std::vector<std::shared_ptr<Task>>& all_tasks,
bool dryrun)
{
bool task_found{false};
- std::set<std::shared_ptr<Task>> ts;
+ std::vector<std::shared_ptr<Task>> ts;
for(const auto& target : targets)
{
@@ -213,7 +219,10 @@ int build(const ctor::settings& settings,
auto depSet = getDepTasks(task);
for(const auto& task : depSet)
{
- ts.insert(task);
+ if(std::find(ts.begin(), ts.end(), task) == ts.end())
+ {
+ ts.push_back(task);
+ }
}
}
}