pubref / rules_proto Goto Github PK
View Code? Open in Web Editor NEWMoved to https://github.com/stackb/rules_proto
Moved to https://github.com/stackb/rules_proto
Say I have 2 proto files sitting in //some-package/
//some-package/A.proto
which imports B.proto
(without some-package
as prefix)//some-package/B.proto
Then I compile the proto_library in
//some-package/BUILD`, like the following:
proto_library(
name = "a-proto",
srcs = ["a-proto"]
proto_source_root = "some-package"
)
proto_library(
name = "b-proto",
srcs = ["b-proto"]
proto_source_root = "some-package"
)
The above works well because proto_source_root
, which allows us to not have to import one proto file into another using the full path relative from WORKSPACE.
Then I do <lang>_grpc_compile
, let's say for java_grpc_compile
:
load("@org_pubref_rules_proto//java:compile.bzl", "java_grpc_compile")
java_grpc_compile(
name = "java-proto",
deps = [":a-proto"],
)
And here it breaks. java_grpc_compile
fails to compile with error:
B.proto: file not found.
some-package/A.proto: Import "B.proto" was not found or had errors.
So basically, A.proto
cannot find B.proto
. However, when I replace the import statement in A.proto
with import some-package/B.proto
and remove usage of proto_source_root
in proto_library
everything works, but we really don't want to do this for many reasons.
Does anyone know what could be the cause and how to work around this?
Could you add a license?
Thanks!
Hi,
In the README.md it simply says that we need to add {lang}:deps.bzl
to our WORKSPACE
file. For example:
git_repository(
name = "org_pubref_rules_proto",
remote = "https://github.com/pubref/rules_proto",
commit = "27da2e7af9e4a1c43c584be2f05be8a301a642b6",
)
load("@org_pubref_rules_proto//java:deps.bzl", "java_grpc_compile")
java_grpc_compile()
However, trying to run java_grpc_compile
after this leads to an error:
ERROR: /Users/haikalpribadi/Workspace/repos/graknlabs/grakn/protocol/BUILD:20:1: every rule of type proto_compile implicitly depends upon the target '@com_google_protobuf//:protoc', but this target could not be found because of: no such package '@com_google_protobuf//'
So then I added @com_google_protobuf
as a dependency:
http_archive(
name = "com_google_protobuf",
sha256 = "0a4c6d0678eb2f063df332cff1a41647ef692c067b5cfb19e51bca778e79d9e0",
strip_prefix = "protobuf-3.6.1",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protobuf-all-3.6.1.zip"],
)
Now I get a different error:
ERROR: /private/var/tmp/_bazel_haikalpribadi/3cdeaa1301f056ec7b4e7ee46bda5c79/external/com_github_grpc_grpc/BUILD:2039:1: no such target '//external:protobuf_headers': target 'protobuf_headers' not declared in package 'external' defined by /Users/haikalpribadi/Workspace/repos/graknlabs/grakn/WORKSPACE and referenced by '@com_github_grpc_grpc//:grpc++_config_proto'
ERROR: /private/var/tmp/_bazel_haikalpribadi/3cdeaa1301f056ec7b4e7ee46bda5c79/external/com_github_grpc_grpc/BUILD:388:1: no such target '//external:protobuf_clib': target 'protobuf_clib' not declared in package 'external' defined by /Users/haikalpribadi/Workspace/repos/graknlabs/grakn/WORKSPACE and referenced by '@com_github_grpc_grpc//:grpc_plugin_support'
So I suspected that I'm missing @com_github_grpc_grpc
, so I added:
git_repository(
name = "com_github_grpc_grpc",
remote = "https://github.com/grpc/grpc",
tag = "v1.15.1"
)
However, it still gives the error as shown above, so I checked in your WORKSPACE
file and saw that you had the following two lines to load grpc_deps.bzl
, and I copied them into my WORKSPACE
file.
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", com_github_grpc_grpc_bazel_grpc_deps = "grpc_deps")
com_github_grpc_grpc_bazel_grpc_deps()
Now everything works fine, and the proto files compile. However, I'm worried that I'm doing something wrong/unnecessary above, as you did not put them in your documentation. Thus, my questions are:
WORKSPACE
? Because I thought {lang}:deps.bzl
was going to take care of it. But if it is needed, ...python_grpc_compile
fails to compile generated .proto
file (it's copied into sandbox, but not used in compilation)
Example can be found here: vmax/org_pubref_rules_proto_bug_sample
ghost:rules_proto_example vmax$ bazel build //:routeguide_gen_grpc
INFO: Analysed target //:routeguide_gen_grpc (0 packages loaded).
INFO: Found 1 target...
ERROR: /Users/vmax/work/GraknLabs/rules_proto_example/BUILD:35:1: error executing shell command: 'bazel-out/host/bin/external/com_google_protobuf/protoc --descriptor_set_out=bazel-out/darwin-fastbuild/genfiles/routeguide_gen_grpc/descriptor.source.bin --proto_path=bazel-out/darwin-fastbuild/gen...' failed (Exit 1)
bazel-out/darwin-fastbuild/genfiles/routeguide_gen.proto: No such file or directory
Target //:routeguide_gen_grpc failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0,235s, Critical Path: 0,05s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
I've followed the instructions in README.md but node_grpc_compile
simply fails without any detailed error message. The error simply says "<Filename>_grpc_pb.js" was not created
, for 2 out of 4 of my files, and I can't get more error message even when using --verbose_failures
.
I've isolated the issue on a branch on my repo for you to reproduce it:
https://github.com/haikalpribadi/grakn/tree/bazel-init-pubref-rules-proto
Once you clone the repo, run bazel build //protocol:client-node-proto
to reproduce the problem.
What are the chances we can de-fork https://github.com/stackb/rules_proto, so that we have access to code search, issues, etc. Unless that is a design choice ๐.
Thanks,
Lucas
Hi @pcj, in rules_protobuf/protobuf we can set output_to_workspace
to output the GRPC files into the development workspace.
How can we do this with the new rules_proto
?
Hi @pcj,
I'm trying to use java_grpc_library
and hitting my head against the wall. :/
In //dependencies/compilers/dependencies.bzl
I have:
def grpc_dependencies():
...
native.git_repository(
name = "org_pubref_rules_proto",
remote = "https://github.com/pubref/rules_proto",
commit = "27da2e7af9e4a1c43c584be2f05be8a301a642b6",
)
In WORKSPACE
I loaded:
load("//dependencies/compilers:dependencies.bzl", "grpc_dependencies")
grpc_dependencies()
load("@org_pubref_rules_proto//java:deps.bzl", "java_grpc_compile")
java_grpc_compile()
Then in the //protocol/BUILD
I do:
load("@org_pubref_rules_proto//java:library.bzl", "java_grpc_library")
java_grpc_library(
name = "client-java-proto",
deps = [
"//protocol/session:session-proto",
"//protocol/keyspace:keyspace-proto",
],
visibility = [
"//server:__subpackages__",
"//client-java:__subpackages__",
]
)
Then when i run bazel build //protocol:client-java-proto
i get this error:
ERROR: /Users/haikalpribadi/Workspace/repos/graknlabs/grakn/protocol/BUILD:20:1: no such package 'java': BUILD file not found on package path and referenced by '//protocol:client-java-proto'
Do you know what I'm missing here? Bazel can't seem to find the java
package in rules_proto
which is clearly sitting there at the root!
I've pushed it up to my repo, it's on bazel-init-java-grpc-library-fails
. https://github.com/haikalpribadi/grakn/tree/bazel-init-java-grp-library-fails
Can you help figure out what's going on?
There are some external deps referencing https://github.com/uber/prototool that are not found in the workspace:
Lines 5 to 6 in 4a1ebfa
error message:
$ bazel build //...
Starting local Bazel server and connecting to it...
..................
INFO: SHA256 (https://github.com/google/protobuf/archive/48cb18e5c419ddd23d9badcfe4e9df7bde1979b2.tar.gz) = f5a35e17fb07f3b13517264cd17a089636fcbb2912f9df7bef7414058969a8d2
ERROR: /Users/ricky/vsco/rules_proto/BUILD.bazel:2:1: no such package '@com_github_uber_prototool_darwin//file': The repository could not be resolved and referenced by '//:prototool'
ERROR: Analysis of target '//:prototool' failed; build aborted: no such package '@com_github_uber_prototool_darwin//file': The repository could not be resolved
INFO: Elapsed time: 26.527s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (38 packages loaded)
currently loading: @io_bazel_rules_go//proto
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.