ProjectArgs loads a chain app -> lib -> leaf of LocalProjects with --debug
and a project flag. lib, loaded without .args, has to see both, and so
does its own sibling, which takes the default one level further down.
Copies loaded with `.args = {}` and with an explicit list get nothing and
exactly that list. The GitProjectSpec default is checked on the spec
itself, since a GitProject would need a repository to clone. Without the
defaults, five of its checks fail.
ProjectDependency now also loads its consumer with a project flag: the
pragma dependency must still come back with no args. Without the explicit
`.args = {}` in the pragma path it gets the consumer's flag.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
1.3 KiB
C++
29 lines
1.3 KiB
C++
// SPDX-License-Identifier: LGPL-3.0-only
|
|
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
import std;
|
|
import Crafter.Build;
|
|
using namespace Crafter;
|
|
|
|
// Loads the same sibling three ways: with its args left at their default,
|
|
// with nothing forwarded, and with a list of its own. The test reads what
|
|
// each copy received back out of cfg.dependencies.
|
|
extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> args) {
|
|
Configuration* inherited = LocalProject({ .projectFile = "../lib/project.cpp" });
|
|
Configuration* none = LocalProject({ .projectFile = "../lib/project.cpp", .args = {} });
|
|
Configuration* replaced = LocalProject({ .projectFile = "../lib/project.cpp", .args = { "--only" } });
|
|
|
|
Configuration cfg;
|
|
cfg.path = "./";
|
|
cfg.name = "app";
|
|
cfg.outputName = "app";
|
|
cfg.type = ConfigurationType::Executable;
|
|
ApplyStandardArgs(cfg, args);
|
|
cfg.dependencies = { inherited, none, replaced };
|
|
// GitProjectSpec takes the same default. Checked on the spec itself,
|
|
// since a GitProject would need a repository to clone.
|
|
const GitProjectSpec git{ .source = { .url = "unused" } };
|
|
const bool gitDefault = git.args == std::vector<std::string>(args.begin(), args.end());
|
|
cfg.compileFlags.push_back(gitDefault ? "-DGIT_DEFAULT=1" : "-DGIT_DEFAULT=0");
|
|
return cfg;
|
|
}
|