Skip to content

Add proto_toolchain rule #82

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

Closed
wants to merge 1 commit into from

Conversation

Yannic
Copy link
Collaborator

@Yannic Yannic commented Jan 22, 2021

No description provided.

@Yannic Yannic force-pushed the proto_toolchain_rule branch from e3d417c to 0c8e3b9 Compare January 22, 2021 16:01
@Yannic
Copy link
Collaborator Author

Yannic commented Jan 22, 2021

@comius This is a Starlark implementation of proto_toolchain that you asked for, PTAL (you only need to look at the last commit, the other commits come from #77 because there are merge conflicts with that PR. Will rebase once the other PR lands)

@Yannic Yannic force-pushed the proto_toolchain_rule branch 4 times, most recently from 5b33509 to 42e6845 Compare January 23, 2021 14:11
Yannic added a commit to Yannic/bazel that referenced this pull request Jan 26, 2021
This change exposes the values of `--protoc` and `--proto_options` to
Starlark, thus making it possible to implement `proto_toolchain` in
Starlark. See bazelbuild/rules_proto#82 for the
implementation of `proto_toolchain`.

Working towards bazelbuild#10005
Copy link
Collaborator

@comius comius left a comment

Choose a reason for hiding this comment

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

Looks good. If you know any good alternatives for the transition, feel free to suggest them. Otherwise LGTM.

@comius comius self-assigned this Jan 28, 2021
@Yannic
Copy link
Collaborator Author

Yannic commented Jan 28, 2021

(I'll fix the nits later today)

I agree that we should migrate away from the command-line flags, however, I'd like to start with using proto_toolchain to expose the command-line flags, then migrate the native rule to depend on proto_toolchain and, once that's complete, deprecate and remove the command-line flags. That avoids inconsistencies in the migration period.

@comius
Copy link
Collaborator

comius commented Jan 28, 2021

(I'll fix the nits later today)

I agree that we should migrate away from the command-line flags, however, I'd like to start with using proto_toolchain to expose the command-line flags, then migrate the native rule to depend on proto_toolchain and, once that's complete, deprecate and remove the command-line flags. That avoids inconsistencies in the migration period.

I would rather see that proto_toolchain rule looks like the final version, that is with a mandatory attribute for protoc, with a default value set. Then add a flag --incompatible_use_toolchain_resolution_for_proto_rules, which is used in the actual rule implementation and decides either to use the toolchain's protoc or the one from flag.

This direction won't block you, when you'll need to add multiple proto_toolchain definitions with protoc for different OS and CPUs.

You will still need an implicit dependency in the proto rules. But even before proto rules are in Starlark, we can flip the toolchain resolution flag and remove protoc flag.

@Yannic
Copy link
Collaborator Author

Yannic commented Jan 28, 2021

Sure, I can create something similar to what C++/Java do

@Yannic Yannic force-pushed the proto_toolchain_rule branch from 42e6845 to 4874999 Compare January 28, 2021 18:50
@Yannic
Copy link
Collaborator Author

Yannic commented Jan 28, 2021

PTAL

Also, could you try to find a reviewer for #77? It seems like we only need a readability review, so I guess anyone with C++ readability could review if @lberki can't do it right now.

@Yannic Yannic force-pushed the proto_toolchain_rule branch from 4874999 to 35184b3 Compare January 28, 2021 19:03
@comius
Copy link
Collaborator

comius commented Jan 29, 2021

Sure, I can create something similar to what C++/Java do

May I suggest that you write a proposal for proto rules toolchainization? See https://github.com/bazelbuild/proposals
With a clear plan, PRs might go through faster, going less back and forth.

@Yannic Yannic force-pushed the proto_toolchain_rule branch from 35184b3 to 74faad4 Compare February 23, 2021 22:55
@Yannic Yannic marked this pull request as ready for review February 23, 2021 22:57
@Yannic Yannic requested a review from lberki as a code owner February 23, 2021 22:57
@Yannic
Copy link
Collaborator Author

Yannic commented Feb 23, 2021

Sure, I can create something similar to what C++/Java do

May I suggest that you write a proposal for proto rules toolchainization? See https://github.com/bazelbuild/proposals
With a clear plan, PRs might go through faster, going less back and forth.

Done (https://docs.google.com/document/d/1go3UMwm2nM8JHhI3MZrtyoFEy3BYg5omGqQmOwcjmNE/edit) PTAL

@comius
Copy link
Collaborator

comius commented Mar 29, 2022

I'm closing this because it's outdated, and we probably don't need proto_toolchain rule.

@comius comius closed this Mar 29, 2022
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