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>
23 lines
893 B
C++
23 lines
893 B
C++
// SPDX-License-Identifier: LGPL-3.0-only
|
|
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
import std;
|
|
import Crafter.Build;
|
|
#pragma crafter dependency "../greeter"
|
|
import Greeter;
|
|
using namespace Crafter;
|
|
|
|
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view>) {
|
|
Configuration cfg;
|
|
cfg.path = "./";
|
|
cfg.name = Greet();
|
|
cfg.outputName = "app";
|
|
cfg.type = ConfigurationType::Executable;
|
|
// Once by the module it exports, once by its configuration name; the
|
|
// test expects the same object back for both.
|
|
cfg.dependencies = { ProjectDependency("Greeter"), ProjectDependency("greeter") };
|
|
// Reported through a flag the test can read back: this file is the one
|
|
// LoadProject was pointed at, the greeter's is not.
|
|
cfg.compileFlags.push_back(IsTopLevelProject() ? "-DTOP_LEVEL=1" : "-DTOP_LEVEL=0");
|
|
return cfg;
|
|
}
|