Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build deps of _build_script_run in 'exec' mode #1561

Merged
merged 5 commits into from
Oct 29, 2022

Conversation

scentini
Copy link
Collaborator

@scentini scentini commented Sep 22, 2022

@scentini scentini marked this pull request as ready for review September 22, 2022 13:30
@UebelAndre
Copy link
Collaborator

Sorry for the delay here!

I think this seems correct but could you elaborate on what deps is for the _build_script_run target? I only ever thought of deps as things for the rust_binary or script attribute. Would it make more sense to not pass deps as an attribute there? And to expect anything that needs to be used at runtime maybe:

  1. A data or compile_data attribute to the rust_binary
  2. A data or tools dependency of _build_script_run

@UebelAndre
Copy link
Collaborator

@scentini I saw you rebased this but did you see #1561 (comment) ?

@scentini
Copy link
Collaborator Author

Hey @UebelAndre, sorry for the delayed response! I believe the premise for needing the deps in the _build_script_run rule is to collect outputs from transitive build scripts.

  1. I wouldn't put them in data of rust_binary, because rust_binary is a generic rule, and the build script outputs shouldn't be present in the bazel-out/.../runfiles/... directory when it is used as a tool dependency, rather than as part of the build script setup.
  2. I don't see an easy way of doing this; currently we collect the output directories all the transitive BuildInfos; we wouldn't want to force users to be aware of all the transitive build scripts.
  3. There is a third option though: instead of a macro, we could have a build_script Starlark rule that unifies the work done by rust_binary and _build_script_run. In that case we could do something similar to 1., because the regular rust_binary won't have the build script outputs propagated in its data, it would be the build_script rule. I consider this option out of scope for this PR though :)

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

Sorry about the merge conflict. Hope you don't mind me resolving it for you. I think this change is fine but after looking closer at cargo_build_script I feel it's implemented in a confusing way and can be simplified. I'll try to open PRs to improve that.

Sorry for the delay and looks good!

@scentini scentini merged commit 9e3d841 into bazelbuild:main Oct 29, 2022
@scentini scentini deleted the build_script branch October 29, 2022 00:10
@scentini
Copy link
Collaborator Author

No worries @UebelAndre, thanks for the review!

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