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

export well known protos #1345

Merged
merged 1 commit into from
Mar 23, 2016

Conversation

smparkes
Copy link
Contributor

When we run protoc from within bazel, we need access to the well known protos, e.g., Any, so that protoc can include them.

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Mar 23, 2016

Are you using genrule to invoke protoc? Why not use the _proto_library rule implemented in protobuf.bzl?

@liujisi
Copy link
Contributor

liujisi commented Mar 23, 2016

LGTM

@smparkes
Copy link
Contributor Author

This is actually part of making protoc work for me from bazel. I have my own skylark extension to run protoc (handles, among other things, java) but will eventually try to submit a PR (if you'd like it/when I get a chance to clean it up.)

The current protoc defined in protobuf.bzl doesn't include access to the well known protos, e.g., Any, so trying to bazel run/bazel-bin won't work:

❯❯❯ ./bazel-bin/protoc --cpp_out=. foo.proto
google/protobuf/any.proto: File not found.
foo.proto: Import "google/protobuf/any.proto" was not found or had errors.
foo.proto:7:12: "google.protobuf.Any" is not defined.

Step one (I think ...) is to tell bazel these files are used elsewhere, e.g., by protoc. That's what I added the filegroup for: that way, should they change, the output of protoc is invalidated.

The second step is to pass them to protoc when it gets run. I've hacked that in my extension but am not happy with it: it adds a -I flag when it runs protoc but it to src which is less than great so I want to (eventually) improve that.

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Mar 23, 2016

LGTM

Thanks for the explanation.

@xfxyjwf xfxyjwf merged commit 8126912 into protocolbuffers:master Mar 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants