summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-09-12 13:06:39 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2021-09-12 13:09:32 +0200
commit86c7aa6f516bf6ed000f3eef26748997d6677c14 (patch)
treedad656b2b34b88a6279c42946f4a34aeaa1432c7 /src
parent5529b296834965afd9736b941aa2c094ff2f4648 (diff)
Separate target list creation from task list creation.
Diffstat (limited to 'src')
-rw-r--r--src/tasks.cc50
-rw-r--r--src/tasks.h12
2 files changed, 42 insertions, 20 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;
diff --git a/src/tasks.h b/src/tasks.h
index 119c7d6..04610e6 100644
--- a/src/tasks.h
+++ b/src/tasks.h
@@ -4,15 +4,21 @@
#include <string>
#include <list>
#include <memory>
+#include <deque>
#include "task.h"
class BuildConfiguration;
class Settings;
-std::list<std::shared_ptr<Task>> taskFactory(const BuildConfiguration& config,
- const Settings& settings,
- const std::string& sourceDir);
+struct Target
+{
+ BuildConfiguration config;
+ std::string path;
+};
+
+const std::deque<Target>& getTargets(const Settings& settings);
+
std::shared_ptr<Task> getNextTask(const std::list<std::shared_ptr<Task>>& allTasks,
std::list<std::shared_ptr<Task>>& dirtyTasks);
std::list<std::shared_ptr<Task>> getTasks(const Settings& settings);