From 2855b6e1172d5b544b150bf617b216691801f574 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 22 Feb 2026 16:32:38 +0100 Subject: Make it possible to register header files along with the sources. --- ctor.cc | 60 +++++++++++++++++++++++++++++++++++++++++------------------- src/ctor.h | 33 +++++++++++++++++++++++++++++++++ test/ctor.cc | 4 ++++ 3 files changed, 78 insertions(+), 19 deletions(-) diff --git a/ctor.cc b/ctor.cc index 76488a5..e610801 100644 --- a/ctor.cc +++ b/ctor.cc @@ -13,25 +13,47 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings) ctor::output_system::build, ctor::target("libctor.a"), ctor::sources{ - "src/build.cc", - "src/configure.cc", - "src/deps.cc", - "src/execute.cc", - "src/externals_manual.cc", - "src/libctor.cc", - "src/pointerlist.cc", - "src/rebuild.cc", - "src/task.cc", - "src/task_ar.cc", - "src/task_fn.cc", - "src/task_cc.cc", - "src/task_ld.cc", - "src/task_so.cc", - "src/tasks.cc", - "src/tools.cc", - "src/util.cc", - "src/unittest.cc", - }, + "src/build.cc", + "src/configure.cc", + "src/deps.cc", + "src/execute.cc", + "src/externals_manual.cc", + "src/libctor.cc", + "src/pointerlist.cc", + "src/rebuild.cc", + "src/task.cc", + "src/task_ar.cc", + "src/task_fn.cc", + "src/task_cc.cc", + "src/task_ld.cc", + "src/task_so.cc", + "src/tasks.cc", + "src/tools.cc", + "src/util.cc", + "src/unittest.cc", + }, + ctor::headers{ + "src/argparser.h", + "src/build.h", + "src/configure.h", + "src/ctor.h", + "src/deps.h", + "src/execute.h", + "src/externals.h", + "src/externals_manual.h", + "src/pointerlist.h", + "src/rebuild.h", + "src/task.h", + "src/task_ar.h", + "src/task_cc.h", + "src/task_fn.h", + "src/task_ld.h", + "src/task_so.h", + "src/tasks.h", + "src/tools.h", + "src/unittest.h", + "src/util.h", + }, ctor::cxx_flags{ "-std=c++20", "-O3", diff --git a/src/ctor.h b/src/ctor.h index 182f97a..9320c3d 100644 --- a/src/ctor.h +++ b/src/ctor.h @@ -121,6 +121,33 @@ struct source using sources = std::vector; +struct header +{ + template + requires (( + std::is_convertible_v + ) && ...) + constexpr header(Args && ... arg) + { + ([&] + { + if constexpr(std::is_convertible_v) + { + file = arg; + } + else if constexpr(std::is_same_v) + { + install = arg; + } + }(), ...); + } + + std::string file; + ctor::install install; +}; + +using headers = std::vector; + enum class cxx_opt { // gcc/clang @@ -363,6 +390,7 @@ struct build_configuration std::is_same_v || std::is_same_v || std::is_same_v || + std::is_same_v || std::is_same_v || std::is_same_v || std::is_convertible_v || @@ -397,6 +425,10 @@ struct build_configuration { sources = arg; } + else if constexpr(std::is_same_v) + { + headers = arg; + } else if constexpr(std::is_same_v) { depends = arg.depends; @@ -441,6 +473,7 @@ struct build_configuration ctor::output_system system{ctor::output_system::build}; std::string target; // Output target file for this configuration ctor::sources sources; // source list + ctor::headers headers; // header list std::vector depends; // internal target dependencies ctor::flags flags; std::vector externals; // externals used by this configuration diff --git a/test/ctor.cc b/test/ctor.cc index d1c0188..6a86dc7 100644 --- a/test/ctor.cc +++ b/test/ctor.cc @@ -215,6 +215,10 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings) "../src/util.cc", "../src/externals_manual.cc", }, + ctor::headers{ + "paths.h", + "tmpfile.h", + }, ctor::cxx_flags{ "-std=c++20", "-O3", "-Wall", "-I../src", -- cgit v1.2.3