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

Break dependency on protobuf.bzl from google/protobuf for C++ #92

Merged
merged 2 commits into from
Aug 8, 2018
Merged

Break dependency on protobuf.bzl from google/protobuf for C++ #92

merged 2 commits into from
Aug 8, 2018

Conversation

sesmith177
Copy link
Contributor

This replaces the use of cc_proto_library / proto_gen from the
@com_google_protobuf//:protobuf.bzl. The reason for doing so is that
newer versions of google/protobuf have changed cc_proto_library +
proto_gen so that they no longer work with pgv_cc_proto_library.

pgv_proto_library now takes a proto_library containing the protos
instead of a list of proto files. The approach for generating the protoc
command line arguments was taken from bazelbuild/rules_go

The py_proto_library imported from @com_google_protobuf//:protobuf.bzl
is used by Envoy, so we left it in.

Note: when integrating this commit with Envoy, we see the error:

2018/08/07 11:17:51 protoc-gen-go: error:[gatherer][file:envoy/config/trace/v2/trace.proto]proto package names should not be mixed in the same directory (envoy.api.v2, envoy.config.trace.v2)
--validate_out: protoc-gen-validate: Plugin failed with status code 1.

It looks like that error should be fixed by lyft/protoc-gen-star#28, however

This replaces the use of cc_proto_library / proto_gen from the
@com_google_protobuf//:protobuf.bzl. The reason for doing so is that
newer versions of google/protobuf have changed cc_proto_library +
proto_gen so that they no longer work with pgv_cc_proto_library.

pgv_proto_library now takes a proto_library containing the protos
instead of a list of proto files. The approach for generating the protoc
command line arguments was taken from bazelbuild/rules_go

The py_proto_library imported from @com_google_protobuf//:protobuf.bzl
is used by Envoy, so we left it in.

Signed-off-by: Andrew Keesler <akeesler@pivotal.io>
Signed-off-by: Amin Jamali <ajamali@pivotal.io>
Copy link
Contributor

@htuch htuch left a comment

Choose a reason for hiding this comment

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

This looks like a fantastic improvement; moving to proto_library inputs was the long term vision, nice to see it happening. @akonradi can you take a quick look and see how this aligns with earlier work that you did in this area?

@htuch htuch self-assigned this Aug 7, 2018
Copy link
Contributor

@akonradi akonradi left a comment

Choose a reason for hiding this comment

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

Cool, I'm glad we're moving towards using the native proto_library rules. A few nits but otherwise looking good.

"""Bazel rule to create a C++ protobuf validation library from proto source files
Args:
name: the name of the pgv_cc_proto_library.
proto: a single proto_library rule which contains the necessary .proto files. Note that this
Copy link
Contributor

Choose a reason for hiding this comment

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

Bazel's native cc_proto_library rule uses deps for the set of proto_library dependencies. It might be worth doing the same here, and using cc_deps or similar for C++ dependencies.

outputs=out_files,
arguments=args + [_proto_path(proto) for proto in protos],
executable=ctx.executable._protoc,
mnemonic="ProtoGenValidateCompile",
Copy link
Contributor

Choose a reason for hiding this comment

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

"Compile" seems inaccurate. What do you think about "CcGenerate"?

- change mnemonic to ProtoGenValidateCcGenerate
- accept array of proto_library rules as argument

Signed-off-by: Sam Smith <sesmith177@gmail.com>
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.

4 participants