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

Add ProtoInfo constructor to Starlark #11061

Closed

Conversation

cheister
Copy link
Contributor

@cheister cheister commented Apr 3, 2020

This is a follow up to #10966 to allow users to create a ProtoInfo provider in Starlark. The corresponding issue is #11060

It also allows the native proto_library to have deps and exports that are not proto_library rules.

@cheister cheister requested a review from lberki as a code owner April 3, 2020 06:47
@dslomov dslomov added team-Rules-Server Issues for serverside rules included with Bazel untriaged labels Apr 3, 2020
@cheister
Copy link
Contributor Author

cheister commented Apr 3, 2020

cc: @Yannic

@cheister
Copy link
Contributor Author

@lberki or @Yannic do you mind taking a look? Thanks.

@cheister cheister force-pushed the proto-common-create-proto-info branch from f6b9737 to bf1ef07 Compare September 15, 2020 19:33
@cheister
Copy link
Contributor Author

@lberki are you still the right person to look at this PR? This feature would let us fix another problem with the IJ plugin not recognizing proto files because we have to make a custom ProtoInfo object for our Proto Rules because there is no way in StarLark to create a native ProtoInfo object.

@aiuto aiuto requested a review from comius February 22, 2021 15:45
@comius comius requested review from c-mita and removed request for comius and lberki May 5, 2021 13:08
Copy link
Contributor

@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.

Have you considered implementing it as a default constructor? That is exposing ProtoInfo() call to Starlark, like it is done for JavaInfo, CcInfo.

Also rebase is needed, FakeApi has mostly been removed, so no changes are needed on FakeProtoCommon.

I haven't done a more thorough review, but the newly added signatures look ok.

@aiuto
Copy link
Contributor

aiuto commented Jun 24, 2021

Friendly ping. This code has gone stale.
@cheister Can you address the concerns and update this or should we close it.

@cheister cheister force-pushed the proto-common-create-proto-info branch from bf1ef07 to 7d24cf1 Compare June 25, 2021 06:12
@cheister cheister changed the title Add proto_common.create_proto_info method to Starlark Add ProtoInfo constructor to Starlark Jun 25, 2021
@cheister
Copy link
Contributor Author

Thanks for looking at the change. The PR has been updated so it is now a ProtoInfo constructor instead of proto_common.createProtoInfo.

It probably still needs one or two more integration tests to make sure a ProtoInfo object built in Starlark will work along with native ProtoInfo objects.

@cheister cheister force-pushed the proto-common-create-proto-info branch from 7d24cf1 to e8c9773 Compare June 26, 2021 23:05
@cheister
Copy link
Contributor Author

I added an integration test that exposes a problem with the hidden :proto_compiler attribute on the native ProtoLibrary Rule. Apparently BazelJavaProtoAspect is expecting the :proto_compiler attribute to be defined on the rule that creates the ProtoInfo object but there is no way to create that attribute in Starlark because it starts with colon. I'm not sure if we should remove the :proto_compiler attribute or fix BazelJavaProtoAspect to fallback to a different protoc when the rule doesn't have the hidden :proto_compiler attribute.

@oquenchil
Copy link
Contributor

Hello, thank you very much for this change. We are in the process of starlarkifying all the rules right now. We haven't reached proto rules yet but will do so in Q4. As part of that starlarkification process the ProtoInfo constructor will be in Starlark too. But for now in order not to interfere with that process we rather not expose any APIs publicly. Count on next year this being possible though.

Thanks!

@oquenchil oquenchil closed this Jul 14, 2021
@cheister
Copy link
Contributor Author

@oquenchil The starlarkification process has been promised for 3 years now, is there any work actually started for the proto rules? The point of having a ProtoInfo constructor in Starlark is so you could transition from the native proto rules to the Starlark rules with the native ProtoInfo object. Is the plan to try to move everyone to a Starlark built ProtoInfo object all at once? That seems like that will break backwards compatibility.

@oquenchil
Copy link
Contributor

Work on the proto rules should start during Q4 this year. Unlike previous Starlarkification promises we are actually moving forward this year and have already starlarkified a number of rules.

The plan is to have the current native rules in Starlark without any incompatible changes, the ProtoInfo constructor for the native provider will be in Starlark, then that will be replaced by a purely Starlark provider. We don't want to add public APIs before this happens precisely to avoid running into incompatible changes.

@cheister
Copy link
Contributor Author

cheister commented Jul 19, 2021

You say: the ProtoInfo constructor for the native provider will be in Starlark but that is exactly what this PR was trying to do? You need to add something to the Starlark API so you can create the native ProtoInfo provider in Starlark.

Unless you mean you're just going to move to a purely Starlark ProtoInfo provider all at once, which will break backwards compatibly with native rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes team-Rules-Server Issues for serverside rules included with Bazel untriaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants