Crafter.Graphics/examples/HelloUI/project.cpp

46 lines
1.4 KiB
C++
Raw Permalink Normal View History

2026-05-01 23:35:37 +02:00
import std;
import Crafter.Build;
namespace fs = std::filesystem;
using namespace Crafter;
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
2026-05-18 04:58:52 +02:00
bool isWasm = false;
for (std::string_view a : args) {
if (a.starts_with("--target=") && a.find("wasm") != std::string_view::npos) {
isWasm = true;
break;
}
}
2026-05-01 23:35:37 +02:00
Configuration* graphics = LocalProject({
.projectFile = "../../project.cpp",
2026-05-02 21:08:20 +02:00
.args = std::vector<std::string>(args.begin(), args.end()),
2026-05-01 23:35:37 +02:00
});
Configuration cfg;
cfg.path = "./";
2026-05-02 21:08:20 +02:00
cfg.name = "HelloUI";
cfg.outputName = "HelloUI";
2026-05-18 04:58:52 +02:00
cfg.type = ConfigurationType::Executable;
if (isWasm) {
cfg.target = "wasm32-wasip1";
cfg.defines.push_back({"CRAFTER_GRAPHICS_WINDOW_DOM", ""});
2026-05-18 05:39:17 +02:00
// 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");
2026-05-18 04:58:52 +02:00
}
2026-05-01 23:35:37 +02:00
ApplyStandardArgs(cfg, args);
cfg.dependencies = { graphics };
std::array<fs::path, 0> ifaces = {};
std::array<fs::path, 1> impls = { "main" };
cfg.GetInterfacesAndImplementations(ifaces, impls);
2026-05-02 21:08:20 +02:00
cfg.files.push_back("font.ttf");
2026-05-18 04:58:52 +02:00
if (isWasm) {
EnableWasiBrowserRuntime(cfg);
}
2026-05-01 23:35:37 +02:00
return cfg;
}