Merge branch 'claude/forward-project-args': sibling projects inherit the args, lint with the lite rules
PR #40. GitProject and LocalProject default their args to the loading project's own (ProjectArgs()), this tree lints with LintRules' lite set, and the fixes from the branch's review: a project file gets its args only for the CrafterBuildProject call, host tooling gets project cache entries of its own, and `--` ends crafter-build's options. The conflicts with claude/dependency-notes are all places both sides added to: - Platform.cppm and Platform.cpp: PragmaDependencies() beside ProjectArgs() and LoadingHostTooling(), all three kept. - LoadProject: the record PragmaDependencies() reads moves up with the frame's dependencies, which this branch sets before dlopen. Left where it was, it would have copied preDeps.configs after the vector was moved into the frame, and recorded nothing. - README: the pragma section's new last sentence goes before the new "Dependency notes for agents" section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
75142276ab
23 changed files with 599 additions and 62 deletions
|
|
@ -484,7 +484,9 @@ export namespace Crafter {
|
|||
// cfg.files, say), and without it both flag settings share one bin dir
|
||||
// and interleave their outputs there. Populated by ApplyStandardArgs;
|
||||
// the args it does recognise are excluded, since their effect already
|
||||
// shows up in target/march/mtune/debug/sysroot/type.
|
||||
// shows up in target/march/mtune/debug/sysroot/type. For the same
|
||||
// reason this is not what to hand a sibling project: ProjectArgs() is
|
||||
// every arg, the recognised ones included.
|
||||
std::vector<std::string> projectArgs;
|
||||
std::vector<Test> tests;
|
||||
// Lint rules for `crafter-build lint`. Populate via AddLintRule.
|
||||
|
|
|
|||
|
|
@ -71,31 +71,56 @@ export namespace Crafter {
|
|||
// clone can still differ in includeDirs, libDirs and libs.
|
||||
ExternalBuildResult ExternalOutputs(const ExternalDependency& dep, std::string_view target);
|
||||
|
||||
// The args the project file now running its CrafterBuildProject was
|
||||
// loaded with: everything that function receives, --target=, --debug and
|
||||
// the other standard flags included. Not cfg.projectArgs, which holds
|
||||
// only what ApplyStandardArgs left uninterpreted: `.args =
|
||||
// cfg.projectArgs` would drop the target and the build type. Empty
|
||||
// everywhere else, because it reads the stack LoadProject keeps per
|
||||
// thread, as IsTopLevelProject does: outside a project file, on any
|
||||
// thread but the one running it, once CrafterBuildProject has returned
|
||||
// (a script runs later), and before it is called, which covers the
|
||||
// file's static initialisers and its `#pragma crafter dependency`
|
||||
// pre-pass. 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, read when the spec is made, so --target=, --march=,
|
||||
// --debug and the project's own flags reach every sibling down a chain
|
||||
// without being passed. Set them to forward something else: {} for
|
||||
// nothing, or a list built from this project's args, such as one without
|
||||
// a flag only this project reads. Give such a list to every sibling: a
|
||||
// project that two paths load with two different lists is built twice,
|
||||
// and the program ends up with both builds.
|
||||
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
|
||||
// url+branch+commit+args+projectFile), recursively LoadProject's the
|
||||
// remote's project.cpp, and returns a stable Configuration* you can drop
|
||||
// into cfg.dependencies. The Configuration is owned by an internal cache
|
||||
// for the lifetime of the build; identical specs share one Configuration.
|
||||
// Clones the spec's git URL into the external cache, recursively
|
||||
// LoadProject's the remote's project.cpp, and returns a stable
|
||||
// Configuration* you can drop into cfg.dependencies. The clone is keyed by
|
||||
// url+branch+commit+projectFile alone, so every arg list builds in the
|
||||
// same working tree, each into variant directories of its own. The
|
||||
// Configuration is owned by an internal cache for the lifetime of the
|
||||
// build, keyed by the clone and the args: identical specs share one.
|
||||
Configuration* GitProject(const GitProjectSpec& spec);
|
||||
|
||||
// Specification for a local sibling crafter-build project (e.g. an
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -82,6 +82,12 @@ namespace Crafter {
|
|||
// dependency notes of the project crafter-build was pointed at are
|
||||
// gathered (Crafter.Build:Agents).
|
||||
std::vector<Configuration*> PragmaDependencies(const fs::path& projectFile);
|
||||
// True while this thread loads a `#pragma crafter dependency`: the tool's
|
||||
// project file and every sibling it loads in turn. GitProject and
|
||||
// LocalProject key the project cache on it, so host tooling, which
|
||||
// ForceHostTooling rewrites in place, never shares a Configuration with a
|
||||
// load for the target.
|
||||
bool LoadingHostTooling();
|
||||
// Resolves the directory holding distributed runtime assets (Crafter.Build
|
||||
// module sources, wasi-runtime/, etc). Honors CRAFTER_BUILD_HOME; otherwise
|
||||
// derives <prefix>/share/crafter-build from the running executable's path.
|
||||
|
|
|
|||
Loading…
Reference in a new issue