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

Need to expose generated protobuf C++ headers #1959

Merged
merged 1 commit into from
Oct 13, 2016

Conversation

abergmeier-dsfishlabs
Copy link
Contributor

… so they can actually be accessed from other libraries.

@grpc-kokoro
Copy link

Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok to test.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@smr277
Copy link

smr277 commented Aug 25, 2016

How would you use this with, say, a cc_library? Would you just include it in deps as ":<proto_library>"?

@abergmeier
Copy link

Would you just include it in deps as ":"?

Exactly:

cc_proto_library(
  name = "proto_foo",
)

cc_library(
  name = "foo",
  deps = [
    ":proto_foo",
  ]

I actually use it like this when working downstream with Bazel workers. That's what it is needed for.

@abergmeier-dsfishlabs
Copy link
Contributor Author

We signed it!

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Sep 29, 2016

@abergmeier You probably need to make another pull request using that account that signed the CLA?

@abergmeier-dsfishlabs
Copy link
Contributor Author

abergmeier-dsfishlabs commented Oct 4, 2016

On the bazel repo it was only necessary to run the cla-bot again. Tadaaaaa.

@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no labels Oct 4, 2016
@abergmeier-dsfishlabs
Copy link
Contributor Author

@davidzchen So are you tracking this manually then?

@abergmeier-dsfishlabs
Copy link
Contributor Author

Anyone looking at that?

@grpc-kokoro
Copy link

Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok for us to run on our infrastructure.

@xfxyjwf xfxyjwf merged commit 993d604 into protocolbuffers:master Oct 13, 2016
@xfxyjwf
Copy link
Contributor

xfxyjwf commented Oct 13, 2016

LG. Thanks!

@abergmeier-dsfishlabs abergmeier-dsfishlabs deleted the feature/cpp branch October 14, 2016 07:15
@abergmeier-dsfishlabs
Copy link
Contributor Author

@davidzchen ping

@ghost
Copy link

ghost commented Nov 4, 2016

For others who are trying to integrate C++ protobufs using Bazel into their own projects. I was able to invoke protobuf's protobuf.bzl file with the following recipe:

Under WORKSPACE add protobuf repo:

new_local_repository(
    name = "protobuf",
    build_file = "third_party/protobuf/BUILD",
    path = "third_party/protobuf"
)

Under your BUILD bazel file in your local project:

load("@protobuf//:protobuf.bzl", "cc_proto_library")
cc_proto_library(
  name = "my_proto",
  srcs = ["my.proto"],
  default_runtime = "@protobuf//:protobuf",
  protoc = "@protobuf//:protoc",
  visibility = ["//visibility:public"],
)

Then, in the command line, simply do: bazel build :my_proto

... and Bazel will automatically generate the file. When including headers, make sure to include relative to where the WORKSPACE file is located. For me, to access the autogenerated protobuf files, I did:

#include "lib/my_proto.pb.h"

As noted in the protobuf.bzl file, this is a temporary workaround until Bazel has general support for the proto_library() command.

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.

6 participants