Skip to content

flowey: expose the build script OUT_DIR from run_cargo_build - #4292

Draft
Ben Hillis (benhillis) wants to merge 1 commit into
microsoft:mainfrom
benhillis:user/benhillis/flowey-build-script-out-dir
Draft

flowey: expose the build script OUT_DIR from run_cargo_build#4292
Ben Hillis (benhillis) wants to merge 1 commit into
microsoft:mainfrom
benhillis:user/benhillis/flowey-build-script-out-dir

Conversation

@benhillis

Copy link
Copy Markdown
Member

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_DIR the build script was invoked with, via a new optional build_script_out_dir on run_cargo_build::Request. Cargo already reports it in the build-script-executed message (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 passes None.

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>
Copilot AI lite review requested due to automatic review settings August 20, 2026 17:31
@benhillis
Ben Hillis (benhillis) requested a review from a team as a code owner August 20, 2026 17:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to run_cargo_build::Request.
  • Models Cargo’s build-script-executed JSON message and captures the out_dir for the requested package by matching on package_id.
  • Updates the HvLite wrapper to pass None to 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.

@benhillis
Ben Hillis (benhillis) marked this pull request as draft August 20, 2026 18:21
@github-actions

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants