Crafter.Build/tests/ProjectDependency/fixture/static-dep/project.cpp
Jorijn van der Graaf e6363b95fe
test: specs and ProjectDependency() in a project file's static initialisers
ProjectArgs gets a sibling that makes its own sibling's spec at
namespace scope. Before the fix that spec took the args the file was
first loaded with; now it takes none on every load. The checks go
through one CheckLoaded helper, which prints what each sibling was
given, so a failure says which args a wrong frame handed over.

ProjectDependency loads a fixture whose static initialiser asks for its
pragma dependency, in a child, because a throw there terminates the
process: before the fix it found none. The check that the dependency
gets none of the consumer's args moves into the first load, which now
passes the app an arg it ignores; the separate load could not fail its
own check, and its early return skipped every later one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 05:11:41 +01:00

22 lines
704 B
C++

// SPDX-License-Identifier: LGPL-3.0-only
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
import std;
import Crafter.Build;
#pragma crafter dependency "../greeter"
using namespace Crafter;
// Asks for its dependency at namespace scope, so the call runs while
// LoadProject dlopens this file, before CrafterBuildProject is called.
namespace {
Configuration* const Greeter = ProjectDependency("greeter");
}
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view>) {
Configuration cfg;
cfg.path = "./";
cfg.name = std::format("static {}", Greeter->name);
cfg.outputName = "static-dep";
cfg.type = ConfigurationType::Executable;
return cfg;
}