2026-10-02 19:57:28 +02:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only
|
|
|
|
|
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
|
|
|
|
|
|
import std;
|
|
|
|
|
import Crafter.Build;
|
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
|
using namespace Crafter;
|
|
|
|
|
|
|
|
|
|
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
|
|
|
|
Configuration cfg;
|
|
|
|
|
cfg.path = "./";
|
|
|
|
|
cfg.name = "Crafter.LintRules";
|
|
|
|
|
cfg.outputName = "Crafter.LintRules";
|
|
|
|
|
cfg.type = ConfigurationType::LibraryStatic;
|
|
|
|
|
ApplyStandardArgs(cfg, args);
|
|
|
|
|
// No dependency on Crafter.Build, on purpose. The rules only ever run
|
|
|
|
|
// inside a crafter-build process, which provides the symbols, and a host
|
|
|
|
|
// build already sees the Crafter.Build modules through the PCM cache
|
|
|
|
|
// crafter-build keeps for its own project files — declaring the library
|
|
|
|
|
// here would make every consumer clone and build all of crafter-build
|
|
|
|
|
// just to lint.
|
|
|
|
|
std::array<fs::path, 1> ifaces = { "interfaces/Crafter.LintRules" };
|
|
|
|
|
std::array<fs::path, 0> impls = {};
|
|
|
|
|
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
|
|
|
|
|
|
|
|
|
// 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
|
2026-10-31 02:21:19 +01:00
|
|
|
// 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 });
|
2026-10-02 19:57:28 +02:00
|
|
|
cfg.AddTest("HouseRules", ifaces).Dependencies({ build });
|
|
|
|
|
}
|
|
|
|
|
return cfg;
|
|
|
|
|
}
|