lint rules lite

This commit is contained in:
Jorijn van der Graaf 2026-10-31 02:21:19 +01:00
commit 42a27016e3
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
4 changed files with 213 additions and 111 deletions

View file

@ -7,9 +7,6 @@ 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());
const bool useLocal = std::erase(depArgs, "--local") > 0;
Configuration cfg;
cfg.path = "./";
cfg.name = "Crafter.LintRules";
@ -28,15 +25,15 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
// The rule test compiles the module as its own interface and links
// crafter-build to run the linter in-process: from git by default, or
// the sibling checkout with `crafter-build test --local`. Host only,
// like the rules themselves, and only when this is the project being
// built: crafter-build itself loads this file as a dependency, and the
// test's GitProject would then load crafter-build's project file again
// and recurse into the cycle guard.
if (IsTopLevelProject() && cfg.target == "x86_64-pc-linux-gnu") {
Configuration* build = useLocal
? LocalProject({ .projectFile = "../Crafter.Build/project.cpp", .args = depArgs })
: GitProject({ .source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Build.git" }, .args = depArgs });
// the sibling checkout with `crafter-build test --local`. Only when this
// is the project being built: crafter-build itself loads this file as a
// dependency, and the test's GitProject would then load crafter-build's
// project file again and recurse into the cycle guard. No target check:
// crafter-build only runs on Linux, and the hard-coded triple this used
// to compare against silently dropped the test on any host that spells
// its triple differently (the Flatpak's x86_64-unknown-linux-gnu).
if (IsTopLevelProject()) {
Configuration* build = GitProject({ .source = { .url = "https://forgejo.catcrafts.net/Catcrafts/Crafter.Build.git" }, .args = depArgs });
cfg.AddTest("HouseRules", ifaces).Dependencies({ build });
}
return cfg;