Comments (5)
Looping in @hochhaus (bazelbuild/rules_closure#89) for possible review.
from rules_protobuf.
@pcj What are your goals for this project? Are you looking for full gRPC support or just basic go protobuf support for interop with rules_closure style JS?
If the latter, it might be easier to use a very light weight stub. For example, I'm using:
ahochhaus@ahochhaus-pc:~/ll$ cat go_proto_library.bzl
load("@io_bazel_rules_go//go:def.bzl", "go_library")
def go_proto_library(
name,
srcs,
visibility = None,
testonly = 0,
protoc = Label("@io_bazel_rules_closure//third_party/protobuf:protoc_bin"),
protoc_gen_go = Label("@com_github_golang_protobuf//:protoc_gen_go")):
cmd = [
"$(location %s)" % protoc,
"--plugin=protoc-gen-go=$(location %s)" % protoc_gen_go,
"--go_out=$(GENDIR)",
]
cmd += ["$(location " + src + ")" for src in srcs]
go_srcs = [src.rsplit('.', 1)[0] + ".pb.go" for src in srcs]
native.genrule(
name = name + "_gen",
srcs = srcs,
testonly = testonly,
visibility = visibility,
message = "Generating Go Protocol Buffer file",
outs = go_srcs,
tools = [protoc, protoc_gen_go],
cmd = " ".join(cmd),
)
go_library(
name = name,
srcs = go_srcs,
deps = [
str(Label("@com_github_golang_protobuf//:proto")),
],
)
with a BUILD file that looks like
...
load("//:go_proto_library.bzl", "go_proto_library")
...
go_proto_library(
name = "pb",
srcs = ["pb/pb.proto"],
)
and then importing that package in go with:
import "<prefix>/pb"
(Obviously name it something better than "pb".)
I'm hesitant to put much time into a code review until we have a plan for where it can be upstreamed for general use. For example, if @yugui would consider accepting go_proto_library
support in rules_go then I would happily send a change.
However, based upon bazelbuild/rules_closure#89 I think all of the bazel protobuf support will land in upstream protobuf eventually. So I'm not sure if it makes sense to store in rules_go for the time being.
What are your thoughts Yuki Yugui Sonoda?
from rules_protobuf.
Thanks @hochhaus. My goal is ultimately to provide comprehensive protobuf support for multiple languages, with gRPC support. Based on my review of sources in getting this started, it's a highly fragmented area given the diversity of tools and existing build infrastructures.
As for golang, I'm still getting my head around how package names, import statements, go_prefix, and go_library all interact. Specifically, the protoc-gen-go plugin has this concept of an ImportMap that is exposed via the option format --go_out=Mfoo=bar:dirname
.
It's not too hard to generate the *.pb.go
files, but have not been able to line it all up to get those files to compile in a different source file that imports them.
from rules_protobuf.
Andy @hochhaus if you send email to [email protected] I will cc: you on email thread with @yugui.
from rules_protobuf.
Note: golang support is now provided, but there are some limitations. See #4.
from rules_protobuf.
Related Issues (20)
- Can't build GRPC when using cpp_proto_repositories HOT 5
- py_proto_library fails when taking input from a genrule HOT 1
- Not work with rules_go v0.13.0 HOT 3
- Dart support? HOT 4
- Go rules HOT 1
- Can't resolve @go_googleapis//google/api HOT 1
- Custom protoc generators HOT 1
- using imports in py_proto_compile fails: _pb2.py and pb2_grpc.py not created HOT 1
- gogo_proto_library with the "well known types" (google/protobuf) HOT 12
- Non repeatable build for grpc_cli HOT 1
- Update rules_protobuf to rules_go 0.16.0 HOT 7
- Addition of protoc-gen-grpc-web HOT 2
- 32-bit C++ compilation HOT 3
- including well known protos in ruby_proto_compile HOT 4
- support latest grpc version HOT 1
- Bazel deprecated native http_archive rule HOT 2
- Unable to load package for 'org_pubref_rules_protobuf/java/rules.bzl' HOT 1
- name 'FileType' is not defined HOT 2
- BUG: Error in label: label() got unexpected keyword argument 'single_file' HOT 2
- file '//protobuf:rules.bzl' does not contain symbol 'proto_compile'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rules_protobuf.