// 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 project other projects load: a library, a program built on it, and a // tool that shares nothing with either and declares a test and a script. // Its `path` is relative, as a project file writes it, so a consumer only // builds it into this directory once the loader has rebased it. namespace { // One new set per call, at addresses that never change: whoever loads // this file keeps the pointers it returns. std::deque Owned; } extern "C" std::vector CrafterBuildConfigurations(std::span) { Configuration& greeter = Owned.emplace_back(); greeter.path = "./"; greeter.name = "greeter"; greeter.outputName = "greeter"; greeter.type = ConfigurationType::LibraryStatic; { std::array interfaces = { "greeter/Greeter" }; std::array implementations = {}; greeter.GetInterfacesAndImplementations(interfaces, implementations); } Configuration& hello = Owned.emplace_back(); hello.path = "./"; hello.name = "hello"; hello.outputName = "hello"; hello.type = ConfigurationType::Executable; hello.dependencies = { &greeter }; { std::array interfaces = {}; std::array implementations = { "hello/main" }; hello.GetInterfacesAndImplementations(interfaces, implementations); } Configuration& tool = Owned.emplace_back(); tool.path = "./"; tool.name = "tool"; tool.outputName = "tool"; tool.type = ConfigurationType::Executable; { std::array interfaces = {}; std::array implementations = { "tool/main" }; tool.GetInterfacesAndImplementations(interfaces, implementations); } tool.AddTest("ToolTest"); tool.scripts.push_back({"stamp", [](ScriptContext& ctx) { std::ofstream(ctx.projectDir / "stamp.ran") << ctx.project.name; return 0; }}); return { &greeter, &hello, &tool }; }