diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2022-06-08 17:31:36 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2022-06-09 22:25:15 +0200 |
commit | 61f7f7538cc6abb0be64c35570f38dd2541d7451 (patch) | |
tree | 092c97084f191eb502b06740a76658432dada34a | |
parent | d9cb571fe126e7e94a52361d733161aa25f23597 (diff) |
Add const Settings& to build configuration callbacks.
-rw-r--r-- | ctor.cc | 2 | ||||
-rw-r--r-- | src/bootstrap.cc | 1 | ||||
-rw-r--r-- | src/build.cc | 2 | ||||
-rw-r--r-- | src/build.h | 3 | ||||
-rw-r--r-- | src/configure.cc | 3 | ||||
-rw-r--r-- | src/externals_manual.cc | 1 | ||||
-rw-r--r-- | src/libctor.cc | 1 | ||||
-rw-r--r-- | src/libctor.h | 12 | ||||
-rw-r--r-- | src/rebuild.cc | 7 | ||||
-rw-r--r-- | src/rebuild.h | 4 | ||||
-rw-r--r-- | src/settings.h | 13 | ||||
-rw-r--r-- | src/task.cc | 2 | ||||
-rw-r--r-- | src/task_ar.cc | 1 | ||||
-rw-r--r-- | src/task_cc.cc | 1 | ||||
-rw-r--r-- | src/task_ld.cc | 1 | ||||
-rw-r--r-- | src/task_so.cc | 1 | ||||
-rw-r--r-- | src/tasks.cc | 3 | ||||
-rw-r--r-- | src/unittest.cc | 1 | ||||
-rw-r--r-- | test/ctor.cc | 2 | ||||
-rw-r--r-- | test/source_type_test.cc | 1 | ||||
-rw-r--r-- | test/tasks_test.cc | 5 |
21 files changed, 25 insertions, 42 deletions
@@ -5,7 +5,7 @@ namespace { -BuildConfigurations ctorConfigs() +BuildConfigurations ctorConfigs(const Settings& settings) { return { 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, diff --git a/test/ctor.cc b/test/ctor.cc index 66f20f2..7d7a53c 100644 --- a/test/ctor.cc +++ b/test/ctor.cc @@ -5,7 +5,7 @@ namespace { -BuildConfigurations ctorTestConfigs() +BuildConfigurations ctorTestConfigs(const Settings& settings) { return { diff --git a/test/source_type_test.cc b/test/source_type_test.cc index 47d820d..ed7e783 100644 --- a/test/source_type_test.cc +++ b/test/source_type_test.cc @@ -2,7 +2,6 @@ #include <libctor.h> #include <task_cc.h> -#include <settings.h> std::ostream& operator<<(std::ostream& stream, const Language& lang) { diff --git a/test/tasks_test.cc b/test/tasks_test.cc index a807d32..2e0ffc7 100644 --- a/test/tasks_test.cc +++ b/test/tasks_test.cc @@ -2,11 +2,10 @@ #include <libctor.h> #include <tasks.h> -#include <settings.h> namespace { -BuildConfigurations ctorTestConfigs1() +BuildConfigurations ctorTestConfigs1(const Settings&) { return { @@ -20,7 +19,7 @@ BuildConfigurations ctorTestConfigs1() }; } -BuildConfigurations ctorTestConfigs2() +BuildConfigurations ctorTestConfigs2(const Settings&) { return { |