import std; import Crafter.Build; namespace fs = std::filesystem; using namespace Crafter; extern "C" Configuration CrafterBuildProject(std::span args) { constexpr std::array networkInterfaces = { "interfaces/Crafter.Network", "interfaces/Crafter.Network-ClientTCP", "interfaces/Crafter.Network-ListenerTCP", "interfaces/Crafter.Network-ClientHTTP", "interfaces/Crafter.Network-ListenerHTTP", "interfaces/Crafter.Network-HTTP", }; constexpr std::array networkImplementations = { "implementations/Crafter.Network-ClientTCP", "implementations/Crafter.Network-ListenerTCP", "implementations/Crafter.Network-ClientHTTP", "implementations/Crafter.Network-ListenerHTTP", }; std::vector depArgs(args.begin(), args.end()); Configuration* thread = GitProject({ .source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Thread.git" }, .args = depArgs, }); Configuration cfg; cfg.path = "./"; cfg.name = "Crafter.Network"; cfg.outputName = "Crafter.Network"; cfg.type = ConfigurationType::LibraryStatic; ApplyStandardArgs(cfg, args); cfg.dependencies = { thread }; { std::array ifaces; std::ranges::copy(networkInterfaces, ifaces.begin()); std::array impls; std::ranges::copy(networkImplementations, impls.begin()); cfg.GetInterfacesAndImplementations(ifaces, impls); } auto addTest = [&](std::string name, fs::path implFile) { Test t; t.config.path = "./"; t.config.name = std::move(name); t.config.outputName = t.config.name; t.config.target = cfg.target; t.config.debug = cfg.debug; t.config.march = cfg.march; t.config.mtune = cfg.mtune; t.config.type = ConfigurationType::Executable; t.config.dependencies = { thread }; std::array ifaces; std::ranges::copy(networkInterfaces, ifaces.begin()); std::array impls; std::ranges::copy(networkImplementations, impls.begin()); impls[4] = std::move(implFile); t.config.GetInterfacesAndImplementations(ifaces, impls); cfg.tests.push_back(std::move(t)); }; addTest("ShouldCompile", "tests/ShouldCompile"); addTest("ShouldRecieveHTTP", "tests/ShouldRecieveHTTP"); addTest("ShouldSendHTTP", "tests/ShouldSendHTTP"); addTest("ShouldSendRecieveHTTP", "tests/ShouldSendRecieveHTTP"); addTest("ShouldSendRecieveKeepaliveHTTP", "tests/ShouldSendRecieveKeepaliveHTTP"); addTest("ShouldSendRecieveLargeHTTP", "tests/ShouldSendRecieveLargeHTTP"); return cfg; }