diff options
| author | Bent Bisballe Nyeng <deva@aasimon.org> | 2026-02-02 18:30:58 +0100 |
|---|---|---|
| committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2026-02-02 18:57:44 +0100 |
| commit | 6accb227b75fef7e99257b0078eb95f9aa0823cc (patch) | |
| tree | 41ed3773d1f8b05eea0e6ff86010237f6e4bd25a /src/ctor.h | |
| parent | 19d1dd34fbc87b6637147785332f180e36acdfef (diff) | |
New syntax
Diffstat (limited to 'src/ctor.h')
| -rw-r--r-- | src/ctor.h | 87 |
1 files changed, 84 insertions, 3 deletions
@@ -297,8 +297,90 @@ using GeneratorManyToOne = const ctor::build_configuration& config, const ctor::settings& settings)>; +struct name +{ + std::string name; +}; + +struct target +{ + std::string target; +}; + +using sources = std::vector<ctor::source>; + +struct depends +{ + std::vector<std::string> depends; +}; + +struct externals +{ + std::vector<std::string> externals; +}; + struct build_configuration { + template <class ... Args> + requires (( + std::is_same_v<Args, ctor::name> || + std::is_same_v<Args, ctor::target_type> || + 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::depends> || + std::is_same_v<Args, ctor::flags> || + std::is_same_v<Args, ctor::externals> || + std::is_same_v<Args, ctor::GeneratorOneToOne> || + std::is_same_v<Args, ctor::GeneratorManyToOne> + ) && ...) + constexpr build_configuration(Args && ... arg) + { + ([&] + { + if constexpr(std::is_same_v<Args, ctor::name>) + { + name = arg.name; + } + else if constexpr(std::is_same_v<Args, ctor::target_type>) + { + type = arg; + } + else if constexpr(std::is_same_v<Args, ctor::output_system>) + { + system = arg; + } + else if constexpr(std::is_same_v<Args, ctor::target>) + { + target = arg.target; + } + else if constexpr(std::is_same_v<Args, ctor::sources>) + { + sources = arg; + } + else if constexpr(std::is_same_v<Args, ctor::depends>) + { + depends = arg.depends; + } + else if constexpr(std::is_same_v<Args, ctor::flags>) + { + flags = arg; + } + else if constexpr(std::is_same_v<Args, ctor::externals>) + { + externals = arg.externals; + } + else if constexpr(std::is_same_v<Args, ctor::GeneratorOneToOne>) + { + function_one_to_one = arg; + } + else if constexpr(std::is_same_v<Args, ctor::GeneratorManyToOne>) + { + function_many_to_one = arg; + } + }(), ...); + } + std::string name; // Name - used for referring in other configurations. ctor::target_type type{ctor::target_type::automatic}; ctor::output_system system{ctor::output_system::build}; @@ -307,9 +389,8 @@ struct build_configuration std::vector<std::string> depends; // internal target dependencies ctor::flags flags; std::vector<std::string> externals; // externals used by this configuration - std::variant<std::monostate, - GeneratorOneToOne, - GeneratorManyToOne> function; + ctor::GeneratorOneToOne function_one_to_one; + ctor::GeneratorManyToOne function_many_to_one; }; using build_configurations = std::vector<build_configuration>; |
