From de26eed5157a1b5efc2a72668b4f4a22638f2774 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 27 Dec 2022 12:58:11 +0100 Subject: Rename libctor.h to ctor.h --- README.md | 2 +- ctor.cc | 2 +- examples/cppbuild.cc | 2 +- examples/ctor.cc | 2 +- examples/subdir/ctor.cc | 2 +- src/bootstrap.cc | 2 +- src/build.cc | 2 +- src/configure.cc | 4 +- src/ctor.h | 154 ++++++++++++++++++++++++++++++++++++ src/externals_manual.cc | 2 +- src/libctor.cc | 2 +- src/libctor.h | 154 ------------------------------------ src/rebuild.cc | 2 +- src/rebuild.h | 2 +- src/task.h | 2 +- src/task_ar.cc | 2 +- src/task_cc.cc | 2 +- src/task_fn.cc | 2 +- src/task_ld.cc | 2 +- src/task_so.cc | 2 +- src/tasks.cc | 2 +- src/tools.h | 2 +- src/util.h | 2 +- test/ctor.cc | 2 +- test/source_type_test.cc | 2 +- test/suite/ctor_files/ctor.cc.bar | 2 +- test/suite/ctor_files/ctor.cc.base | 2 +- test/suite/ctor_files/ctor.cc.multi | 2 +- test/tasks_test.cc | 2 +- 29 files changed, 182 insertions(+), 182 deletions(-) create mode 100644 src/ctor.h delete mode 100644 src/libctor.h diff --git a/README.md b/README.md index caad51d..1a02be1 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Step 1: Create a build configuration, in C++ A really simple example ('hello_config.cc'): ```c++ -#include "libctor.h" +#include "ctor.h" namespace { diff --git a/ctor.cc b/ctor.cc index 445f18a..7f936c6 100644 --- a/ctor.cc +++ b/ctor.cc @@ -1,7 +1,7 @@ // -*- c++ -*- // Distributed under the BSD 2-Clause License. // See accompanying file LICENSE for details. -#include +#include namespace { diff --git a/examples/cppbuild.cc b/examples/cppbuild.cc index eafac8d..9e1014f 100644 --- a/examples/cppbuild.cc +++ b/examples/cppbuild.cc @@ -1,4 +1,4 @@ -#include "libctor.h" +#include "ctor.h" namespace { diff --git a/examples/ctor.cc b/examples/ctor.cc index 1a02e90..6ed8c6c 100644 --- a/examples/ctor.cc +++ b/examples/ctor.cc @@ -1,7 +1,7 @@ // -*- c++ -*- // Distributed under the BSD 2-Clause License. // See accompanying file LICENSE for details. -#include "libctor.h" +#include "ctor.h" namespace { diff --git a/examples/subdir/ctor.cc b/examples/subdir/ctor.cc index b5f5885..2e3de9f 100644 --- a/examples/subdir/ctor.cc +++ b/examples/subdir/ctor.cc @@ -1,7 +1,7 @@ // -*- c++ -*- // Distributed under the BSD 2-Clause License. // See accompanying file LICENSE for details. -#include "../libctor.h" +#include "../ctor.h" namespace { diff --git a/src/bootstrap.cc b/src/bootstrap.cc index 9a3c321..9079092 100644 --- a/src/bootstrap.cc +++ b/src/bootstrap.cc @@ -6,7 +6,7 @@ #define BOOTSTRAP -#include "libctor.h" +#include "ctor.h" #include "util.cc" #include "rebuild.cc" diff --git a/src/build.cc b/src/build.cc index 98952e0..5ea1a13 100644 --- a/src/build.cc +++ b/src/build.cc @@ -11,7 +11,7 @@ #include #include -#include "libctor.h" +#include "ctor.h" using namespace std::chrono_literals; diff --git a/src/configure.cc b/src/configure.cc index a81f8ad..86538ab 100644 --- a/src/configure.cc +++ b/src/configure.cc @@ -11,7 +11,7 @@ #include #include "execute.h" -#include "libctor.h" +#include "ctor.h" #include "tasks.h" #include "rebuild.h" #include "externals.h" @@ -379,7 +379,7 @@ int regenerateCache(const Settings& default_settings, std::cout << "Writing results to: " << configurationFile.string() << "\n"; { std::ofstream istr(configurationFile); - istr << "#include \n\n"; + istr << "#include \n\n"; istr << "const Configuration& configuration()\n"; istr << "{\n"; istr << " static Configuration cfg =\n"; diff --git a/src/ctor.h b/src/ctor.h new file mode 100644 index 0000000..96e1115 --- /dev/null +++ b/src/ctor.h @@ -0,0 +1,154 @@ +// -*- c++ -*- +// Distributed under the BSD 2-Clause License. +// See accompanying file LICENSE for details. +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +enum class TargetType +{ + Auto, // Default - deduce from target name and sources extensions + + Executable, + StaticLibrary, + DynamicLibrary, + Object, + UnitTest, + UnitTestLib, + Function, +}; + +enum class Language +{ + Auto, // Default - deduce language from source extensions + + C, + Cpp, + Asm, +}; + +enum class OutputSystem +{ + Host, // Output for the target system + Build, // Internal tool during cross-compilation +}; + +struct Source +{ + Source(const char* file) : file(file) {} + Source(const std::string& file) : file(file) {} + Source(const char* file, Language lang) : file(file), language(lang) {} + Source(const std::string& file, Language lang) : file(file), language(lang) {} + + Source(const char* file, const char* output) : file(file), output(output) {} + Source(const std::string& file, const std::string& output) : file(file), output(output) {} + Source(const char* file, Language lang, const char* output) : file(file), language(lang), output(output) {} + Source(const std::string& file, Language lang, const std::string& output) : file(file), language(lang), output(output) {} + + std::string file; + Language language{Language::Auto}; + std::string output{}; +}; + +struct Flags +{ + std::vector cxxflags; // flags for c++ compiler + std::vector cflags; // flags for c compiler + std::vector ldflags; // flags for linker + std::vector 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; +using GeneratorCb = std::function; + +struct BuildConfiguration +{ + std::string name; // Name - used for referring in other configurations. + TargetType type{TargetType::Auto}; + OutputSystem system{OutputSystem::Host}; + std::string target; // Output target file for this configuration + std::vector sources; // source list + std::vector depends; // internal target dependencies + Flags flags; + std::vector externals; // externals used by this configuration + GeneratorCb function; +}; + +using BuildConfigurations = std::vector; + +int reg(BuildConfigurations (*cb)(const Settings&), + const std::source_location location = std::source_location::current()); + +// This type will use flags verbatim +struct ExternalManual +{ + Flags flags; +}; + + +struct ExternalConfiguration +{ + std::string name; // Name for configuration + OutputSystem system{OutputSystem::Host}; + std::variant external; +}; + +using ExternalConfigurations = std::vector; + +int reg(ExternalConfigurations (*cb)(const Settings&), + const std::source_location location = std::source_location::current()); + +// Convenience macro - ugly but keeps things simple(r) +#define CONCAT(a, b) CONCAT_INNER(a, b) +#define CONCAT_INNER(a, b) a ## b +#define UNIQUE_NAME(base) CONCAT(base, __LINE__) +#define REG(cb) namespace { int UNIQUE_NAME(unique) = reg(cb); } + +// Predefined configuration keys +namespace cfg +{ +constexpr auto builddir = "builddir"; + +constexpr auto host_cc = "host-cc"; +constexpr auto host_cxx = "host-cpp"; +constexpr auto host_ar = "host-ar"; +constexpr auto host_ld = "host-ld"; + +constexpr auto build_cc = "build-cc"; +constexpr auto build_cxx = "build-cpp"; +constexpr auto build_ar = "build-ar"; +constexpr auto build_ld = "build-ld"; + +constexpr auto ctor_includedir = "ctor-includedir"; +constexpr auto ctor_libdir = "ctor-libdir"; +} + +struct Configuration +{ + std::vector args; // vector of arguments used when last calling configure + std::map env; // env used when last calling configure + + std::map tools; // tools + std::map externals; +}; + +const Configuration& configuration(); +bool hasConfiguration(const std::string& key); +const std::string& getConfiguration(const std::string& key, + const std::string& defaultValue = {}); diff --git a/src/externals_manual.cc b/src/externals_manual.cc index 0e3cdfd..3f00698 100644 --- a/src/externals_manual.cc +++ b/src/externals_manual.cc @@ -5,7 +5,7 @@ #include -#include "libctor.h" +#include "ctor.h" #include "util.h" #include "tools.h" diff --git a/src/libctor.cc b/src/libctor.cc index d188771..45fc94d 100644 --- a/src/libctor.cc +++ b/src/libctor.cc @@ -19,7 +19,7 @@ #include -#include "libctor.h" +#include "ctor.h" #include "configure.h" #include "rebuild.h" #include "tasks.h" diff --git a/src/libctor.h b/src/libctor.h deleted file mode 100644 index 96e1115..0000000 --- a/src/libctor.h +++ /dev/null @@ -1,154 +0,0 @@ -// -*- c++ -*- -// Distributed under the BSD 2-Clause License. -// See accompanying file LICENSE for details. -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -enum class TargetType -{ - Auto, // Default - deduce from target name and sources extensions - - Executable, - StaticLibrary, - DynamicLibrary, - Object, - UnitTest, - UnitTestLib, - Function, -}; - -enum class Language -{ - Auto, // Default - deduce language from source extensions - - C, - Cpp, - Asm, -}; - -enum class OutputSystem -{ - Host, // Output for the target system - Build, // Internal tool during cross-compilation -}; - -struct Source -{ - Source(const char* file) : file(file) {} - Source(const std::string& file) : file(file) {} - Source(const char* file, Language lang) : file(file), language(lang) {} - Source(const std::string& file, Language lang) : file(file), language(lang) {} - - Source(const char* file, const char* output) : file(file), output(output) {} - Source(const std::string& file, const std::string& output) : file(file), output(output) {} - Source(const char* file, Language lang, const char* output) : file(file), language(lang), output(output) {} - Source(const std::string& file, Language lang, const std::string& output) : file(file), language(lang), output(output) {} - - std::string file; - Language language{Language::Auto}; - std::string output{}; -}; - -struct Flags -{ - std::vector cxxflags; // flags for c++ compiler - std::vector cflags; // flags for c compiler - std::vector ldflags; // flags for linker - std::vector 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; -using GeneratorCb = std::function; - -struct BuildConfiguration -{ - std::string name; // Name - used for referring in other configurations. - TargetType type{TargetType::Auto}; - OutputSystem system{OutputSystem::Host}; - std::string target; // Output target file for this configuration - std::vector sources; // source list - std::vector depends; // internal target dependencies - Flags flags; - std::vector externals; // externals used by this configuration - GeneratorCb function; -}; - -using BuildConfigurations = std::vector; - -int reg(BuildConfigurations (*cb)(const Settings&), - const std::source_location location = std::source_location::current()); - -// This type will use flags verbatim -struct ExternalManual -{ - Flags flags; -}; - - -struct ExternalConfiguration -{ - std::string name; // Name for configuration - OutputSystem system{OutputSystem::Host}; - std::variant external; -}; - -using ExternalConfigurations = std::vector; - -int reg(ExternalConfigurations (*cb)(const Settings&), - const std::source_location location = std::source_location::current()); - -// Convenience macro - ugly but keeps things simple(r) -#define CONCAT(a, b) CONCAT_INNER(a, b) -#define CONCAT_INNER(a, b) a ## b -#define UNIQUE_NAME(base) CONCAT(base, __LINE__) -#define REG(cb) namespace { int UNIQUE_NAME(unique) = reg(cb); } - -// Predefined configuration keys -namespace cfg -{ -constexpr auto builddir = "builddir"; - -constexpr auto host_cc = "host-cc"; -constexpr auto host_cxx = "host-cpp"; -constexpr auto host_ar = "host-ar"; -constexpr auto host_ld = "host-ld"; - -constexpr auto build_cc = "build-cc"; -constexpr auto build_cxx = "build-cpp"; -constexpr auto build_ar = "build-ar"; -constexpr auto build_ld = "build-ld"; - -constexpr auto ctor_includedir = "ctor-includedir"; -constexpr auto ctor_libdir = "ctor-libdir"; -} - -struct Configuration -{ - std::vector args; // vector of arguments used when last calling configure - std::map env; // env used when last calling configure - - std::map tools; // tools - std::map externals; -}; - -const Configuration& configuration(); -bool hasConfiguration(const std::string& key); -const std::string& getConfiguration(const std::string& key, - const std::string& defaultValue = {}); diff --git a/src/rebuild.cc b/src/rebuild.cc index 9ddf5ba..7155984 100644 --- a/src/rebuild.cc +++ b/src/rebuild.cc @@ -10,7 +10,7 @@ #include #include "configure.h" -#include "libctor.h" +#include "ctor.h" #include "tasks.h" #include "build.h" #include "execute.h" diff --git a/src/rebuild.h b/src/rebuild.h index f1255c6..afa2307 100644 --- a/src/rebuild.h +++ b/src/rebuild.h @@ -6,7 +6,7 @@ #include #include -#include "libctor.h" +#include "ctor.h" class Settings; diff --git a/src/task.h b/src/task.h index be3995f..e192555 100644 --- a/src/task.h +++ b/src/task.h @@ -10,7 +10,7 @@ #include #include -#include "libctor.h" +#include "ctor.h" enum class State { diff --git a/src/task_ar.cc b/src/task_ar.cc index 3e1746c..1e6b278 100644 --- a/src/task_ar.cc +++ b/src/task_ar.cc @@ -6,7 +6,7 @@ #include #include -#include "libctor.h" +#include "ctor.h" #include "execute.h" #include "util.h" diff --git a/src/task_cc.cc b/src/task_cc.cc index c4343b6..d1b89ce 100644 --- a/src/task_cc.cc +++ b/src/task_cc.cc @@ -7,7 +7,7 @@ #include #include -#include "libctor.h" +#include "ctor.h" #include "execute.h" #include "util.h" #include "tools.h" diff --git a/src/task_fn.cc b/src/task_fn.cc index ab00fae..4ff692d 100644 --- a/src/task_fn.cc +++ b/src/task_fn.cc @@ -7,7 +7,7 @@ #include #include -#include "libctor.h" +#include "ctor.h" #include "execute.h" #include "util.h" diff --git a/src/task_ld.cc b/src/task_ld.cc index 20e823d..b5b762f 100644 --- a/src/task_ld.cc +++ b/src/task_ld.cc @@ -6,7 +6,7 @@ #include #include -#include "libctor.h" +#include "ctor.h" #include "execute.h" #include "util.h" #include "tools.h" diff --git a/src/task_so.cc b/src/task_so.cc index 8c6dbd4..4779321 100644 --- a/src/task_so.cc +++ b/src/task_so.cc @@ -6,7 +6,7 @@ #include #include -#include "libctor.h" +#include "ctor.h" #include "execute.h" #include "util.h" #include "tools.h" diff --git a/src/tasks.cc b/src/tasks.cc index 68b2476..12ff399 100644 --- a/src/tasks.cc +++ b/src/tasks.cc @@ -9,7 +9,7 @@ #include #include -#include "libctor.h" +#include "ctor.h" #include "task.h" #include "task_cc.h" #include "task_ld.h" diff --git a/src/tools.h b/src/tools.h index 39118d2..c346cbf 100644 --- a/src/tools.h +++ b/src/tools.h @@ -6,7 +6,7 @@ #include #include -#include "libctor.h" +#include "ctor.h" enum class ToolChain { diff --git a/src/util.h b/src/util.h index c8b591a..0cb01ce 100644 --- a/src/util.h +++ b/src/util.h @@ -3,7 +3,7 @@ // See accompanying file LICENSE for details. #pragma once -#include "libctor.h" +#include "ctor.h" #include #include diff --git a/test/ctor.cc b/test/ctor.cc index 9b690a2..e6d9734 100644 --- a/test/ctor.cc +++ b/test/ctor.cc @@ -1,7 +1,7 @@ // -*- c++ -*- // Distributed under the BSD 2-Clause License. // See accompanying file LICENSE for details. -#include +#include namespace { diff --git a/test/source_type_test.cc b/test/source_type_test.cc index ed7e783..ce1923e 100644 --- a/test/source_type_test.cc +++ b/test/source_type_test.cc @@ -1,6 +1,6 @@ #include -#include +#include #include std::ostream& operator<<(std::ostream& stream, const Language& lang) diff --git a/test/suite/ctor_files/ctor.cc.bar b/test/suite/ctor_files/ctor.cc.bar index 92456cb..d63b5e8 100644 --- a/test/suite/ctor_files/ctor.cc.bar +++ b/test/suite/ctor_files/ctor.cc.bar @@ -1,7 +1,7 @@ // -*- c++ -*- // Distributed under the BSD 2-Clause License. // See accompanying file LICENSE for details. -#include +#include //#include "config.h" namespace diff --git a/test/suite/ctor_files/ctor.cc.base b/test/suite/ctor_files/ctor.cc.base index 6c60513..3de099d 100644 --- a/test/suite/ctor_files/ctor.cc.base +++ b/test/suite/ctor_files/ctor.cc.base @@ -1,7 +1,7 @@ // -*- c++ -*- // Distributed under the BSD 2-Clause License. // See accompanying file LICENSE for details. -#include +#include //#include "config.h" namespace diff --git a/test/suite/ctor_files/ctor.cc.multi b/test/suite/ctor_files/ctor.cc.multi index 9db2517..d18d0d5 100644 --- a/test/suite/ctor_files/ctor.cc.multi +++ b/test/suite/ctor_files/ctor.cc.multi @@ -1,7 +1,7 @@ // -*- c++ -*- // Distributed under the BSD 2-Clause License. // See accompanying file LICENSE for details. -#include +#include //#include "config.h" #include "foobar.h" diff --git a/test/tasks_test.cc b/test/tasks_test.cc index 2e0ffc7..a660994 100644 --- a/test/tasks_test.cc +++ b/test/tasks_test.cc @@ -1,6 +1,6 @@ #include -#include +#include #include namespace -- cgit v1.2.3