Skip to content

Use relative labels and Label macro wherever possible #543

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

Merged
merged 2 commits into from
Jan 21, 2021
Merged

Use relative labels and Label macro wherever possible #543

merged 2 commits into from
Jan 21, 2021

Conversation

UebelAndre
Copy link
Collaborator

This PR updates changes the explicit use of @io_bazel_rules_rust//... to //... and adds the use of Label wherever possible. This should currently have no functional but it provides some better type guarantees.

@google-cla google-cla bot added the cla: yes label Dec 27, 2020
@UebelAndre
Copy link
Collaborator Author

This PR came from some exploration i was doing in trying to support either agnostic workspace names for this repository or at least both rules_rust and io_bazel_rules_rust. For the most part, this would work if it weren't for two things, the way toolchains are currently setup, and the fact that some cargo-raze outputs (namely protobuf) have dependencies on the workspace name.

executable = True,
allow_single_file = True,
cfg = "exec",
),
},
outputs = {"out": "%{name}.rs"},
toolchains = [
"@io_bazel_rules_rust//bindgen:bindgen_toolchain",
"@io_bazel_rules_rust//rust:toolchain",
str(Label("//bindgen:bindgen_toolchain")),
Copy link
Collaborator Author

@UebelAndre UebelAndre Dec 28, 2020

Choose a reason for hiding this comment

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

I'm shopping around for some thoughts here and generally more insight on Label. I'm not sure if this is an appropriate use of Label. Anyone have any experiences like this they can share?

Specifically around str(Label("..."))

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is perfectly acceptable. I remember having a funny discussion with several senior engineer in the Bazel team about this "hack" and having the manager answer: I don't think this is a hack, which just settled our decision to keep this as an idiom, although I left the team 3 years ago so I don't know what is the status now.

@UebelAndre
Copy link
Collaborator Author

@dfreese Hey, are you able to take a look at this 🙏

@UebelAndre
Copy link
Collaborator Author

@damienmg hey, you wouldn't als have time to look at this would you 😅 🙏

This allows for the workspace to have an arbitrary name with the exception of any thing that was output by `cargo-raze`
@UebelAndre
Copy link
Collaborator Author

@illicitonion Hey, would you have time to take a look at this? 🙏 😅

@UebelAndre
Copy link
Collaborator Author

@damienmg Hey, spoke with @illicitonion and he thinks you'd be the best reviewer for this change. Would you have a quick moment to take a look at this this week?

executable = True,
allow_single_file = True,
cfg = "exec",
),
},
outputs = {"out": "%{name}.rs"},
toolchains = [
"@io_bazel_rules_rust//bindgen:bindgen_toolchain",
"@io_bazel_rules_rust//rust:toolchain",
str(Label("//bindgen:bindgen_toolchain")),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is perfectly acceptable. I remember having a funny discussion with several senior engineer in the Bazel team about this "hack" and having the manager answer: I don't think this is a hack, which just settled our decision to keep this as an idiom, although I left the team 3 years ago so I don't know what is the status now.

@damienmg
Copy link
Collaborator

This is the right approach, this repository was created before we made the label behavior consistent and thus was using aboslute label approach, but there is no reason to do this anymore.

@UebelAndre
Copy link
Collaborator Author

@damienmg Thanks for the review, that bit of context, and updating the branch 🙏 CI seems to still be passing 😄

@damienmg damienmg merged commit 2c678c1 into bazelbuild:master Jan 21, 2021
@UebelAndre UebelAndre deleted the label branch January 21, 2021 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants