Crafter.LintRules declares a test that links crafter-build, fetched with GitProject. crafter-build's own project.cpp loads Crafter.LintRules as a `#pragma crafter dependency`, so the chain was: crafter-build loads LintRules, LintRules' test wiring loads crafter-build's project.cpp from the external cache, which loads LintRules again, and the cycle guard threw. Every command that loads project.cpp in this repository has failed since that test was added, including the last CI run on master. A project file had no way to tell whether it was the one the user pointed crafter-build at or a dependency being loaded for somebody else, so it could not skip wiring that only its own build needs. IsTopLevelProject() answers that from the loading-frame stack ProjectDependency() already reads: one frame is the top-level project file, a second is only ever pushed for a dependency. Outside any project file it is true as well, which is what a test harness constructing Configurations expects. The ProjectDependency test records the answer from both the app and the greeter project files and checks each. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
25 lines
1,015 B
C++
25 lines
1,015 B
C++
// 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;
|
|
|
|
// The sibling project the consumer's project.cpp imports a module from.
|
|
// ApplyStandardArgs on purpose: it reads CRAFTER_BUILD_MARCH from the
|
|
// environment, and the pre-pass has to override whatever it picked.
|
|
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
|
Configuration cfg;
|
|
cfg.path = "./";
|
|
cfg.name = "greeter";
|
|
cfg.outputName = "greeter";
|
|
cfg.type = ConfigurationType::LibraryStatic;
|
|
ApplyStandardArgs(cfg, args);
|
|
std::array<fs::path, 1> ifaces = { "interfaces/Greeter" };
|
|
std::array<fs::path, 0> impls = {};
|
|
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
|
// Loaded as a dependency, so this must come out false (see app/).
|
|
cfg.compileFlags.push_back(IsTopLevelProject() ? "-DTOP_LEVEL=1" : "-DTOP_LEVEL=0");
|
|
return cfg;
|
|
}
|