From f66ab53b9380a5367e24727df620d6620ab031f7 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 2 Feb 2026 20:10:41 +0100 Subject: Apply new syntax to flags --- src/configure.cc | 10 +++++----- src/ctor.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/configure.cc b/src/configure.cc index a8b50e0..1b8caa6 100644 --- a/src/configure.cc +++ b/src/configure.cc @@ -839,7 +839,7 @@ int regenerateCache(ctor::settings& settings, for(const auto& ext : externalConfigs) { - istr << " { \"" << esc(ext.name) << "\", {\n"; + istr << " { \"" << esc(ext.name) << "\", ctor::flags{\n"; ctor::flags resolved_flags; if(std::holds_alternative(ext.external)) { @@ -858,7 +858,7 @@ int regenerateCache(ctor::settings& settings, if(!resolved_flags.cflags.empty()) { - istr << " .cflags = {"; + istr << " ctor::c_flags{"; for(const auto& flag : resolved_flags.cflags) { istr << flag << ","; @@ -868,7 +868,7 @@ int regenerateCache(ctor::settings& settings, if(!resolved_flags.cxxflags.empty()) { - istr << " .cxxflags = {"; + istr << " ctor::cxx_flags{"; for(const auto& flag : resolved_flags.cxxflags) { istr << flag << ","; @@ -878,7 +878,7 @@ int regenerateCache(ctor::settings& settings, if(!resolved_flags.ldflags.empty()) { - istr << " .ldflags = {"; + istr << " ctor::ld_flags{"; for(const auto& flag : resolved_flags.ldflags) { istr << flag << ","; @@ -888,7 +888,7 @@ int regenerateCache(ctor::settings& settings, if(!resolved_flags.asmflags.empty()) { - istr << " .asmflags = {"; + istr << " ctor::asm_flags{"; for(const auto& flag : resolved_flags.asmflags) { istr << flag << ","; diff --git a/src/ctor.h b/src/ctor.h index aa46e5f..bac1e3a 100644 --- a/src/ctor.h +++ b/src/ctor.h @@ -269,6 +269,41 @@ using asm_flags = std::vector; struct flags { + template + requires (( + std::is_same_v || + std::is_same_v || + std::is_same_v || + std::is_same_v || + std::is_same_v + ) && ...) + constexpr flags(Args && ... arg) + { + ([&] + { + if constexpr(std::is_same_v) + { + cflags = arg; + } + else if constexpr(std::is_same_v) + { + cxxflags = arg; + } + else if constexpr(std::is_same_v) + { + ldflags = arg; + } + else if constexpr(std::is_same_v) + { + arflags = arg; + } + else if constexpr(std::is_same_v) + { + asmflags = arg; + } + }(), ...); + } + ctor::c_flags cflags; // flags for c compiler ctor::cxx_flags cxxflags; // flags for c++ compiler ctor::ld_flags ldflags; // flags for linker -- cgit v1.2.3