diff options
Diffstat (limited to 'src/tasks.cc')
-rw-r--r-- | src/tasks.cc | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/src/tasks.cc b/src/tasks.cc index 2d8f46e..1607b37 100644 --- a/src/tasks.cc +++ b/src/tasks.cc @@ -13,6 +13,34 @@ #include "task_so.h" #include "rebuild.h" +const std::deque<Target>& getTargets(const Settings& settings) +{ + static bool initialised{false}; + static std::deque<Target> targets; + if(!initialised) + { + for(std::size_t i = 0; i < numConfigFiles; ++i) + { + std::string path = + std::filesystem::path(configFiles[i].file).parent_path().string(); + if(settings.verbose > 1) + { + std::cout << configFiles[i].file << " in path " << path << "\n"; + } + auto configs = configFiles[i].cb(); + for(const auto& config : configs) + { + targets.push_back({config, path}); + } + } + initialised = true; + } + + return targets; +} + +namespace +{ std::list<std::shared_ptr<Task>> taskFactory(const BuildConfiguration& config, const Settings& settings, const std::string& sourceDir) @@ -105,25 +133,13 @@ std::shared_ptr<Task> getNextTask(const std::list<std::shared_ptr<Task>>& allTas std::list<std::shared_ptr<Task>> getTasks(const Settings& settings) { - static std::deque<BuildConfiguration> build_configs; + auto& targets = getTargets(settings); std::list<std::shared_ptr<Task>> tasks; - for(std::size_t i = 0; i < numConfigFiles; ++i) + for(const auto& target : targets) { - std::string path = - std::filesystem::path(configFiles[i].file).parent_path().string(); - if(settings.verbose > 1) - { - std::cout << configFiles[i].file << " in path " << path << "\n"; - } - auto configs = configFiles[i].cb(); - for(const auto& config : configs) - { - build_configs.push_back(config); - const auto& build_config = build_configs.back(); - std::vector<std::string> objects; - auto t = taskFactory(build_config, settings, path); - tasks.insert(tasks.end(), t.begin(), t.end()); - } + std::vector<std::string> objects; + auto t = taskFactory(target.config, settings, target.path); + tasks.insert(tasks.end(), t.begin(), t.end()); } return tasks; |