import std; import Crafter.Build; namespace fs = std::filesystem; using namespace Crafter; extern "C" Configuration CrafterBuildProject(std::span args) { bool isWasm = false; for (std::string_view a : args) { if (a.starts_with("--target=") && a.find("wasm") != std::string_view::npos) { isWasm = true; break; } } Configuration* graphics = LocalProject({ .projectFile = "../../project.cpp", .args = std::vector(args.begin(), args.end()), }); Configuration cfg; cfg.path = "./"; cfg.name = "HelloUI"; cfg.outputName = "HelloUI"; cfg.type = ConfigurationType::Executable; if (isWasm) { cfg.target = "wasm32-wasip1"; cfg.defines.push_back({"CRAFTER_GRAPHICS_WINDOW_DOM", ""}); // Match the -msimd128 that Crafter.Math/Crafter.Graphics's wasm // PCMs were compiled with, otherwise PCM imports trip a config- // mismatch error in recent clangs. cfg.compileFlags.push_back("-msimd128"); } ApplyStandardArgs(cfg, args); cfg.dependencies = { graphics }; std::array ifaces = {}; std::array impls = { "main" }; cfg.GetInterfacesAndImplementations(ifaces, impls); cfg.files.push_back("font.ttf"); if (isWasm) { EnableWasiBrowserRuntime(cfg); } return cfg; }