1. During the loading phase, bring the google/protobuf into your WORKSPACE 
so you can refer to it as @com_github_google_protobuf later.  The bazel 
convention is to have fully qualified names, flattening special characters 
to underscore.

git_repository(
  name = "com_github_google_protobuf",
  remote = "https://github.com/google/protobuf.git";,
  tag = "v3.0.0",
)

2. During the analysis phase, load the function in your BUILD file by 
referring to the skylark bzl filename.  
    As the protobuf repo has a BUILD file in the root (which defines it as 
a "package"), you need to refer to the 
    bzl relative to the package name.  That's why you need the colon. 

# You can also alias the function to whatever you want with 'foo = 
"cc_proto_library"'
load("@com_github_google_protobuf//:protobuf.bzl", "cc_proto_library")

# These are called "target pattern operators" IIRC
@ = names an external dependency that is loaded in WORKSPACE.
// = relative to the workspace root
: relative to package

3. Call it


cc_proto_library( 
 name = "alice", 
 srcs = ["alice.proto"], 
)

But then, where did the files go?  If it worked, they should be in $(bazel 
info bazel-genfiles)/protoa/alice.pb.h

I've been working on a set of rules for protobuf +/- gRPC 
at https://github.com/pubref/rules_protobuf.  Perhaps it will be of use to 
you.


On Monday, July 18, 2016 at 11:25:45 AM UTC-6, JI Ioannidis wrote:
>
> What is the sequence of magic incantations to create a cc_proto_library 
> rule? I have tried copying protobuf.bzl from the protobuf repo to the root 
> of my workspace, as well as some (at least a year old) .bzl files 
> referenced in this group, to no avail.
>
> My end goal is to have a BUILD file such as 
> $ *cat protoa/BUILD*  
> cc_proto_library( 
>  name = "alice", 
>  srcs = ["alice.proto"], 
> )
>
> then type 
>
> $ *bazel build //protoa:alice*
>
> and have it create the right .pb.h and .pb.cc files
>
> FWIW, I have already installed bazel at sha 42d8290 (compiled, bazel 
> binary copied to ~/bin/) and built and installed protobuf at sha b99577c. 
>
> Thanks!
>
> /ji
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to