summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2026-02-22 16:32:38 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2026-02-22 17:39:06 +0100
commit2855b6e1172d5b544b150bf617b216691801f574 (patch)
tree620e64d83a8ea4e18f0990766f2c8592127cd452
parentdb6c4499ecc23212838f45fc9fa8c0a703d8b85f (diff)
Make it possible to register header files along with the sources.
-rw-r--r--ctor.cc60
-rw-r--r--src/ctor.h33
-rw-r--r--test/ctor.cc4
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<ctor::source>;
+struct header
+{
+ template <class ... Args>
+ requires ((
+ std::is_convertible_v<Args, std::string_view>
+ ) && ...)
+ constexpr header(Args && ... arg)
+ {
+ ([&]
+ {
+ if constexpr(std::is_convertible_v<Args, std::string_view>)
+ {
+ file = arg;
+ }
+ else if constexpr(std::is_same_v<Args, ctor::install>)
+ {
+ install = arg;
+ }
+ }(), ...);
+ }
+
+ std::string file;
+ ctor::install install;
+};
+
+using headers = std::vector<ctor::header>;
+
enum class cxx_opt
{
// gcc/clang
@@ -363,6 +390,7 @@ struct build_configuration
std::is_same_v<Args, ctor::output_system> ||
std::is_same_v<Args, ctor::target> ||
std::is_same_v<Args, ctor::sources> ||
+ std::is_same_v<Args, ctor::headers> ||
std::is_same_v<Args, ctor::depends> ||
std::is_same_v<Args, ctor::externals> ||
std::is_convertible_v<Args, ctor::GeneratorOneToOne> ||
@@ -397,6 +425,10 @@ struct build_configuration
{
sources = arg;
}
+ else if constexpr(std::is_same_v<Args, ctor::headers>)
+ {
+ headers = arg;
+ }
else if constexpr(std::is_same_v<Args, ctor::depends>)
{
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<std::string> depends; // internal target dependencies
ctor::flags flags;
std::vector<std::string> 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",