diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2022-05-29 14:55:51 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2022-06-09 22:15:32 +0200 |
commit | b74bd9e24e1205b7449404fd05172664b211d82c (patch) | |
tree | af69d4efbdddee347cd82c774880efa6820a0aa2 /src/tasks.cc | |
parent | 15eea63a6e7da37e7b4d643f189e6de150268ff8 (diff) |
Make all task lists std::set instead of std::list to make sure to not contain duplicates.
Diffstat (limited to 'src/tasks.cc')
-rw-r--r-- | src/tasks.cc | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/tasks.cc b/src/tasks.cc index 8ab296f..8bb8de6 100644 --- a/src/tasks.cc +++ b/src/tasks.cc @@ -5,6 +5,7 @@ #include <filesystem> #include <deque> +#include <list> #include <iostream> #include <algorithm> @@ -76,9 +77,9 @@ const std::deque<Target>& getTargets(const Settings& settings, return targets; } -std::list<std::shared_ptr<Task>> taskFactory(const BuildConfiguration& config, - const Settings& settings, - const std::string& sourceDir) +std::set<std::shared_ptr<Task>> taskFactory(const BuildConfiguration& config, + const Settings& settings, + const std::string& sourceDir) { std::filesystem::path targetFile(config.target); @@ -106,12 +107,12 @@ std::list<std::shared_ptr<Task>> taskFactory(const BuildConfiguration& config, } std::vector<std::string> objects; - std::list<std::shared_ptr<Task>> tasks; + std::set<std::shared_ptr<Task>> tasks; for(const auto& file : config.sources) { - tasks.emplace_back(std::make_shared<TaskCC>(config, settings, - sourceDir, file)); - objects.push_back(tasks.back()->target()); + auto task = std::make_shared<TaskCC>(config, settings, sourceDir, file); + tasks.insert(task); + objects.push_back(task->target()); } switch(target_type) @@ -121,8 +122,8 @@ std::list<std::shared_ptr<Task>> taskFactory(const BuildConfiguration& config, break; case TargetType::StaticLibrary: - tasks.emplace_back(std::make_shared<TaskAR>(config, settings, config.target, - objects, sourceDir)); + tasks.insert(std::make_shared<TaskAR>(config, settings, config.target, + objects, sourceDir)); break; #ifndef BOOTSTRAP case TargetType::DynamicLibrary: @@ -132,14 +133,14 @@ std::list<std::shared_ptr<Task>> taskFactory(const BuildConfiguration& config, std::cerr << "Dynamic library target must have 'lib' prefix\n"; exit(1); } - tasks.emplace_back(std::make_shared<TaskSO>(config, settings, config.target, - objects, sourceDir)); + tasks.insert(std::make_shared<TaskSO>(config, settings, config.target, + objects, sourceDir)); break; case TargetType::Executable: case TargetType::UnitTest: - tasks.emplace_back(std::make_shared<TaskLD>(config, settings, config.target, - objects, sourceDir)); + tasks.insert(std::make_shared<TaskLD>(config, settings, config.target, + objects, sourceDir)); break; case TargetType::Object: @@ -153,8 +154,8 @@ std::list<std::shared_ptr<Task>> taskFactory(const BuildConfiguration& config, return tasks; } -std::shared_ptr<Task> getNextTask(const std::list<std::shared_ptr<Task>>& allTasks, - std::list<std::shared_ptr<Task>>& dirtyTasks) +std::shared_ptr<Task> getNextTask(const std::set<std::shared_ptr<Task>>& allTasks, + std::set<std::shared_ptr<Task>>& dirtyTasks) { for(auto dirtyTask = dirtyTasks.begin(); dirtyTask != dirtyTasks.end(); @@ -172,12 +173,12 @@ std::shared_ptr<Task> getNextTask(const std::list<std::shared_ptr<Task>>& allTas return nullptr; } -std::list<std::shared_ptr<Task>> getTasks(const Settings& settings, - const std::vector<std::string> names, - bool resolve_externals) +std::set<std::shared_ptr<Task>> getTasks(const Settings& settings, + const std::vector<std::string> names, + bool resolve_externals) { auto& targets = getTargets(settings, resolve_externals); - std::list<std::shared_ptr<Task>> tasks; + std::set<std::shared_ptr<Task>> tasks; for(const auto& target : targets) { if(names.empty() || @@ -185,7 +186,7 @@ std::list<std::shared_ptr<Task>> getTasks(const Settings& settings, { std::vector<std::string> objects; auto t = taskFactory(target.config, settings, target.path); - tasks.insert(tasks.end(), t.begin(), t.end()); + tasks.insert(t.begin(), t.end()); } } |