summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ctor.cc24
-rw-r--r--src/ctor.h38
-rw-r--r--test/ctor.cc148
-rw-r--r--test/generated_sources_test.cc18
-rw-r--r--test/suite/ctor_files/ctor.cc.bar16
-rw-r--r--test/suite/ctor_files/ctor.cc.base16
-rw-r--r--test/suite/ctor_files/ctor.cc.generated55
-rw-r--r--test/suite/ctor_files/ctor.cc.generated223
-rw-r--r--test/suite/ctor_files/ctor.cc.multi16
9 files changed, 170 insertions, 184 deletions
diff --git a/ctor.cc b/ctor.cc
index 9a82cf5..76488a5 100644
--- a/ctor.cc
+++ b/ctor.cc
@@ -32,19 +32,17 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
"src/util.cc",
"src/unittest.cc",
},
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20",
- "-O3",
- "-g",
- "-Wall",
- "-Wextra",
- "-Wshadow",
- "-Wconversion",
-// "-Wnrvo",
- "-Isrc",
- "-fexceptions",
- },
+ ctor::cxx_flags{
+ "-std=c++20",
+ "-O3",
+ "-g",
+ "-Wall",
+ "-Wextra",
+ "-Wshadow",
+ "-Wconversion",
+// "-Wnrvo",
+ "-Isrc",
+ "-fexceptions",
},
}
};
diff --git a/src/ctor.h b/src/ctor.h
index bac1e3a..96cc24b 100644
--- a/src/ctor.h
+++ b/src/ctor.h
@@ -364,10 +364,14 @@ struct build_configuration
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>
+ std::is_convertible_v<Args, ctor::GeneratorOneToOne> ||
+ std::is_convertible_v<Args, ctor::GeneratorManyToOne> ||
+ std::is_same_v<Args, ctor::c_flags> ||
+ std::is_same_v<Args, ctor::cxx_flags> ||
+ std::is_same_v<Args, ctor::ld_flags> ||
+ std::is_same_v<Args, ctor::ar_flags> ||
+ std::is_same_v<Args, ctor::asm_flags>
) && ...)
constexpr build_configuration(Args && ... arg)
{
@@ -397,22 +401,38 @@ struct build_configuration
{
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>)
+ else if constexpr(std::is_convertible_v<Args, ctor::GeneratorOneToOne>)
{
function_one_to_one = arg;
}
- else if constexpr(std::is_same_v<Args, ctor::GeneratorManyToOne>)
+ else if constexpr(std::is_convertible_v<Args, ctor::GeneratorManyToOne>)
{
function_many_to_one = arg;
}
+ else if constexpr(std::is_same_v<Args, ctor::c_flags>)
+ {
+ flags.cflags = arg;
+ }
+ else if constexpr(std::is_same_v<Args, ctor::cxx_flags>)
+ {
+ flags.cxxflags = arg;
+ }
+ else if constexpr(std::is_same_v<Args, ctor::ld_flags>)
+ {
+ flags.ldflags = arg;
+ }
+ else if constexpr(std::is_same_v<Args, ctor::ar_flags>)
+ {
+ flags.arflags = arg;
+ }
+ else if constexpr(std::is_same_v<Args, ctor::asm_flags>)
+ {
+ flags.asmflags = arg;
+ }
}(), ...);
}
diff --git a/test/ctor.cc b/test/ctor.cc
index 440ddfe..afec91c 100644
--- a/test/ctor.cc
+++ b/test/ctor.cc
@@ -17,13 +17,11 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
"argparser_test.cc",
"testmain.cc",
},
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20", "-O3", "-Wall",
- "-I../src", "-Iuunit",
- "-DOUTPUT=\"argparser\"",
- "-fexceptions",
- },
+ ctor::cxx_flags{
+ "-std=c++20", "-O3", "-Wall",
+ "-I../src", "-Iuunit",
+ "-DOUTPUT=\"argparser\"",
+ "-fexceptions",
},
},
{
@@ -35,13 +33,11 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
"testmain.cc",
},
ctor::depends({"libctor_nomain.a"}),
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20", "-O3", "-Wall",
- "-I../src", "-Iuunit",
- "-DOUTPUT=\"generated_sources\"",
- "-fexceptions",
- },
+ ctor::cxx_flags{
+ "-std=c++20", "-O3", "-Wall",
+ "-I../src", "-Iuunit",
+ "-DOUTPUT=\"generated_sources\"",
+ "-fexceptions",
},
},
{
@@ -53,13 +49,11 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
"testmain.cc",
"../src/util.cc",
},
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20", "-O3", "-Wall",
- "-I../src", "-Iuunit",
- "-DOUTPUT=\"argsplit\"",
- "-fexceptions",
- },
+ ctor::cxx_flags{
+ "-std=c++20", "-O3", "-Wall",
+ "-I../src", "-Iuunit",
+ "-DOUTPUT=\"argsplit\"",
+ "-fexceptions",
},
},
{
@@ -71,13 +65,11 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
"testmain.cc",
"../src/pointerlist.cc",
},
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20", "-O3", "-Wall",
- "-I../src", "-Iuunit",
- "-DOUTPUT=\"pointerlist\"",
- "-fexceptions",
- },
+ ctor::cxx_flags{
+ "-std=c++20", "-O3", "-Wall",
+ "-I../src", "-Iuunit",
+ "-DOUTPUT=\"pointerlist\"",
+ "-fexceptions",
},
},
{
@@ -91,13 +83,11 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
"../src/util.cc",
},
ctor::depends({"testprog"}),
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20", "-O3", "-Wall",
- "-I../src", "-Iuunit",
- "-DOUTPUT=\"deps\"",
- "-fexceptions",
- },
+ ctor::cxx_flags{
+ "-std=c++20", "-O3", "-Wall",
+ "-I../src", "-Iuunit",
+ "-DOUTPUT=\"deps\"",
+ "-fexceptions",
},
},
{
@@ -107,11 +97,9 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
ctor::sources{
"testprog.cc",
},
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20", "-O3", "-Wall",
- "-fexceptions",
- },
+ ctor::cxx_flags{
+ "-std=c++20", "-O3", "-Wall",
+ "-fexceptions",
},
},
{
@@ -126,15 +114,13 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
"../src/util.cc",
},
ctor::depends({"testprog"}),
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20", "-O3", "-Wall",
- "-I../src", "-Iuunit",
- "-DOUTPUT=\"execute\"",
- "-fexceptions",
- },
- ctor::ld_flags{ "-pthread" },
+ ctor::cxx_flags{
+ "-std=c++20", "-O3", "-Wall",
+ "-I../src", "-Iuunit",
+ "-DOUTPUT=\"execute\"",
+ "-fexceptions",
},
+ ctor::ld_flags{ "-pthread" },
},
{
ctor::target_type::unit_test,
@@ -145,15 +131,13 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
"testmain.cc",
},
ctor::depends({"libctor_nomain.a"}),
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20", "-O3", "-Wall",
- "-I../src", "-Iuunit",
- "-DOUTPUT=\"tasks\"",
- "-fexceptions",
- },
- ctor::ld_flags{ "-pthread" },
+ ctor::cxx_flags{
+ "-std=c++20", "-O3", "-Wall",
+ "-I../src", "-Iuunit",
+ "-DOUTPUT=\"tasks\"",
+ "-fexceptions",
},
+ ctor::ld_flags{ "-pthread" },
},
{
ctor::target_type::unit_test,
@@ -164,15 +148,13 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
"testmain.cc",
},
ctor::depends({"libctor_nomain.a"}),
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20", "-O3", "-Wall",
- "-I../src", "-Iuunit",
- "-DOUTPUT=\"cycle\"",
- "-fexceptions",
- },
- ctor::ld_flags{ "-pthread" },
+ ctor::cxx_flags{
+ "-std=c++20", "-O3", "-Wall",
+ "-I../src", "-Iuunit",
+ "-DOUTPUT=\"cycle\"",
+ "-fexceptions",
},
+ ctor::ld_flags{ "-pthread" },
},
{
ctor::target_type::unit_test,
@@ -183,15 +165,13 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
"testmain.cc",
},
ctor::depends({"libctor_nomain.a"}),
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20", "-O3", "-Wall",
- "-I../src", "-Iuunit",
- "-DOUTPUT=\"source_type\"",
- "-fexceptions",
- },
- ctor::ld_flags{ "-pthread" },
+ ctor::cxx_flags{
+ "-std=c++20", "-O3", "-Wall",
+ "-I../src", "-Iuunit",
+ "-DOUTPUT=\"source_type\"",
+ "-fexceptions",
},
+ ctor::ld_flags{ "-pthread" },
},
{
ctor::target_type::unit_test,
@@ -204,13 +184,11 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
"../src/tools.cc",
},
ctor::depends({"libctor_nomain.a"}),
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20", "-O3", "-Wall",
- "-I../src", "-Iuunit",
- "-DOUTPUT=\"tools\"",
- "-fexceptions",
- },
+ ctor::cxx_flags{
+ "-std=c++20", "-O3", "-Wall",
+ "-I../src", "-Iuunit",
+ "-DOUTPUT=\"tools\"",
+ "-fexceptions",
},
},
{
@@ -236,14 +214,12 @@ ctor::build_configurations ctorTestConfigs(const ctor::settings& settings)
"../src/externals_manual.cc",
"../configuration.cc",
},
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20", "-O3", "-Wall",
- "-I../src",
- "-fexceptions",
- },
- ctor::ld_flags{ "-pthread" },
+ ctor::cxx_flags{
+ "-std=c++20", "-O3", "-Wall",
+ "-I../src",
+ "-fexceptions",
},
+ ctor::ld_flags{ "-pthread" },
},
};
}
diff --git a/test/generated_sources_test.cc b/test/generated_sources_test.cc
index 626a102..29a48fc 100644
--- a/test/generated_sources_test.cc
+++ b/test/generated_sources_test.cc
@@ -43,13 +43,13 @@ public:
{"bar.x", ctor::output_file{"foo.cc"}},
{"bar.y", ctor::output_file{"bar.cc"}},
},
- ctor::GeneratorOneToOne([]([[maybe_unused]]const std::string& input,
+ []([[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;
- }),
+ },
},
};
});
@@ -93,16 +93,16 @@ public:
{
ctor::target("foo.cc"),
ctor::sources{
- {"bar.x"},
- {"bar.y"},
+ "bar.x",
+ "bar.y",
},
- ctor::GeneratorManyToOne([](const std::vector<std::string>& input,
- const std::string& output,
- const ctor::build_configuration& config,
- const ctor::settings& settings)
+ []([[maybe_unused]]const std::vector<std::string>& 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 2342c3a..f73f400 100644
--- a/test/suite/ctor_files/ctor.cc.bar
+++ b/test/suite/ctor_files/ctor.cc.bar
@@ -16,15 +16,13 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
ctor::sources{
"hello.cc",
},
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20",
- "-O3",
- "-g",
- "-Wall",
- "-Werror",
- "-fexceptions",
- },
+ ctor::cxx_flags{
+ "-std=c++20",
+ "-O3",
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-fexceptions",
},
ctor::externals({"bar"}),
}
diff --git a/test/suite/ctor_files/ctor.cc.base b/test/suite/ctor_files/ctor.cc.base
index 3734415..cc06e85 100644
--- a/test/suite/ctor_files/ctor.cc.base
+++ b/test/suite/ctor_files/ctor.cc.base
@@ -16,15 +16,13 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
ctor::sources{
"hello.cc",
},
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20",
- "-O3",
- "-g",
- "-Wall",
- "-Werror",
- "-fexceptions",
- },
+ ctor::cxx_flags{
+ "-std=c++20",
+ "-O3",
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-fexceptions",
},
ctor::externals({"bar"}),
}
diff --git a/test/suite/ctor_files/ctor.cc.generated b/test/suite/ctor_files/ctor.cc.generated
index fe7e173..96b6fb5 100644
--- a/test/suite/ctor_files/ctor.cc.generated
+++ b/test/suite/ctor_files/ctor.cc.generated
@@ -17,15 +17,13 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
ctor::sources{
{ "world.cc", ctor::source_type::generated },
},
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20",
- "-O3",
- "-g",
- "-Wall",
- "-Werror",
- "-fexceptions",
- },
+ ctor::cxx_flags{
+ "-std=c++20",
+ "-O3",
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-fexceptions",
},
},
{
@@ -33,15 +31,13 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
ctor::sources{
{ "foo.cc", ctor::source_type::generated },
},
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20",
- "-O3",
- "-g",
- "-Wall",
- "-Werror",
- "-fexceptions",
- },
+ ctor::cxx_flags{
+ "-std=c++20",
+ "-O3",
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-fexceptions",
},
},
{
@@ -50,24 +46,25 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
{"hello.cc", ctor::output_file{"world.cc"}},
{"hello.cc", ctor::output_file{"foo.cc"}},
},
- ctor::GeneratorOneToOne{[](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;
- }}
+ },
},
{
ctor::target("many_to_one"),
ctor::sources{
{"many_to_one.cc", ctor::source_type::generated}
- }
+ },
+ ctor::cxx_flags{"-fexceptions"},
},
{
ctor::target("many_to_one.cc"),
@@ -75,10 +72,10 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
{"foo.cc", ctor::source_type::generated},
{"hello.cc"},
},
- ctor::GeneratorManyToOne{[](const std::vector<std::string>& input,
- const std::string& output,
- const ctor::build_configuration& config,
- const ctor::settings& settings)
+ [](const std::vector<std::string>& input,
+ const std::string& output,
+ const ctor::build_configuration& config,
+ const ctor::settings& settings)
{
std::cout << "Output: " << output << '\n';
std::ofstream ofs(output);
@@ -97,7 +94,7 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
}
ofs << "*/\n";
return 0;
- }}
+ }
},
};
diff --git a/test/suite/ctor_files/ctor.cc.generated2 b/test/suite/ctor_files/ctor.cc.generated2
index acda99f..2e36c0e 100644
--- a/test/suite/ctor_files/ctor.cc.generated2
+++ b/test/suite/ctor_files/ctor.cc.generated2
@@ -30,34 +30,35 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
{"hello.cc", ctor::output_file{"world.cc"}},
{"hello.cc", ctor::output_file{"foo.cc"}},
},
- ctor::GeneratorOneToOne{[](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;
- }}
+ }
},
{
ctor::target("many_to_one"),
ctor::sources{
{"many_to_one.cc", ctor::source_type::generated}
- }
+ },
+ ctor::cxx_flags{ "-fexceptions", },
},
{
ctor::target("many_to_one.cc"),
ctor::sources{
{"hello.cc"},
},
- ctor::GeneratorManyToOne{[](const std::vector<std::string>& input,
- const std::string& output,
- const ctor::build_configuration& config,
- const ctor::settings& settings)
+ [](const std::vector<std::string>& input,
+ const std::string& output,
+ const ctor::build_configuration& config,
+ const ctor::settings& settings)
{
std::cout << "Output: " << output << '\n';
std::ofstream ofs(output);
@@ -76,7 +77,7 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
}
ofs << "*/\n";
return 0;
- }}
+ }
},
};
diff --git a/test/suite/ctor_files/ctor.cc.multi b/test/suite/ctor_files/ctor.cc.multi
index cf86703..e45ad45 100644
--- a/test/suite/ctor_files/ctor.cc.multi
+++ b/test/suite/ctor_files/ctor.cc.multi
@@ -18,15 +18,13 @@ ctor::build_configurations ctorConfigs(const ctor::settings& settings)
ctor::sources{
"hello.cc",
},
- ctor::flags{
- ctor::cxx_flags{
- "-std=c++20",
- "-O3",
- "-g",
- "-Wall",
- "-Werror",
- "-fexceptions",
- },
+ ctor::cxx_flags{
+ "-std=c++20",
+ "-O3",
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-fexceptions",
},
ctor::externals({"bar"}),
}