Optionally traverse srcs and deps for run-time dependencies#3466
Merged
chrisnovakovic merged 3 commits intothought-machine:masterfrom Dec 9, 2025
Merged
Conversation
There are circumstances under which a target might want to inherit the run-time dependencies of certain build-time dependencies, because the target's output is built in such a way that its dependencies don't have their own run-time dependencies resolved. An example of this is the shell-rules plugin's `sh_binary` rule: a `sh_binary` is a zip file of its dependencies (`deps`) concatenated onto a shell script preamble that extracts those dependencies into a temporary directory during initialisation. If one of those `deps` happens to have its own run-time dependencies, Please will not resolve them, and they will therefore not be built before the target runs (and will not be sent to the remote worker along with the target's output). Add two parameters to `build_rule` - `runtime_deps_from_srcs` and `runtime_deps_from_deps` - that indicate to Please that run-time dependencies should additionally be collected from the target's `srcs` and `deps` respectively. This allows build definitions to inherit the run-time dependencies of their sources and/or build-time dependencies if they know they will be needed when running the target they generate.
f20fdfa to
021659b
Compare
Contributor
Author
|
Rebased to fix the FreeBSD Cirrus CI job (#3467). |
toastwaffle
approved these changes
Dec 9, 2025
src/core/build_target.go
Outdated
| } | ||
| } | ||
| } | ||
| for _, dep := range t.dependencies { |
Contributor
There was a problem hiding this comment.
Is it worth putting this loop inside a conditional on t.RuntimeDependenciesFromSources || t.RuntimeDependenciesFromDependencies? Or is this just not run enough for it to matter?
Contributor
Author
There was a problem hiding this comment.
It's a good point - that iteration over t.dependencies is entirely unnecessary for most targets. I'll gate it.
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.
There are circumstances under which a target might want to inherit the run-time dependencies of certain build-time dependencies, because the target's output is built in such a way that its dependencies don't have their own run-time dependencies resolved. An example of this is the shell-rules plugin's
sh_binaryrule: ash_binaryis a zip file of its dependencies (deps) concatenated onto a shell script preamble that extracts those dependencies into a temporary directory during initialisation. If one of thosedepshappens to have its own run-time dependencies, Please will not resolve them, and they will therefore not be built before the target runs (and will not be sent to the remote worker along with the target's output).Add two parameters to
build_rule-runtime_deps_from_srcsandruntime_deps_from_deps- that indicate to Please that run-time dependencies should additionally be collected from the target'ssrcsanddepsrespectively. This allows build definitions to inherit the run-time dependencies of their sources and/or build-time dependencies if they know they will be needed when running the target they generate.