// -*- c++ -*- // Distributed under the BSD 2-Clause License. // See accompanying file LICENSE for details. #include #include #include #include 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"}}, }, ctor::GeneratorOneToOne{[](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::flags{ ctor::cxx_flags{ "-fexceptions", }, }, }, { ctor::target("many_to_one.cc"), ctor::sources{ {"hello.cc"}, }, ctor::GeneratorManyToOne{[](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); 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);