Skip to content

Add cpp macros to append wrapped language info to xDS user agent#26189

Merged
markdroth merged 4 commits intogrpc:masterfrom
markdroth:xds_user_agent_wrapped_langs
Jun 8, 2021
Merged

Add cpp macros to append wrapped language info to xDS user agent#26189
markdroth merged 4 commits intogrpc:masterfrom
markdroth:xds_user_agent_wrapped_langs

Conversation

@markdroth
Copy link
Copy Markdown
Member

@nicolasnoble, can you please advise as to the best way to set this macro in the build system for C++? I assume that we'll need to add it for both bazel and cmake? Thanks!

CC @srini100 @yashykt

@markdroth markdroth added the release notes: no Indicates if PR should not be in release notes label May 6, 2021
@markdroth markdroth changed the title Add cpp macro to append wrapped language info to xDS user agent Add cpp macros to append wrapped language info to xDS user agent May 7, 2021
@nicolasnoble
Copy link
Copy Markdown
Contributor

Quick comment first:

all identifiers regardless of use that begin with either two underscores or an underscore followed by a capital letter are reserved names

so technically, _GRPC_XDS_USER_AGENT_VERSION_SUFFIX is reserved.

@nicolasnoble
Copy link
Copy Markdown
Contributor

In general, for Bazel and cmake, you'll want to add defines in the corresponding library target. Since the change you're doing does not need to propagate to the users of the library, the change is luckily less problematic than if it was to pollute the whole environment.

For bazel you want to use the local_defines attribute for the build target.

For cmake, that'd be add_definitions used like so. I don't think we could make it easy to only target the one library, but at the same time, I don't think it matters that much here.

@markdroth
Copy link
Copy Markdown
Member Author

It looks like there are going to be complications in setting this macro properly for C++, because bazel is used for both C++ and Python, and cmake is used for both C++ and C#, so in both cases, we need some way to set the macro conditionally.

@jtattermusch says that we can handle cmake by passing the defines to cmake from the scripts that are used to build C#. He said he'd send me a separate PR for that later this week.

Bazel will require more thought, because there's no obvious way to set the macros conditionally for a target that is common to both python and C++. So I think I'm going to try to handle that in a separate PR as well.

Let's move forward with this PR as-is, just providing the macros but not actually setting them. That way, the wrapped langs can start using this while we continue to figure out how to set it properly in bazel and cmake.

@markdroth
Copy link
Copy Markdown
Member Author

As per today's discussion, we'll leave these macros unset for C++, setting them only for wrapped languages when we know that we're building for those languages. This means that we'll be lumping in cases where we build python with bazel in with the C++ stats, but that's probably okay for now. We can always try to find a new way to optimize that later if we need more detail.

@markdroth
Copy link
Copy Markdown
Member Author

Known issues: #26019

@markdroth markdroth merged commit fbf3283 into grpc:master Jun 8, 2021
@markdroth markdroth deleted the xds_user_agent_wrapped_langs branch June 8, 2021 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release notes: no Indicates if PR should not be in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants