DuplicateModule builds its project once more with --wide --reorder, with which P gives M the list that A passes on, in the other order. The loader takes the two orders for two lists and makes two configurations of M, which VariantId, taking the project's own flags sorted, builds into one directory, and a pass builds that directory once. The case checks that the two are two configurations with one directory, and then, in two passes, that the graph builds and that P's main.cpp and A's interface have their edges to the module of the configuration of M that the pass built. The first pass builds whichever asks first, and the other has no modules. The second builds the other one first and records it for the directory, as BuildAll records a configuration it builds, before it builds the graph, so that both configurations of M then have modules, the first still those it read in the first pass. On the engine of the range's base the graph is refused as "module M is built twice for P": every configuration had its modules from the listing, and the refusal told the builds apart by their configurations. On an engine that reads a dependency's modules off the configuration it is listed as, the range's fix without BuildResult::built, the first pass builds and A's interface has no edge to M, P's M being the one built and A's having no modules, and the second pass is refused as a graph with two builds of M.
35 lines
1.4 KiB
C++
35 lines
1.4 KiB
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;
|
|
|
|
// Loads M itself and through A, which passes on all of its args. With
|
|
// --split, the list P gives M leaves --wide out, as a filter meant for one
|
|
// sibling would, and the two paths load M with two different lists. With
|
|
// --reorder, P gives M its args in the other order: the same list, which
|
|
// the loader still takes for another.
|
|
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
|
const bool split = std::ranges::contains(args, std::string_view("--split"));
|
|
std::vector<std::string> mArgs;
|
|
for (std::string_view arg : args) {
|
|
if (!split || arg != "--wide") mArgs.emplace_back(arg);
|
|
}
|
|
if (std::ranges::contains(args, std::string_view("--reorder"))) std::ranges::reverse(mArgs);
|
|
Configuration* m = LocalProject({ .projectFile = "../m/project.cpp", .args = mArgs });
|
|
Configuration* a = LocalProject({ .projectFile = "../a/project.cpp" });
|
|
|
|
Configuration cfg;
|
|
cfg.path = "./";
|
|
cfg.name = "P";
|
|
cfg.outputName = "P";
|
|
cfg.type = ConfigurationType::Executable;
|
|
ApplyStandardArgs(cfg, args);
|
|
cfg.dependencies = { m, a };
|
|
std::array<fs::path, 0> ifaces = {};
|
|
std::array<fs::path, 1> impls = { "main" };
|
|
cfg.GetInterfacesAndImplementations(ifaces, impls);
|
|
return cfg;
|
|
}
|