test(build): one project loaded with its flags in two orders is built once

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.
This commit is contained in:
Jorijn van der Graaf 2026-11-27 09:25:53 +01:00
commit 15e9831203
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
2 changed files with 70 additions and 1 deletions

View file

@ -8,13 +8,16 @@ 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.
// 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" });