summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap.cc1
-rw-r--r--src/build.cc2
-rw-r--r--src/build.h3
-rw-r--r--src/configure.cc3
-rw-r--r--src/externals_manual.cc1
-rw-r--r--src/libctor.cc1
-rw-r--r--src/libctor.h12
-rw-r--r--src/rebuild.cc7
-rw-r--r--src/rebuild.h4
-rw-r--r--src/settings.h13
-rw-r--r--src/task.cc2
-rw-r--r--src/task_ar.cc1
-rw-r--r--src/task_cc.cc1
-rw-r--r--src/task_ld.cc1
-rw-r--r--src/task_so.cc1
-rw-r--r--src/tasks.cc3
-rw-r--r--src/unittest.cc1
17 files changed, 21 insertions, 36 deletions
diff --git a/src/bootstrap.cc b/src/bootstrap.cc
index 64f11fc..6e4ef19 100644
--- a/src/bootstrap.cc
+++ b/src/bootstrap.cc
@@ -7,7 +7,6 @@
#define BOOTSTRAP
#include "libctor.h"
-#include "settings.h"
#include "util.cc"
#include "rebuild.cc"
diff --git a/src/build.cc b/src/build.cc
index cb830ac..081c156 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -11,6 +11,8 @@
#include <thread>
#include <list>
+#include "libctor.h"
+
using namespace std::chrono_literals;
int build(const Settings& settings,
diff --git a/src/build.h b/src/build.h
index f3a1419..caf7a68 100644
--- a/src/build.h
+++ b/src/build.h
@@ -8,9 +8,10 @@
#include <memory>
#include "task.h"
-#include "settings.h"
#include "tasks.h"
+struct Settings;
+
//! Dry-run returns number of dirty tasks but otherwise does nothing.
int build(const Settings& settings,
const std::string& name,
diff --git a/src/configure.cc b/src/configure.cc
index 02e8224..bc7d3e8 100644
--- a/src/configure.cc
+++ b/src/configure.cc
@@ -10,7 +10,6 @@
#include <getoptpp/getoptpp.hpp>
-#include "settings.h"
#include "execute.h"
#include "libctor.h"
#include "tasks.h"
@@ -260,7 +259,7 @@ int regenerateCache(const Settings& default_settings,
ExternalConfigurations externalConfigs;
for(std::size_t i = 0; i < numExternalConfigFiles; ++i)
{
- auto newExternalConfigs = externalConfigFiles[i].cb();
+ auto newExternalConfigs = externalConfigFiles[i].cb(settings);
externalConfigs.insert(externalConfigs.end(),
newExternalConfigs.begin(),
newExternalConfigs.end());
diff --git a/src/externals_manual.cc b/src/externals_manual.cc
index afea257..79c9be3 100644
--- a/src/externals_manual.cc
+++ b/src/externals_manual.cc
@@ -6,7 +6,6 @@
#include <map>
#include "libctor.h"
-#include "settings.h"
extern std::map<std::string, std::string> external_includedir;
extern std::map<std::string, std::string> external_libdir;
diff --git a/src/libctor.cc b/src/libctor.cc
index a4aec86..d188771 100644
--- a/src/libctor.cc
+++ b/src/libctor.cc
@@ -20,7 +20,6 @@
#include <getoptpp/getoptpp.hpp>
#include "libctor.h"
-#include "settings.h"
#include "configure.h"
#include "rebuild.h"
#include "tasks.h"
diff --git a/src/libctor.h b/src/libctor.h
index 70f2c3e..f80a5c5 100644
--- a/src/libctor.h
+++ b/src/libctor.h
@@ -8,6 +8,7 @@
#include <vector>
#include <map>
#include <variant>
+#include <cstddef>
enum class TargetType
{
@@ -55,6 +56,13 @@ struct Flags
std::vector<std::string> asmflags; // flags for asm translator
};
+struct Settings
+{
+ std::string builddir{"build"};
+ std::size_t parallel_processes{1};
+ int verbose{0}; // -1: completely silent, 0: normal, 1: verbose, ...
+};
+
struct BuildConfiguration
{
std::string name; // Name - used for referring in other configurations.
@@ -69,7 +77,7 @@ struct BuildConfiguration
using BuildConfigurations = std::vector<BuildConfiguration>;
-int reg(BuildConfigurations (*cb)(),
+int reg(BuildConfigurations (*cb)(const Settings&),
const std::source_location location = std::source_location::current());
// This type will use flags verbatim
@@ -87,7 +95,7 @@ struct ExternalConfiguration
using ExternalConfigurations = std::vector<ExternalConfiguration>;
-int reg(ExternalConfigurations (*cb)(),
+int reg(ExternalConfigurations (*cb)(const Settings&),
const std::source_location location = std::source_location::current());
// Convenience macro - ugly but keeps things simple(r)
diff --git a/src/rebuild.cc b/src/rebuild.cc
index 7c34e77..3e0e78d 100644
--- a/src/rebuild.cc
+++ b/src/rebuild.cc
@@ -9,7 +9,6 @@
#include <source_location>
#include "configure.h"
-#include "settings.h"
#include "libctor.h"
#include "tasks.h"
#include "build.h"
@@ -18,7 +17,7 @@
std::array<BuildConfigurationEntry, 1024> configFiles;
std::size_t numConfigFiles{0};
-int reg(BuildConfigurations (*cb)(),
+int reg(BuildConfigurations (*cb)(const Settings&),
const std::source_location location)
{
// NOTE: std::cout cannot be used here
@@ -48,7 +47,7 @@ int reg(const char* location)
configFiles[numConfigFiles].file = location;
configFiles[numConfigFiles].cb =
- [](){ return std::vector<BuildConfiguration>{}; };
+ [](const Settings&){ return std::vector<BuildConfiguration>{}; };
++numConfigFiles;
return 0;
@@ -97,7 +96,7 @@ int unreg(const char* location)
std::array<ExternalConfigurationEntry, 1024> externalConfigFiles;
std::size_t numExternalConfigFiles{0};
-int reg(ExternalConfigurations (*cb)(),
+int reg(ExternalConfigurations (*cb)(const Settings&),
const std::source_location location)
{
// NOTE: std::cout cannot be used here
diff --git a/src/rebuild.h b/src/rebuild.h
index 0845d30..f1255c6 100644
--- a/src/rebuild.h
+++ b/src/rebuild.h
@@ -13,13 +13,13 @@ class Settings;
struct BuildConfigurationEntry
{
const char* file;
- BuildConfigurations (*cb)();
+ BuildConfigurations (*cb)(const Settings&);
};
struct ExternalConfigurationEntry
{
const char* file;
- ExternalConfigurations (*cb)();
+ ExternalConfigurations (*cb)(const Settings&);
};
extern std::array<BuildConfigurationEntry, 1024> configFiles;
diff --git a/src/settings.h b/src/settings.h
deleted file mode 100644
index 48e3619..0000000
--- a/src/settings.h
+++ /dev/null
@@ -1,13 +0,0 @@
-// -*- c++ -*-
-// Distributed under the BSD 2-Clause License.
-// See accompanying file LICENSE for details.
-#pragma once
-
-#include <cstddef>
-
-struct Settings
-{
- std::string builddir{"build"};
- std::size_t parallel_processes{1};
- int verbose{0}; // -1: completely silent, 0: normal, 1: verbose, ...
-};
diff --git a/src/task.cc b/src/task.cc
index 3ec48f5..37e1879 100644
--- a/src/task.cc
+++ b/src/task.cc
@@ -6,8 +6,6 @@
#include <unistd.h>
#include <iostream>
-#include "settings.h"
-
Task::Task(const BuildConfiguration& config, const Settings& settings,
const std::string& sourceDir)
: config(config)
diff --git a/src/task_ar.cc b/src/task_ar.cc
index 5a86ead..3e1746c 100644
--- a/src/task_ar.cc
+++ b/src/task_ar.cc
@@ -7,7 +7,6 @@
#include <fstream>
#include "libctor.h"
-#include "settings.h"
#include "execute.h"
#include "util.h"
diff --git a/src/task_cc.cc b/src/task_cc.cc
index 41a97f3..673c16d 100644
--- a/src/task_cc.cc
+++ b/src/task_cc.cc
@@ -8,7 +8,6 @@
#include <cassert>
#include "libctor.h"
-#include "settings.h"
#include "execute.h"
#include "util.h"
diff --git a/src/task_ld.cc b/src/task_ld.cc
index e78a1e6..3e05fb1 100644
--- a/src/task_ld.cc
+++ b/src/task_ld.cc
@@ -7,7 +7,6 @@
#include <fstream>
#include "libctor.h"
-#include "settings.h"
#include "execute.h"
#include "util.h"
diff --git a/src/task_so.cc b/src/task_so.cc
index 34de2bb..1af14b5 100644
--- a/src/task_so.cc
+++ b/src/task_so.cc
@@ -7,7 +7,6 @@
#include <fstream>
#include "libctor.h"
-#include "settings.h"
#include "execute.h"
#include "util.h"
diff --git a/src/tasks.cc b/src/tasks.cc
index af364b9..646292a 100644
--- a/src/tasks.cc
+++ b/src/tasks.cc
@@ -9,7 +9,6 @@
#include <iostream>
#include <algorithm>
-#include "settings.h"
#include "libctor.h"
#include "task.h"
#include "task_cc.h"
@@ -35,7 +34,7 @@ const std::deque<Target>& getTargets(const Settings& settings,
{
std::cout << configFiles[i].file << " in path " << path << "\n";
}
- auto configs = configFiles[i].cb();
+ auto configs = configFiles[i].cb(settings);
for(auto& config : configs)
{
if(resolve_externals)
diff --git a/src/unittest.cc b/src/unittest.cc
index 02f4229..f18de47 100644
--- a/src/unittest.cc
+++ b/src/unittest.cc
@@ -6,7 +6,6 @@
#include <iostream>
#include "execute.h"
-#include "settings.h"
#include "task.h"
int runUnitTests(std::set<std::shared_ptr<Task>>& tasks,