From 668158a83bc9e5af7bf65fe88d22d1958e33443f Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 6 Feb 2026 18:25:41 +0100 Subject: New syntax --- Jenkinsfile | 4 +- ctor.cc | 66 ++++--- src/configure.cc | 10 +- src/ctor.h | 202 ++++++++++++++++++- src/task_fn.cc | 27 ++- src/tasks.cc | 11 +- test/ctor.cc | 320 ++++++++++++++----------------- test/cycle_test.cc | 14 +- test/generated_sources_test.cc | 56 +++--- test/suite/ctor_files/ctor.cc.bar | 38 ++-- test/suite/ctor_files/ctor.cc.base | 38 ++-- test/suite/ctor_files/ctor.cc.generated | 73 ++++--- test/suite/ctor_files/ctor.cc.generated2 | 39 ++-- test/suite/ctor_files/ctor.cc.multi | 38 ++-- test/tasks_test.cc | 12 +- 15 files changed, 551 insertions(+), 397 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3e04aeb..d198a69 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,11 +32,11 @@ pipeline { echo 'Cleaning workspace ...' sh 'git clean -d -x -f' echo 'Building (gcc) ...' - sh 'CXXFLAGS="-Werror -Wno-maybe-uninitialized" CXX=g++ ./bootstrap.sh' + sh 'CXXFLAGS="-Werror" CXX=g++ ./bootstrap.sh' echo 'Testing (gcc) ...' sh './ctor check' echo 'Testing suite (gcc) ...' - sh '(cd test/suite; g++ -std=c++20 test.cc -o test && CTORDIR=../../build CXXFLAGS="-Werror -Wno-maybe-uninitialized" CXX=g++ ./test)' + sh '(cd test/suite; g++ -std=c++20 test.cc -o test && CTORDIR=../../build CXXFLAGS="-Werror" CXX=g++ ./test)' } post { always { diff --git a/ctor.cc b/ctor.cc index 3dd1b59..76488a5 100644 --- a/ctor.cc +++ b/ctor.cc @@ -10,41 +10,39 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings) return { { - .system = ctor::output_system::build, - .target = "libctor.a", - .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", - }, - .flags = { - .cxxflags = { - "-std=c++20", - "-O3", - "-g", - "-Wall", - "-Wextra", - "-Wshadow", - "-Wconversion", -// "-Wnrvo", - "-Isrc", - "-fexceptions", + 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", }, + ctor::cxx_flags{ + "-std=c++20", + "-O3", + "-g", + "-Wall", + "-Wextra", + "-Wshadow", + "-Wconversion", +// "-Wnrvo", + "-Isrc", + "-fexceptions", }, } }; 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 29c8f6d..890c257 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 @@ -297,8 +332,110 @@ 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; + +struct depends +{ + std::vector depends; +}; + +struct externals +{ + std::vector externals; +}; + struct build_configuration { + template + requires (( + 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_same_v || + std::is_convertible_v || + std::is_convertible_v || + std::is_same_v || + std::is_same_v || + std::is_same_v || + std::is_same_v || + std::is_same_v + ) && ...) + constexpr build_configuration(Args && ... arg) + { + ([&] + { + if constexpr(std::is_same_v) + { + name = arg.name; + } + else if constexpr(std::is_same_v) + { + type = arg; + } + else if constexpr(std::is_same_v) + { + system = arg; + } + else if constexpr(std::is_same_v) + { + target = arg.target; + } + else if constexpr(std::is_same_v) + { + sources = arg; + } + else if constexpr(std::is_same_v) + { + depends = arg.depends; + } + else if constexpr(std::is_same_v) + { + externals = arg.externals; + } + else if constexpr(std::is_convertible_v) + { + function_one_to_one = arg; + } + else if constexpr(std::is_convertible_v) + { + function_many_to_one = arg; + } + else if constexpr(std::is_same_v) + { + flags.cflags = arg; + } + else if constexpr(std::is_same_v) + { + flags.cxxflags = arg; + } + else if constexpr(std::is_same_v) + { + flags.ldflags = arg; + } + else if constexpr(std::is_same_v) + { + flags.arflags = arg; + } + else if constexpr(std::is_same_v) + { + flags.asmflags = 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 +444,8 @@ struct build_configuration std::vector depends; // internal target dependencies ctor::flags flags; std::vector externals; // externals used by this configuration - std::variant function; + ctor::GeneratorOneToOne function_one_to_one; + ctor::GeneratorManyToOne function_many_to_one; }; using build_configurations = std::vector; @@ -320,12 +456,72 @@ int reg(std::function cb, // This type will use flags verbatim struct external_manual { + template + requires (( + std::is_same_v || + std::is_same_v || + std::is_same_v || + std::is_same_v || + std::is_same_v + ) && ...) + constexpr external_manual(Args && ... arg) + { + ([&] + { + if constexpr(std::is_same_v) + { + flags.cflags = arg; + } + else if constexpr(std::is_same_v) + { + flags.cxxflags = arg; + } + else if constexpr(std::is_same_v) + { + flags.ldflags = arg; + } + else if constexpr(std::is_same_v) + { + flags.arflags = arg; + } + else if constexpr(std::is_same_v) + { + flags.asmflags = arg; + } + }(), ...); + } + ctor::flags flags; }; struct external_configuration { + template + requires (( + std::is_same_v || + std::is_same_v || + std::is_same_v + ) && ...) + constexpr external_configuration(Args && ... arg) + { + ([&] + { + if constexpr(std::is_same_v) + { + name = arg.name; + } + else if constexpr(std::is_same_v) + { + system = arg; + } + else if constexpr(std::is_same_v) + { + external = arg; + } + }(), ...); + } + std::string name; // Name for configuration ctor::output_system system{ctor::output_system::build}; std::variant external; diff --git a/src/task_fn.cc b/src/task_fn.cc index b712e70..4f27cc7 100644 --- a/src/task_fn.cc +++ b/src/task_fn.cc @@ -24,7 +24,7 @@ TaskFn::TaskFn(ctor::target_type resolved_target_type, sourceDir.parent_path()); source_language = source.language; - if(std::holds_alternative(config.function)) + if(config.function_one_to_one) { if(source.source_type == ctor::source_type::generated) { @@ -41,7 +41,7 @@ TaskFn::TaskFn(ctor::target_type resolved_target_type, } _targetFile = base / source.output; } - else if(std::holds_alternative(config.function)) + else if(config.function_many_to_one) { for(const auto& src : config.sources) { @@ -74,7 +74,7 @@ bool TaskFn::dirtyInner() return true; } - if(std::holds_alternative(config.function)) + if(config.function_many_to_one) { if(!std::filesystem::exists(sourceListFile)) { @@ -94,7 +94,7 @@ bool TaskFn::dirtyInner() std::filesystem::file_time_type last_changed{}; bool missing{false}; - if(std::holds_alternative(config.function)) + if(config.function_one_to_one) { if(!std::filesystem::exists(sourceFile)) { @@ -102,7 +102,7 @@ bool TaskFn::dirtyInner() } last_changed = std::filesystem::last_write_time(sourceFile); } - else if(std::holds_alternative(config.function)) + else if(config.function_many_to_one) { bool first{true}; for(const auto& source : sources) @@ -144,7 +144,7 @@ bool TaskFn::dirtyInner() int TaskFn::runInner() { - if(std::holds_alternative(config.function)) + if(config.function_many_to_one) { // Write sourceList to file. std::ofstream sourceListStream(sourceListFile.string()); @@ -160,20 +160,17 @@ int TaskFn::runInner() } int res{}; - if(std::holds_alternative(config.function)) + if(config.function_one_to_one) { - } - else if(std::holds_alternative(config.function)) - { - auto func = std::get(config.function); + auto func = config.function_one_to_one; res = func(sourceFile.string(), targetFile().string(), config, settings); } - else if(std::holds_alternative(config.function)) + else if(config.function_many_to_one) { - auto func = std::get(config.function); + auto func = config.function_many_to_one; res = func(sources, targetFile().string(), config, @@ -196,7 +193,7 @@ int TaskFn::clean() std::filesystem::remove(targetFile()); } - if(std::holds_alternative(config.function)) + if(config.function_many_to_one) { if(std::filesystem::exists(sourceListFile)) { @@ -211,7 +208,7 @@ int TaskFn::clean() std::vector TaskFn::depends() const { std::vector deps; - if(std::holds_alternative(config.function)) + if(config.function_many_to_one) { for(const auto& src : config.sources) { diff --git a/src/tasks.cc b/src/tasks.cc index f520772..5e1d235 100644 --- a/src/tasks.cc +++ b/src/tasks.cc @@ -85,7 +85,7 @@ std::vector> taskFactory(const ctor::build_configuration& ctor::target_type resolved_target_type{config.type}; if(resolved_target_type == ctor::target_type::automatic) { - if(!std::holds_alternative(config.function)) + if(config.function_one_to_one || config.function_many_to_one) { resolved_target_type = ctor::target_type::function; } @@ -103,8 +103,10 @@ std::vector> taskFactory(const ctor::build_configuration& for(const auto& source : config.sources) { if(source.toolchain == ctor::toolchain::any || - (config.system == ctor::output_system::build && source.toolchain == c.build_toolchain) || - (config.system == ctor::output_system::host && source.toolchain == c.host_toolchain)) + (config.system == ctor::output_system::build && + source.toolchain == c.build_toolchain) || + (config.system == ctor::output_system::host && + source.toolchain == c.host_toolchain)) { auto task = std::make_shared(ctor::target_type::object, config, settings, sourceDir, source); @@ -116,8 +118,7 @@ std::vector> taskFactory(const ctor::build_configuration& #ifndef BOOTSTRAP else { - bool multi{std::holds_alternative(config.function)}; - if(multi) + if(config.function_many_to_one) { auto task = std::make_shared(resolved_target_type, config, settings, sourceDir, ""); diff --git a/test/ctor.cc b/test/ctor.cc index e7ed038..afec91c 100644 --- a/test/ctor.cc +++ b/test/ctor.cc @@ -8,244 +8,220 @@ namespace ctor::build_configurations ctorTestConfigs(const ctor::settings& settings) { return - { { - .type = ctor::target_type::unit_test, - .system = ctor::output_system::build, - .target = "argparser_test", - .sources = { - "argparser_test.cc", - "testmain.cc", - }, - .flags = { - .cxxflags = { + { + ctor::target_type::unit_test, + ctor::output_system::build, + ctor::target("argparser_test"), + ctor::sources{ + "argparser_test.cc", + "testmain.cc", + }, + ctor::cxx_flags{ "-std=c++20", "-O3", "-Wall", "-I../src", "-Iuunit", "-DOUTPUT=\"argparser\"", "-fexceptions", }, }, - }, - { - .type = ctor::target_type::unit_test, - .system = ctor::output_system::build, - .target = "generated_sources_test", - .sources = { - "generated_sources_test.cc", - "testmain.cc", - }, - .depends = { "libctor_nomain.a" }, - .flags = { - .cxxflags = { + { + ctor::target_type::unit_test, + ctor::output_system::build, + ctor::target("generated_sources_test"), + ctor::sources{ + "generated_sources_test.cc", + "testmain.cc", + }, + ctor::depends({"libctor_nomain.a"}), + ctor::cxx_flags{ "-std=c++20", "-O3", "-Wall", "-I../src", "-Iuunit", "-DOUTPUT=\"generated_sources\"", "-fexceptions", }, }, - }, - { - .type = ctor::target_type::unit_test, - .system = ctor::output_system::build, - .target = "argsplit_test", - .sources = { - "argsplit_test.cc", - "testmain.cc", - "../src/util.cc", - }, - .flags = { - .cxxflags = { + { + ctor::target_type::unit_test, + ctor::output_system::build, + ctor::target("argsplit_test"), + ctor::sources{ + "argsplit_test.cc", + "testmain.cc", + "../src/util.cc", + }, + ctor::cxx_flags{ "-std=c++20", "-O3", "-Wall", "-I../src", "-Iuunit", "-DOUTPUT=\"argsplit\"", "-fexceptions", }, }, - }, - { - .type = ctor::target_type::unit_test, - .system = ctor::output_system::build, - .target = "pointerlist_test", - .sources = { - "pointerlist_test.cc", - "testmain.cc", - "../src/pointerlist.cc", - }, - .flags = { - .cxxflags = { + { + ctor::target_type::unit_test, + ctor::output_system::build, + ctor::target("pointerlist_test"), + ctor::sources{ + "pointerlist_test.cc", + "testmain.cc", + "../src/pointerlist.cc", + }, + ctor::cxx_flags{ "-std=c++20", "-O3", "-Wall", "-I../src", "-Iuunit", "-DOUTPUT=\"pointerlist\"", "-fexceptions", }, }, - }, - { - .type = ctor::target_type::unit_test, - .system = ctor::output_system::build, - .target = "deps_test", - .sources = { - "deps_test.cc", - "testmain.cc", - "../src/deps.cc", - "../src/util.cc", - }, - .depends = { "testprog", }, - .flags = { - .cxxflags = { + { + ctor::target_type::unit_test, + ctor::output_system::build, + ctor::target("deps_test"), + ctor::sources{ + "deps_test.cc", + "testmain.cc", + "../src/deps.cc", + "../src/util.cc", + }, + ctor::depends({"testprog"}), + ctor::cxx_flags{ "-std=c++20", "-O3", "-Wall", "-I../src", "-Iuunit", "-DOUTPUT=\"deps\"", "-fexceptions", }, }, - }, - { - .type = ctor::target_type::unit_test, - .system = ctor::output_system::build, - .target = "testprog", - .sources = { - "testprog.cc", - }, - .flags = { - .cxxflags = { + { + ctor::target_type::unit_test, + ctor::output_system::build, + ctor::target("testprog"), + ctor::sources{ + "testprog.cc", + }, + ctor::cxx_flags{ "-std=c++20", "-O3", "-Wall", "-fexceptions", }, }, - }, - { - .type = ctor::target_type::unit_test, - .system = ctor::output_system::build, - .target = "execute_test", - .sources = { - "execute_test.cc", - "testmain.cc", - "../src/execute.cc", - "../src/pointerlist.cc", - "../src/util.cc", - }, - .depends = { "testprog", }, - .flags = { - .cxxflags = { + { + ctor::target_type::unit_test, + ctor::output_system::build, + ctor::target("execute_test"), + ctor::sources{ + "execute_test.cc", + "testmain.cc", + "../src/execute.cc", + "../src/pointerlist.cc", + "../src/util.cc", + }, + ctor::depends({"testprog"}), + ctor::cxx_flags{ "-std=c++20", "-O3", "-Wall", "-I../src", "-Iuunit", "-DOUTPUT=\"execute\"", "-fexceptions", }, - .ldflags = { "-pthread" }, - }, - }, - { - .type = ctor::target_type::unit_test, - .system = ctor::output_system::build, - .target = "tasks_test", - .sources = { - "tasks_test.cc", - "testmain.cc", - }, - .depends = { "libctor_nomain.a" }, - .flags = { - .cxxflags = { + ctor::ld_flags{ "-pthread" }, + }, + { + ctor::target_type::unit_test, + ctor::output_system::build, + ctor::target("tasks_test"), + ctor::sources{ + "tasks_test.cc", + "testmain.cc", + }, + ctor::depends({"libctor_nomain.a"}), + ctor::cxx_flags{ "-std=c++20", "-O3", "-Wall", "-I../src", "-Iuunit", "-DOUTPUT=\"tasks\"", "-fexceptions", }, - .ldflags = { "-pthread" }, - }, - }, - { - .type = ctor::target_type::unit_test, - .system = ctor::output_system::build, - .target = "cycle_test", - .sources = { - "cycle_test.cc", - "testmain.cc", - }, - .depends = { "libctor_nomain.a" }, - .flags = { - .cxxflags = { + ctor::ld_flags{ "-pthread" }, + }, + { + ctor::target_type::unit_test, + ctor::output_system::build, + ctor::target("cycle_test"), + ctor::sources{ + "cycle_test.cc", + "testmain.cc", + }, + ctor::depends({"libctor_nomain.a"}), + ctor::cxx_flags{ "-std=c++20", "-O3", "-Wall", "-I../src", "-Iuunit", "-DOUTPUT=\"cycle\"", "-fexceptions", }, - .ldflags = { "-pthread" }, - }, - }, - { - .type = ctor::target_type::unit_test, - .system = ctor::output_system::build, - .target = "source_type_test", - .sources = { - "source_type_test.cc", - "testmain.cc", - }, - .depends = { "libctor_nomain.a" }, - .flags = { - .cxxflags = { + ctor::ld_flags{ "-pthread" }, + }, + { + ctor::target_type::unit_test, + ctor::output_system::build, + ctor::target("source_type_test"), + ctor::sources{ + "source_type_test.cc", + "testmain.cc", + }, + ctor::depends({"libctor_nomain.a"}), + ctor::cxx_flags{ "-std=c++20", "-O3", "-Wall", "-I../src", "-Iuunit", "-DOUTPUT=\"source_type\"", "-fexceptions", }, - .ldflags = { "-pthread" }, - }, - }, - { - .type = ctor::target_type::unit_test, - .system = ctor::output_system::build, - .target = "tools_test", - .sources = { - "tools_test.cc", - "testmain.cc", - "../src/util.cc", - "../src/tools.cc", - }, - //.depends = { "libctor_nomain.a" }, - .flags = { - .cxxflags = { + ctor::ld_flags{ "-pthread" }, + }, + { + ctor::target_type::unit_test, + ctor::output_system::build, + ctor::target("tools_test"), + ctor::sources{ + "tools_test.cc", + "testmain.cc", + "../src/util.cc", + "../src/tools.cc", + }, + ctor::depends({"libctor_nomain.a"}), + ctor::cxx_flags{ "-std=c++20", "-O3", "-Wall", "-I../src", "-Iuunit", "-DOUTPUT=\"tools\"", "-fexceptions", }, }, - }, - { - .type = ctor::target_type::unit_test_library, - .system = ctor::output_system::build, - .target = "libctor_nomain.a", - .sources = { - "../src/build.cc", - "../src/configure.cc", - "../src/deps.cc", - "../src/execute.cc", - "../src/pointerlist.cc", - "../src/rebuild.cc", - "../src/tasks.cc", - "../src/task.cc", - "../src/task_ar.cc", - "../src/task_cc.cc", - "../src/task_fn.cc", - "../src/task_ld.cc", - "../src/task_so.cc", - "../src/tools.cc", - "../src/util.cc", - "../src/externals_manual.cc", - "../configuration.cc", - }, - .flags = { - .cxxflags = { + { + ctor::target_type::unit_test_library, + ctor::output_system::build, + ctor::target("libctor_nomain.a"), + ctor::sources{ + "../src/build.cc", + "../src/configure.cc", + "../src/deps.cc", + "../src/execute.cc", + "../src/pointerlist.cc", + "../src/rebuild.cc", + "../src/tasks.cc", + "../src/task.cc", + "../src/task_ar.cc", + "../src/task_cc.cc", + "../src/task_fn.cc", + "../src/task_ld.cc", + "../src/task_so.cc", + "../src/tools.cc", + "../src/util.cc", + "../src/externals_manual.cc", + "../configuration.cc", + }, + ctor::cxx_flags{ "-std=c++20", "-O3", "-Wall", "-I../src", "-fexceptions", }, - .ldflags = { "-pthread" }, + ctor::ld_flags{ "-pthread" }, }, - }, - }; + }; } } diff --git a/test/cycle_test.cc b/test/cycle_test.cc index 3b45632..8f4c296 100644 --- a/test/cycle_test.cc +++ b/test/cycle_test.cc @@ -11,23 +11,23 @@ ctor::build_configurations ctorTestConfigsCyclic(const ctor::settings&) { // No dependency { - .target = "target0", + ctor::target("target0"), }, // Direct (self-depends) { - .target = "target1", - .depends = { "target1" }, + ctor::target("target1"), + ctor::depends({ "target1" }), }, // Indirect cyclic depends { - .target = "target2", - .depends = { "target3" }, + ctor::target("target2"), + ctor::depends({ "target3" }), }, { - .target = "target3", - .depends = { "target2" }, + ctor::target("target3"), + ctor::depends({ "target2" }), }, }; } diff --git a/test/generated_sources_test.cc b/test/generated_sources_test.cc index 8c46983..29a48fc 100644 --- a/test/generated_sources_test.cc +++ b/test/generated_sources_test.cc @@ -32,24 +32,24 @@ public: { return ctor::build_configurations{ { - .target = "test1", - .sources = { - {"foo.cc", ctor::source_type::generated} - } + ctor::target("test1"), + ctor::sources{ + {"foo.cc", ctor::source_type::generated} + }, }, { - .target = "this_is_unused", - .sources = { - {"bar.x", ctor::output_file{"foo.cc"}}, - {"bar.y", ctor::output_file{"bar.cc"}}, - }, - .function = []([[maybe_unused]]const std::string& input, - [[maybe_unused]]const std::string& output, - [[maybe_unused]]const ctor::build_configuration& config, - [[maybe_unused]]const ctor::settings& settings) + ctor::target("this_is_unused"), + ctor::sources{ + {"bar.x", ctor::output_file{"foo.cc"}}, + {"bar.y", ctor::output_file{"bar.cc"}}, + }, + []([[maybe_unused]]const std::string& input, + [[maybe_unused]]const std::string& output, + [[maybe_unused]]const ctor::build_configuration& config, + [[maybe_unused]]const ctor::settings& settings) { return 0; - } + }, }, }; }); @@ -85,24 +85,24 @@ public: { return ctor::build_configurations{ { - .target = "test1", - .sources = { - {"foo.cc", ctor::source_type::generated} - } + ctor::target("test1"), + ctor::sources{ + {"foo.cc", ctor::source_type::generated} + }, }, { - .target = "foo.cc", - .sources = { - {"bar.x"}, - {"bar.y"}, - }, - .function = [](const std::vector& input, - const std::string& output, - const ctor::build_configuration& config, - const ctor::settings& settings) + ctor::target("foo.cc"), + ctor::sources{ + "bar.x", + "bar.y", + }, + []([[maybe_unused]]const std::vector& input, + [[maybe_unused]]const std::string& output, + [[maybe_unused]]const ctor::build_configuration& config, + [[maybe_unused]]const ctor::settings& settings) { return 0; - } + }, }, }; }); diff --git a/test/suite/ctor_files/ctor.cc.bar b/test/suite/ctor_files/ctor.cc.bar index ab88379..d77eb70 100644 --- a/test/suite/ctor_files/ctor.cc.bar +++ b/test/suite/ctor_files/ctor.cc.bar @@ -11,22 +11,20 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings) return { { - .name = "hello", - .target = "hello", - .sources = { + ctor::name("hello"), + ctor::target("hello"), + ctor::sources{ "hello.cc", }, - .flags = { - .cxxflags = { - "-std=c++20", - "-O3", - "-g", - "-Wall", - "-Werror", - "-fexceptions", - }, + ctor::cxx_flags{ + "-std=c++20", + "-O3", + "-g", + "-Wall", + "-Werror", + "-fexceptions", }, - .externals = {"bar"}, + ctor::externals({"bar"}), } }; } @@ -36,14 +34,12 @@ ctor::external_configurations ctorExtConfigs(const ctor::settings& settings) return { { - .name = "bar", - .external = ctor::external_manual{ - .flags = { - .cflags = { "-D_B_" }, - .cxxflags = { "-D_A_", "-DBAR"}, - .ldflags = { "-D_C_" }, - .asmflags = { "-D_D_" }, - }, + ctor::name("bar"), + ctor::external_manual{ + ctor::c_flags{ "-D_B_" }, + ctor::cxx_flags{ "-D_A_", "-DBAR"}, + ctor::ld_flags{ "-D_C_" }, + ctor::asm_flags{ "-D_D_" }, }, // Creates --with-foo-prefix arg to configure which will be used for // -L and -I flags. diff --git a/test/suite/ctor_files/ctor.cc.base b/test/suite/ctor_files/ctor.cc.base index a8b3c92..73b5cdb 100644 --- a/test/suite/ctor_files/ctor.cc.base +++ b/test/suite/ctor_files/ctor.cc.base @@ -11,22 +11,20 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings) return { { - .name = "hello", - .target = "hello", - .sources = { + ctor::name("hello"), + ctor::target("hello"), + ctor::sources{ "hello.cc", }, - .flags = { - .cxxflags = { - "-std=c++20", - "-O3", - "-g", - "-Wall", - "-Werror", - "-fexceptions", - }, + ctor::cxx_flags{ + "-std=c++20", + "-O3", + "-g", + "-Wall", + "-Werror", + "-fexceptions", }, - .externals = {"bar"}, + ctor::externals({"bar"}), } }; } @@ -36,15 +34,13 @@ ctor::external_configurations ctorExtConfigs(const ctor::settings& settings) return { { - .name = "bar", - .external = ctor::external_manual + ctor::name("bar"), + ctor::external_manual { - .flags = { - .cflags = { "-D_B_" }, - .cxxflags = { "-D_A_", "-DFOO"}, - .ldflags = { "-D_C_" }, - .asmflags = { "-D_D_" }, - }, + ctor::c_flags{ "-D_B_" }, + ctor::cxx_flags{ "-D_A_", "-DFOO"}, + ctor::ld_flags{ "-D_C_" }, + ctor::asm_flags{ "-D_D_" }, }, // Creates --with-foo-prefix arg to configure which will be used for // -L and -I flags. diff --git a/test/suite/ctor_files/ctor.cc.generated b/test/suite/ctor_files/ctor.cc.generated index d4b9786..96b6fb5 100644 --- a/test/suite/ctor_files/ctor.cc.generated +++ b/test/suite/ctor_files/ctor.cc.generated @@ -13,72 +13,69 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings) return { { - .target = "world", - .sources = { + ctor::target("world"), + ctor::sources{ { "world.cc", ctor::source_type::generated }, }, - .flags = { - .cxxflags = { - "-std=c++20", - "-O3", - "-g", - "-Wall", - "-Werror", - "-fexceptions", - }, + ctor::cxx_flags{ + "-std=c++20", + "-O3", + "-g", + "-Wall", + "-Werror", + "-fexceptions", }, }, { - .target = "foo", - .sources = { + ctor::target("foo"), + ctor::sources{ { "foo.cc", ctor::source_type::generated }, }, - .flags = { - .cxxflags = { - "-std=c++20", - "-O3", - "-g", - "-Wall", - "-Werror", - "-fexceptions", - }, + ctor::cxx_flags{ + "-std=c++20", + "-O3", + "-g", + "-Wall", + "-Werror", + "-fexceptions", }, }, { - .target = "this_is_unused", - .sources = { + ctor::target("this_is_unused"), + ctor::sources{ {"hello.cc", ctor::output_file{"world.cc"}}, {"hello.cc", ctor::output_file{"foo.cc"}}, }, - .function = [](const std::string& input, - const std::string& output, - const ctor::build_configuration& config, - const ctor::settings& settings) + [](const std::string& input, + const std::string& output, + const ctor::build_configuration& config, + const ctor::settings& settings) { namespace fs = std::filesystem; std::cout << "Input: " << input << '\n'; std::cout << "Output: " << output << '\n'; fs::copy_file(input, output, fs::copy_options::overwrite_existing); return 0; - } + }, }, { - .target = "many_to_one", - .sources = { + ctor::target("many_to_one"), + ctor::sources{ {"many_to_one.cc", ctor::source_type::generated} - } + }, + ctor::cxx_flags{"-fexceptions"}, }, { - .target = "many_to_one.cc", - .sources = { + ctor::target("many_to_one.cc"), + ctor::sources{ {"foo.cc", ctor::source_type::generated}, {"hello.cc"}, }, - .function = [](const std::vector& input, - const std::string& output, - const ctor::build_configuration& config, - const ctor::settings& settings) + [](const std::vector& input, + const std::string& output, + const ctor::build_configuration& config, + const ctor::settings& settings) { std::cout << "Output: " << output << '\n'; std::ofstream ofs(output); diff --git a/test/suite/ctor_files/ctor.cc.generated2 b/test/suite/ctor_files/ctor.cc.generated2 index c78489f..2e36c0e 100644 --- a/test/suite/ctor_files/ctor.cc.generated2 +++ b/test/suite/ctor_files/ctor.cc.generated2 @@ -13,27 +13,27 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings) return { { - .target = "world", - .sources = { + ctor::target("world"), + ctor::sources{ { "world.cc", ctor::source_type::generated }, }, }, { - .target = "foo", - .sources = { + ctor::target("foo"), + ctor::sources{ { "foo.cc", ctor::source_type::generated }, }, }, { - .target = "this_is_unused", - .sources = { + ctor::target("this_is_unused"), + ctor::sources{ {"hello.cc", ctor::output_file{"world.cc"}}, {"hello.cc", ctor::output_file{"foo.cc"}}, }, - .function = [](const std::string& input, - const std::string& output, - const ctor::build_configuration& config, - const ctor::settings& settings) + [](const std::string& input, + const std::string& output, + const ctor::build_configuration& config, + const ctor::settings& settings) { namespace fs = std::filesystem; std::cout << "Input: " << input << '\n'; @@ -44,20 +44,21 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings) }, { - .target = "many_to_one", - .sources = { + ctor::target("many_to_one"), + ctor::sources{ {"many_to_one.cc", ctor::source_type::generated} - } + }, + ctor::cxx_flags{ "-fexceptions", }, }, { - .target = "many_to_one.cc", - .sources = { + ctor::target("many_to_one.cc"), + ctor::sources{ {"hello.cc"}, }, - .function = [](const std::vector& input, - const std::string& output, - const ctor::build_configuration& config, - const ctor::settings& settings) + [](const std::vector& input, + const std::string& output, + const ctor::build_configuration& config, + const ctor::settings& settings) { std::cout << "Output: " << output << '\n'; std::ofstream ofs(output); diff --git a/test/suite/ctor_files/ctor.cc.multi b/test/suite/ctor_files/ctor.cc.multi index 157d96c..fc4c7a4 100644 --- a/test/suite/ctor_files/ctor.cc.multi +++ b/test/suite/ctor_files/ctor.cc.multi @@ -13,22 +13,20 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings) return { { - .name = "hello", - .target = "hello", - .sources = { + ctor::name("hello"), + ctor::target("hello"), + ctor::sources{ "hello.cc", }, - .flags = { - .cxxflags = { - "-std=c++20", - "-O3", - "-g", - "-Wall", - "-Werror", - "-fexceptions", - }, + ctor::cxx_flags{ + "-std=c++20", + "-O3", + "-g", + "-Wall", + "-Werror", + "-fexceptions", }, - .externals = {"bar"}, + ctor::externals({"bar"}), } }; } @@ -38,14 +36,12 @@ ctor::external_configurations ctorExtConfigs(const ctor::settings& settings) return { { - .name = "bar", - .external = ctor::external_manual{ - .flags = { - .cflags = { "-D_B_" }, - .cxxflags = { "-D_A_", "-DFOO"}, - .ldflags = { "-D_C_" }, - .asmflags = { "-D_D_" }, - }, + ctor::name("bar"), + ctor::external_manual{ + ctor::c_flags{ "-D_B_" }, + ctor::cxx_flags{ "-D_A_", "-DFOO"}, + ctor::ld_flags{ "-D_C_" }, + ctor::asm_flags{ "-D_D_" }, }, // Creates --with-foo-prefix arg to configure which will be used for // -L and -I flags. diff --git a/test/tasks_test.cc b/test/tasks_test.cc index 1276347..32bed5a 100644 --- a/test/tasks_test.cc +++ b/test/tasks_test.cc @@ -10,12 +10,12 @@ ctor::build_configurations ctorTestConfigs1(const ctor::settings&) return { { - .name = "Target1", - .target = "target1", - .sources = {"foo.cc", "bar.c"}, + ctor::name("Target1"), + ctor::target("target1"), + ctor::sources({"foo.cc", "bar.c"}), }, { - .target = "target2", + ctor::target("target2"), }, }; } @@ -25,10 +25,10 @@ ctor::build_configurations ctorTestConfigs2(const ctor::settings&) return { { - .target = "target3", + ctor::target("target3"), }, { - .target = "target4", + ctor::target("target4"), }, }; } -- cgit v1.2.3