summaryrefslogtreecommitdiff
path: root/src/tasks.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/tasks.cc')
-rw-r--r--src/tasks.cc34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/tasks.cc b/src/tasks.cc
index 61c130b..2f9e47a 100644
--- a/src/tasks.cc
+++ b/src/tasks.cc
@@ -8,6 +8,7 @@
#include <list>
#include <iostream>
#include <algorithm>
+#include <span>
#include "ctor.h"
#include "task.h"
@@ -24,20 +25,22 @@
const std::deque<Target>& getTargets(const ctor::settings& settings,
bool resolve_externals)
{
+ auto config_files = std::span(configFiles).subspan(0, numConfigFiles);
+
static bool initialised{false};
static std::deque<Target> targets;
if(!initialised)
{
const auto& externals = ctor::get_configuration().externals;
- for(std::size_t i = 0; i < numConfigFiles; ++i)
+ for(const auto& config_file : config_files)
{
std::string path =
- std::filesystem::path(configFiles[i].file).parent_path().string();
+ std::filesystem::path(config_file.file).parent_path().string();
if(settings.verbose > 1)
{
- std::cout << configFiles[i].file << " in path " << path << "\n";
+ std::cout << config_file.file << " in path " << path << "\n";
}
- auto configs = configFiles[i].cb(settings);
+ auto configs = config_file.cb(settings);
for(auto& config : configs)
{
if(resolve_externals)
@@ -72,7 +75,8 @@ const std::deque<Target>& getTargets(const ctor::settings& settings,
std::vector<std::shared_ptr<Task>> taskFactory(const ctor::build_configuration& config,
const ctor::settings& settings,
- const std::string& sourceDir)
+ const std::string& sourceDir,
+ bool is_self)
{
std::vector<std::shared_ptr<Task>> tasks;
@@ -91,14 +95,20 @@ std::vector<std::shared_ptr<Task>> taskFactory(const ctor::build_configuration&
}
}
+ const auto& c = ctor::get_configuration();
std::vector<std::string> objects;
if(target_type != ctor::target_type::function)
{
- for(const auto& file : config.sources)
+ for(const auto& source : config.sources)
{
- auto task = std::make_shared<TaskCC>(config, settings, sourceDir, file);
- tasks.push_back(task);
- objects.push_back(task->targetFile().string());
+ if(source.toolchain == ctor::toolchain::any ||
+ (config.system == ctor::output_system::build && source.toolchain == c.build_toolchain) ||
+ (config.system == ctor::output_system::host && source.toolchain == c.host_toolchain))
+ {
+ auto task = std::make_shared<TaskCC>(config, settings, sourceDir, source);
+ tasks.push_back(task);
+ objects.push_back(task->targetFile().string());
+ }
}
}
#ifndef BOOTSTRAP
@@ -145,7 +155,7 @@ std::vector<std::shared_ptr<Task>> taskFactory(const ctor::build_configuration&
case ctor::target_type::executable:
case ctor::target_type::unit_test:
tasks.push_back(std::make_shared<TaskLD>(config, settings, config.target,
- objects, sourceDir));
+ objects, sourceDir, is_self));
break;
case ctor::target_type::object:
@@ -160,7 +170,7 @@ std::vector<std::shared_ptr<Task>> taskFactory(const ctor::build_configuration&
return tasks;
}
-std::shared_ptr<Task> getNextTask(const std::vector<std::shared_ptr<Task>>& allTasks,
+std::shared_ptr<Task> getNextTask([[maybe_unused]]const std::vector<std::shared_ptr<Task>>& allTasks,
std::vector<std::shared_ptr<Task>>& dirtyTasks)
{
for(auto dirtyTask = dirtyTasks.begin();
@@ -192,7 +202,7 @@ std::vector<std::shared_ptr<Task>> getTasks(const ctor::settings& settings,
std::find(std::begin(names), std::end(names), target.config.target) != std::end(names))
{
std::vector<std::string> objects;
- auto t = taskFactory(target.config, settings, target.path);
+ auto t = taskFactory(target.config, settings, target.path, false);
tasks.insert(tasks.end(), t.begin(), t.end());
}
}