Skip to content

Fix properties in Grpc.Tools#22896

Merged
jtattermusch merged 1 commit intogrpc:masterfrom
Falco20019:grpc-tools-fix-env-variables
May 15, 2020
Merged

Fix properties in Grpc.Tools#22896
jtattermusch merged 1 commit intogrpc:masterfrom
Falco20019:grpc-tools-fix-env-variables

Conversation

@Falco20019
Copy link
Copy Markdown
Contributor

Protobuf_ToolsOs, Protobuf_ToolsCpu and Protobuf_ProtocFullPath are currently always overwritten by the environment variables without a checking-condition.

I added the checks so that it becomes possible to set them in the csproj as described (and expected) in the BUILD-INTEGRATION.md.

CC @jtattermusch @kkm000

* Protobuf_ToolsOs
* Protobuf_ToolsCpu
* Protobuf_ProtocFullPath
@jtattermusch jtattermusch self-assigned this May 8, 2020
@jtattermusch jtattermusch self-requested a review May 8, 2020 13:52
@jtattermusch jtattermusch added lang/C# release notes: yes Indicates if PR needs to be in release notes kokoro:run labels May 8, 2020
@@ -68,9 +68,9 @@

<PropertyGroup>
<!-- First try environment variable. -->
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment should be updated to say that environment variables don't override explicitly set values

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great catch! Would be good to know what is the intended behavior from @kkm000

Do we want env variables to overwrite props or do we want props to overwrite env? Dependent on that, we can also only overwrite the prop if env is not empty. This would also fix the bug of not being able to set it at all right now.

I‘m not sure if the use cases here. Maybe having it set in env for build servers? Then env should overwrite props.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe @jtattermusch also knows if we want to have ENV overwrite PROPS or the other way around to adjust the logic accordingly.

@jtattermusch
Copy link
Copy Markdown
Contributor

I'm actually not sure how important it is to use values from Protobuf_ToolsOs, Protobuf_ToolsCpu and Protobuf_ProtocFullPath properties (and not overwrite them with possibly empty env vars), because in 99.9% of cases the values are set a few lines later automatically anyway.
Therefore, I'm actually not convinced that this PR is very useful.

@Falco20019
Copy link
Copy Markdown
Contributor Author

Falco20019 commented May 11, 2020

According to https://github.com/grpc/grpc/blob/master/src/csharp/BUILD-INTEGRATION.md#ill-investigate-that-when-i-have-time-i-just-want-to-run-protoc-as-i-did-before these are set and I assumed that I could also set them like most of the other props documented there. But it‘s only possible by setting the env or prop as PROTOBUF_PROTOC which is not documented.

One use case I was thinking of was redefining it on a build server by using a Directory.Build.props file.

I don’t need it currently, so I‘m fine with keeping the current behavior. I was just wondering that these are the only 3 props that can’t be overwritten in the whole package and since gRPC_PluginFullPath CAN be manually set (see

<gRPC_PluginFullPath Condition=" '$(gRPC_PluginFullPath)' == '' and '$(Protobuf_ToolsOs)' == 'windows' "
), so this felt unintentionally missed.

But I do see your point that most users will never touch it. And those in need might also check the target file and find it out like I did.

Copy link
Copy Markdown
Contributor

@jtattermusch jtattermusch left a comment

Choose a reason for hiding this comment

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

As said, I'm not sure how useful this is, but what you're saying makes sense, so LGTM.

@jtattermusch
Copy link
Copy Markdown
Contributor

@apolcyn please add second LGTM.

@jtattermusch jtattermusch merged commit 163fcfa into grpc:master May 15, 2020
@Falco20019 Falco20019 deleted the grpc-tools-fix-env-variables branch May 19, 2020 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang/C# release notes: yes Indicates if PR needs to be in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants