diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2024-10-02 21:20:40 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2024-10-03 12:06:38 +0200 |
commit | 0008920eed996009068fe9f71512c436577b6220 (patch) | |
tree | 60350de98747a63e1739841b966269f5e312b9ba /src/tasks.cc | |
parent | a38c6682e4fb1f45aa1f37d10c2480aa517ea3bc (diff) |
Ensure the initial task order is preserved. Fixes bad ordering during linking.develop
Diffstat (limited to 'src/tasks.cc')
-rw-r--r-- | src/tasks.cc | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/tasks.cc b/src/tasks.cc index 22ad2d6..61c130b 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,18 +160,19 @@ 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(); ++dirtyTask) { + auto task = *dirtyTask; //std::cout << "Examining target " << (*dirtyTask)->target() << "\n"; - if((*dirtyTask)->ready()) + if(task->ready()) { dirtyTasks.erase(dirtyTask); - return *dirtyTask; + return task; } } @@ -179,12 +180,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 +193,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()); } } |