feat(external): forward a project's args to its sibling projects by default
Every project.cpp with a sibling dependency opened with the same line,
std::vector<std::string> depArgs(args.begin(), args.end());
and handed depArgs to each GitProject and LocalProject. CrafterBuildProject
receives a span of string_views and the specs wanted owned strings, and
without the copy the sibling got none of the project's args: it was built
for the host while the project cross-compiled, and in release while it
built --debug. GitProject then turned the copy straight back into
string_views for LoadProject.
Both specs now default their args to ProjectArgs(), the args LoadProject
was given for the project file whose CrafterBuildProject is running. It
reads the per-thread stack LoadProject already keeps for IsTopLevelProject
and ProjectDependency, whose frames now record the args. A default member
initializer rather than a new type or an optional: the member stays a
std::vector<std::string>, so every existing `.args = depArgs` keeps its
exact meaning (each of the ~50 calls across the Catcrafts projects passes
one), and `.args = {}` still forwards nothing. It is the shape of
Configuration::target = HostTarget(). A project.cpp that drops its .args
needs a crafter-build with this change: an older one compiles it and
forwards nothing.
ProjectArgs() is declared in :External, next to the defaults that call
it. :Platform, where it is defined, cannot be imported there: its
unexported `struct Configuration;` would make :External's exported one an
ill-formed redeclaration, which clang rejects.
The #pragma crafter dependency path now passes `.args = {}` explicitly.
Host tooling is built for the host whatever the consumer targets and was
loaded with no args; the default would otherwise hand it the consumer's
--target= and project flags.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0cbded4a3d
commit
aec93617ee
2 changed files with 48 additions and 13 deletions
|
|
@ -54,16 +54,31 @@ export namespace Crafter {
|
|||
std::vector<std::string> ExternalIncludeFlags(const ExternalDependency& dep, std::string_view target);
|
||||
ExternalBuildResult BuildExternal(const ExternalDependency& dep, std::string_view target, std::atomic<bool>& cancelled);
|
||||
|
||||
// The args LoadProject was given for the project file currently running
|
||||
// its CrafterBuildProject: what that function receives, standard flags
|
||||
// included (cfg.projectArgs is only the part ApplyStandardArgs left
|
||||
// over). Empty when no project file is running, and on any thread but
|
||||
// the one loading it, because it reads the stack LoadProject keeps per
|
||||
// thread, as IsTopLevelProject does. The specs below default their args
|
||||
// to it. Defined beside LoadProject, but declared here so those defaults
|
||||
// can see it: importing :Platform into this partition would make the
|
||||
// exported `struct Configuration;` above a redeclaration of :Platform's
|
||||
// unexported one, which clang rejects.
|
||||
std::vector<std::string> ProjectArgs();
|
||||
|
||||
// Specification for a sibling crafter-build project to fetch and depend on.
|
||||
// GitSource picks the revision: leave branch + commit empty for the
|
||||
// remote's default branch HEAD (sloppy but convenient), set branch to
|
||||
// track a branch tip, or set commit to pin to an immutable SHA. args are
|
||||
// forwarded verbatim to the dep's CrafterBuildProject — typically you
|
||||
// pass through the parent's args so target/march/debug propagate.
|
||||
// what the dep's CrafterBuildProject receives. They default to this
|
||||
// project's own, so --target=, --march=, --debug and flags of its own
|
||||
// such as --local reach a whole chain of sibling projects without being
|
||||
// passed. Set them to forward something else: a copy without one of this
|
||||
// project's flags, one with an extra --target=, or {} for nothing.
|
||||
struct GitProjectSpec {
|
||||
GitSource source;
|
||||
fs::path projectFile = "project.cpp";
|
||||
std::vector<std::string> args;
|
||||
std::vector<std::string> args = ProjectArgs();
|
||||
};
|
||||
|
||||
// Clones the spec's git URL into the per-project external cache (keyed by
|
||||
|
|
@ -77,8 +92,8 @@ export namespace Crafter {
|
|||
// example folder depending on its parent project, or a workspace where
|
||||
// multiple projects live side-by-side without going through git).
|
||||
struct LocalProjectSpec {
|
||||
fs::path projectFile; // relative to cwd or absolute
|
||||
std::vector<std::string> args; // forwarded to dep's CrafterBuildProject
|
||||
fs::path projectFile; // relative to cwd or absolute
|
||||
std::vector<std::string> args = ProjectArgs(); // as GitProjectSpec::args
|
||||
};
|
||||
|
||||
// Same as GitProject but for a local on-disk project — no fetch, no
|
||||
|
|
|
|||
Loading…
Reference in a new issue