flowey: expose the build script OUT_DIR from run_cargo_build - #4292
Draft
Ben Hillis (benhillis) wants to merge 1 commit into
Draft
flowey: expose the build script OUT_DIR from run_cargo_build#4292Ben Hillis (benhillis) wants to merge 1 commit into
Ben Hillis (benhillis) wants to merge 1 commit into
Conversation
Crates whose build script emits auxiliary artifacts that cargo itself doesn't track (e.g: generated metadata files) currently have no good way to hand those artifacts to flowey. The workaround is to have the build script copy them somewhere flowey knows about, but that only happens when the build script actually re-runs - on a warm cargo cache it doesn't, so the destination has to be kept alive out-of-band, and forcing it to repopulate means invalidating the crate. Instead, let a caller ask for the `OUT_DIR` the build script was invoked with. Cargo reports it in the `build-script-executed` message, and preserves the directory whether or not the script re-ran, so artifacts can simply be read from it after every build. The build script is matched by package id (as reported alongside the crate's own compiler artifact) rather than by name, since a package id is unambiguous. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends Flowey’s run_cargo_build node API so callers can optionally retrieve the OUT_DIR used for a crate’s build script, enabling reliable collection of build-script-produced artifacts (even on warm caches) without requiring an out-of-band copy step.
Changes:
- Adds an optional
build_script_out_dir: Option<WriteVar<PathBuf>>output torun_cargo_build::Request. - Models Cargo’s
build-script-executedJSON message and captures theout_dirfor the requested package by matching onpackage_id. - Updates the HvLite wrapper to pass
Noneto preserve existing behavior for current callers.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| flowey/flowey_lib_hvlite/src/run_cargo_build.rs | Plumbs the new optional build_script_out_dir field through the wrapper (set to None for existing behavior). |
| flowey/flowey_lib_common/src/run_cargo_build.rs | Adds the new request field and implements extraction of build script OUT_DIR from Cargo JSON output via package_id. |
| flowey/flowey_lib_common/src/_util/cargo_output.rs | Extends Cargo JSON message modeling to include package_id on artifacts and the build-script-executed message with out_dir. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Ben Hillis (benhillis)
marked this pull request as draft
August 20, 2026 18:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Crates whose build script emits auxiliary artifacts that cargo itself doesn't track (e.g: generated metadata files) currently have no good way to hand those artifacts to flowey.
The workaround is to have the build script copy them somewhere flowey knows about, via an env var pointing at a flowey-owned directory. That only happens when the build script actually re-runs though - on a warm cargo cache it doesn't, so the destination has to be kept alive out-of-band between runs, and forcing it to repopulate means invalidating the crate and paying for a relink.
Instead, let a caller ask for the
OUT_DIRthe build script was invoked with, via a new optionalbuild_script_out_dironrun_cargo_build::Request. Cargo already reports it in thebuild-script-executedmessage (we just weren't modelling that variant), and cargo preserves the directory whether or not the script re-ran - so the artifacts can simply be read from it after every build, warm or cold.The build script is matched by package id (as reported alongside the crate's own compiler artifact) rather than by name, since a package id is unambiguous.
No behavior change for existing callers: the new field is
Option, and every current call site passesNone.