Migrate to crafter-build project.cpp and restructure views
- Replace project.json + run.sh with a C++ project.cpp build descriptor (crafter-build), targeting wasm32-wasip1 with the Crafter.Graphics dep - Add Catcrafts-Views implementation; drop Catcrafts-Component - Add catcrafts-head.js (sets <title>/<link> tags at runtime) - Update Blog/Root/main modules, README, and favicon Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d87c408712
commit
13a12c2a2c
15 changed files with 227 additions and 126 deletions
75
project.cpp
Normal file
75
project.cpp
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
catcrafts.net
|
||||
Copyright (C) 2026 Catcrafts
|
||||
|
||||
The source code of this website is made available for viewing purposes only.
|
||||
No permission is granted to copy, modify, distribute, or create derivative works.
|
||||
*/
|
||||
|
||||
import std;
|
||||
import Crafter.Build;
|
||||
namespace fs = std::filesystem;
|
||||
using namespace Crafter;
|
||||
|
||||
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
||||
std::vector<std::string> depArgs(args.begin(), args.end());
|
||||
depArgs.push_back("--target=wasm32-wasip1");
|
||||
|
||||
// --local resolves the Crafter.Graphics dep from a sibling working tree
|
||||
// instead of fetching it from forgejo. Mirrors Crafter.Graphics's own
|
||||
// project.cpp convention so edits across the two repos pick up without
|
||||
// commit-and-pull.
|
||||
bool useLocal = false;
|
||||
for (std::string_view a : args) {
|
||||
if (a == "--local") { useLocal = true; break; }
|
||||
}
|
||||
if (useLocal && std::find(depArgs.begin(), depArgs.end(), std::string("--local")) == depArgs.end()) {
|
||||
depArgs.push_back("--local");
|
||||
}
|
||||
|
||||
Configuration* graphics = useLocal
|
||||
? LocalProject({
|
||||
.projectFile = "../Crafter/Crafter.Graphics/project.cpp",
|
||||
.args = depArgs,
|
||||
})
|
||||
: GitProject({
|
||||
.source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Graphics.git" },
|
||||
.args = depArgs,
|
||||
});
|
||||
|
||||
Configuration cfg;
|
||||
cfg.path = "./";
|
||||
cfg.name = "Catcrafts.Net";
|
||||
cfg.outputName = "catcrafts";
|
||||
cfg.type = ConfigurationType::Executable;
|
||||
cfg.target = "wasm32-wasip1";
|
||||
ApplyStandardArgs(cfg, args);
|
||||
cfg.dependencies = { graphics };
|
||||
|
||||
std::array<fs::path, 4> ifaces = {
|
||||
"interfaces/Catcrafts",
|
||||
"interfaces/Catcrafts-Views",
|
||||
"interfaces/Catcrafts-Blog",
|
||||
"interfaces/Catcrafts-Root",
|
||||
};
|
||||
std::array<fs::path, 4> impls = {
|
||||
"implementations/main",
|
||||
"implementations/Catcrafts-Blog",
|
||||
"implementations/Catcrafts-Root",
|
||||
"implementations/Catcrafts-Views",
|
||||
};
|
||||
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
||||
|
||||
cfg.files.emplace_back(fs::path("styles/styles.css"));
|
||||
cfg.files.emplace_back(fs::path("robots.txt"));
|
||||
cfg.files.emplace_back(fs::path("sitemap.xml"));
|
||||
cfg.files.emplace_back(fs::path("favicon.svg"));
|
||||
// Loaded as a <script type="module"> before runtime.js by
|
||||
// EnableWasiBrowserRuntime — sets <title>/<link> tags since the
|
||||
// Dom partition has no head-element access.
|
||||
cfg.files.emplace_back(fs::path("catcrafts-head.js"));
|
||||
|
||||
EnableWasiBrowserRuntime(cfg);
|
||||
|
||||
return cfg;
|
||||
}
|
||||
Loading…
Reference in a new issue