diff options
Diffstat (limited to 'test/suite/ctor_files')
| -rw-r--r-- | test/suite/ctor_files/ctor.cc.bar | 37 | ||||
| -rw-r--r-- | test/suite/ctor_files/ctor.cc.base | 37 | ||||
| -rw-r--r-- | test/suite/ctor_files/ctor.cc.generated | 104 | ||||
| -rw-r--r-- | test/suite/ctor_files/ctor.cc.generated2 | 87 | ||||
| -rw-r--r-- | test/suite/ctor_files/ctor.cc.multi | 37 |
5 files changed, 242 insertions, 60 deletions
diff --git a/test/suite/ctor_files/ctor.cc.bar b/test/suite/ctor_files/ctor.cc.bar index 218f9cc..d77eb70 100644 --- a/test/suite/ctor_files/ctor.cc.bar +++ b/test/suite/ctor_files/ctor.cc.bar @@ -11,21 +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", - }, + ctor::cxx_flags{ + "-std=c++20", + "-O3", + "-g", + "-Wall", + "-Werror", + "-fexceptions", }, - .externals = {"bar"}, + ctor::externals({"bar"}), } }; } @@ -35,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 eab39c4..73b5cdb 100644 --- a/test/suite/ctor_files/ctor.cc.base +++ b/test/suite/ctor_files/ctor.cc.base @@ -11,21 +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", - }, + ctor::cxx_flags{ + "-std=c++20", + "-O3", + "-g", + "-Wall", + "-Werror", + "-fexceptions", }, - .externals = {"bar"}, + ctor::externals({"bar"}), } }; } @@ -35,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 new file mode 100644 index 0000000..96b6fb5 --- /dev/null +++ b/test/suite/ctor_files/ctor.cc.generated @@ -0,0 +1,104 @@ +// -*- c++ -*- +// Distributed under the BSD 2-Clause License. +// See accompanying file LICENSE for details. +#include <ctor.h> +#include <filesystem> +#include <iostream> +#include <fstream> + +namespace +{ +ctor::build_configurations ctorConfigs(const ctor::settings& settings) +{ + return + { + { + ctor::target("world"), + ctor::sources{ + { "world.cc", ctor::source_type::generated }, + }, + ctor::cxx_flags{ + "-std=c++20", + "-O3", + "-g", + "-Wall", + "-Werror", + "-fexceptions", + }, + }, + { + ctor::target("foo"), + ctor::sources{ + { "foo.cc", ctor::source_type::generated }, + }, + ctor::cxx_flags{ + "-std=c++20", + "-O3", + "-g", + "-Wall", + "-Werror", + "-fexceptions", + }, + }, + { + ctor::target("this_is_unused"), + ctor::sources{ + {"hello.cc", ctor::output_file{"world.cc"}}, + {"hello.cc", ctor::output_file{"foo.cc"}}, + }, + [](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{ + {"foo.cc", ctor::source_type::generated}, + {"hello.cc"}, + }, + [](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); + bool comment{true}; + for(const auto& input_file : input) + { + std::cout << "Input: " << input_file << '\n'; + std::ifstream ifs(input_file); + std::string line; + while(std::getline(ifs, line)) + { + ofs << line << '\n'; + } + if(comment) ofs << "/*\n"; + comment = false; + } + ofs << "*/\n"; + return 0; + } + }, + + }; +} +} + +REG(ctorConfigs); diff --git a/test/suite/ctor_files/ctor.cc.generated2 b/test/suite/ctor_files/ctor.cc.generated2 new file mode 100644 index 0000000..2e36c0e --- /dev/null +++ b/test/suite/ctor_files/ctor.cc.generated2 @@ -0,0 +1,87 @@ +// -*- c++ -*- +// Distributed under the BSD 2-Clause License. +// See accompanying file LICENSE for details. +#include <ctor.h> +#include <filesystem> +#include <iostream> +#include <fstream> + +namespace +{ +ctor::build_configurations ctorConfigs(const ctor::settings& settings) +{ + return + { + { + ctor::target("world"), + ctor::sources{ + { "world.cc", ctor::source_type::generated }, + }, + }, + { + ctor::target("foo"), + ctor::sources{ + { "foo.cc", ctor::source_type::generated }, + }, + }, + { + ctor::target("this_is_unused"), + ctor::sources{ + {"hello.cc", ctor::output_file{"world.cc"}}, + {"hello.cc", ctor::output_file{"foo.cc"}}, + }, + [](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"}, + }, + [](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); + bool comment{true}; + for(const auto& input_file : input) + { + std::cout << "Input: " << input_file << '\n'; + std::ifstream ifs(input_file); + std::string line; + while(std::getline(ifs, line)) + { + ofs << line << '\n'; + } + if(comment) ofs << "/*\n"; + comment = false; + } + ofs << "*/\n"; + return 0; + } + }, + + }; +} +} + +REG(ctorConfigs); diff --git a/test/suite/ctor_files/ctor.cc.multi b/test/suite/ctor_files/ctor.cc.multi index 2b88afe..fc4c7a4 100644 --- a/test/suite/ctor_files/ctor.cc.multi +++ b/test/suite/ctor_files/ctor.cc.multi @@ -13,21 +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", - }, + ctor::cxx_flags{ + "-std=c++20", + "-O3", + "-g", + "-Wall", + "-Werror", + "-fexceptions", }, - .externals = {"bar"}, + ctor::externals({"bar"}), } }; } @@ -37,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. |
