Fix C++ cleanup in Grpc.Tools#22895
Conversation
jtattermusch
left a comment
There was a problem hiding this comment.
I have trouble following the logic changes and making sure this doesn't break anything.
We really need to come up with some simple way of testing the .targets file, the lack of tests is making accepting any Grpc.Tools change difficult.
src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets
Outdated
Show resolved
Hide resolved
src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets
Outdated
Show resolved
Hide resolved
|
@jtattermusch @JunTaoLuo I updated the PR to use |
src/csharp/Grpc.Tools/build/_protobuf/Google.Protobuf.Tools.targets
Outdated
Show resolved
Hide resolved
|
|
||
| All ExpectedOutputs will be removed. --> | ||
| <Target Name="Protobuf_PrepareClean" Condition=" '@(Protobuf)' != '' "> | ||
| <Target Name="Protobuf_PrepareClean" Condition=" '@(Protobuf_Rooted)' != '' "> |
There was a problem hiding this comment.
Same here, I think it would make sense for Protobuf_PrepareClean to depend on _Protobuf_SetProtoRoot, especially since this target isn't prefixed with _ which generally signals that it could be called independently.
There was a problem hiding this comment.
Good point! I will change it.
There was a problem hiding this comment.
Are you still going to address this?
There was a problem hiding this comment.
See #22895 (comment)
We have two options how to fix it but both have downsides and would change either the current behavior or would by asymmetrical to how creation is currently done which feels a bit strange. Would be good to @JunTaoLuo‘s opinion on the two suggestions. (Or three, since keeping it this way is also one.)
There was a problem hiding this comment.
Let's leave as is for now and if needed, we can address in a followup PR.
|
@JunTaoLuo I looked into having I see two options here on how to solve it:
<Target Name="Protobuf_PrepareClean"
Condition=" '@(Protobuf)' != '' "
DependsOnTargets=" _Protobuf_SetProtoRoot;
_Protobuf_PrepareClean" />
<Target Name="_Protobuf_PrepareClean" Condition=" '@(Protobuf_Rooted)' != '' ">
<!-- Predict expected names. -->
<ProtoCompilerOutputs Condition=" '$(Language)' == 'C#' "
Protobuf="@(Protobuf_Rooted)"
Generator="$(Protobuf_Generator)">
<Output TaskParameter="PossibleOutputs" ItemName="Protobuf_ExpectedOutputs" />
</ProtoCompilerOutputs>
</Target>
<Target Name="Protobuf_PrepareClean"
DependsOnTargets=" _Protobuf_SetProtoRoot"
Condition=" '@(Protobuf)' != '' ">
<!-- Predict expected names. -->
<ProtoCompilerOutputs Condition=" '$(Language)' == 'C#' "
Protobuf="@(Protobuf_Rooted)"
Generator="$(Protobuf_Generator)">
<Output TaskParameter="PossibleOutputs" ItemName="Protobuf_ExpectedOutputs" />
</ProtoCompilerOutputs>
</Target>We have the same issue with Both ways would change the current behavior. So if someone is calling the target already with manually setting |
|
@JunTaoLuo @jtattermusch Any more input on this? Thanks for the valuable feedback so far! |
|
Adhoc distribtest run: sponge/ec2617f6-ed25-4bca-a3b6-cc1ddcc1df08 |
|
@Falco20019 can you update the PR description to match the reality? (right now it seems out of data). Also, why is this called "fix C++ cleanup"? - there doesn't seem anything that's specific to C++ codegen in this change. |
jtattermusch
left a comment
There was a problem hiding this comment.
I think with some very minor nits (see my new comments), this is looking good now.
Thanks for improving the clarity of the change, following what it does is now much easier.
I'll approve once the distribtests pass and my last comments are addressed.
It fixes the root that was missing for C++ cleanup. Right now, since the root was not set, the expected files are wrong and cleanup is not working for C++. So this really only is a fix for C++ as that’s the only language using the proto root in the expected output. I want to use the same logic also for C#. To be more precise, currently for creation the root is set through ProtoCompile, but for cleanup it was not, so the result was different for creation and cleanup. |
|
Another adhoc run (this time with rebased code to avoid an unrelated artifact breakage). |
|
The distribtests have passed: sponge/580024b2-08f1-472e-bc7a-3ba0f3aba111 |
The result of
Protobuf_ExpectedOutputsinProtobuf_PrepareCleanandProtobuf_PrepareCompileis different for out-of-path protos if noProtoRootwas given.This is, because
_Protobuf_SelectFilesis settingProtoRoot=%(RelativeDir)when building, but this is not set when cleaning up.This PR extracts the logic of settings the
ProtoRootfrom_Protobuf_SelectFilesinto_Protobuf_SetProtoRootand ensures, that the same files are expected for creation and cleanup. Since we are not filling a new item group but updating an existing one, we had to use update logic instead of include logic. Otherwise we would end up withProtobufhaving the same item twice, once withoutProtoRootand once with the setProtoRoot.CC @jtattermusch @kkm000