Git Product home page Git Product logo

rules_protobuf's People

Contributors

achew22 avatar bocon13 avatar bzz avatar cheister avatar douglas-reid avatar gsf avatar jacobstr avatar jasonps01 avatar jwahlin avatar kellycampbell avatar lx223 avatar mapx avatar mattmoor avatar maverick-crank-grey avatar mikesamuel avatar mingkaic avatar nelhage avatar pcj avatar pedrokiefer avatar perezd avatar prestonvanloon avatar promiseofcake avatar raraujosc avatar tcnghia avatar timpalpant avatar vladmos avatar wiktortomczak avatar ynh avatar zetten avatar zhexuany avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rules_protobuf's Issues

python example not working

Hi,

I'm in the process of writing a python grpc service so I'm using the example/helloworld as a reference (which by the way was super helpful and helped me get a java grpc service building and running with bazel).

I tried to run my python grpc service but I got a "No module named grpc" ImportError.

So, I did a fresh git clone of the rules_protobuf repo (I've tried both master and 0.7.0) and when I tried to run the python client like so:
bazel run //examples/helloworld/python:greeter_client

I get a matching error

Target //examples/helloworld/python:greeter_client up-to-date:
  bazel-genfiles/examples/helloworld/proto/helloworld_pb2.py
  bazel-bin/examples/helloworld/python/greeter_client
INFO: Elapsed time: 189.527s, Critical Path: 30.49s

INFO: Running command line: bazel-bin/examples/helloworld/python/greeter_client
Traceback (most recent call last):
  File "/private/var/tmp/_bazel_nikos/5722d11b74c80b41ea06388f34041080/execroot/rules_protobuf_original/bazel-out/local-fastbuild/bin/examples/helloworld/python/greeter_client.runfiles/org_pubref_rules_protobuf/examples/helloworld/python/greeter_client.py", line 34, in <module>
    import grpc
ImportError: No module named grpc
ERROR: Non-zero return code '1' from command: Process exited with status 1.

In Java the example added certain compile time dependencies which are not present in the python example.

I wish I had more intimate knowledge of bazel to figure this out. Any help in fixing the example would be greatly appreciated.

Invalid branch, tag, or commit: Ref tags/v0.7.1

I tried to use v0.7.1 by

git_repository(
    name = "org_pubref_rules_protobuf",
    remote = "https://github.com/pubref/rules_protobuf",
    tag = "v0.7.1",
)

, but I got the following build error.

ERROR: com.google.devtools.build.lib.packages.BuildFileContainsErrorsException: error loading package '': Encountered error while reading extension file 'go/rules.bzl': no such package '@org_pubref_rules_protobuf//go': Invalid branch, tag, or commit: Ref tags/v0.7.1 can not be resolved.

Depends on a proto lib with well known protos

Hello,

I have a proto lib A that imports descriptor.proto and a proto lib B that depends on A.

go_proto_library(
    name = "a_proto_go",
    importmap = {
        "google/protobuf/descriptor.proto": "github.com/golang/protobuf/protoc-gen-go/descriptor",
    },
    imports = [
        "../../external/com_github_google_protobuf/src",
    ],
    protos = ["x/a.proto"],
    deps = [
      "@com_github_golang_protobuf//protoc-gen-go/descriptor:go_default_library",
    ],
)

go_proto_library(
    name = "b_proto_go",
    protos = ["x/b.proto"],
    deps = [
        ":a_proto_go",
    ],
)

I could compile a_proto_go, but for b_proto_go I had to add the same imports to compile.
Is this expected? Is there any way to use the imports of the dependencies automatically?

Thanks,

Cannot build, anymore (java_proto_library)

Hey,

I've been at this for several hours and honestly don't remember what started it, but as of today, java_proto_library stopped working on my machine.

I have installed the latest bazel (https://github.com/bazelbuild/bazel, tag 0.4.0).
I have incremented the version of pubref/rules_protobuf I use.

WORKSPACE

git_repository(
  name = "org_pubref_rules_protobuf",
  remote = "https://github.com/pubref/rules_protobuf",
  tag = "v0.7.0",
)

BUILD

load("@org_pubref_rules_protobuf//java:rules.bzl", "java_proto_library")

java_proto_library(
  name = "my_proto",
  protos = ["my_proto.proto"],
  verbose = 1,
)

Output

 $ bazel build src/main/project/... src/test/project/...
WARNING: /home/user/.cache/bazel/_bazel_user/00bb1210de2173919b75bf7db0a13118/external/org_pubref_rules_protobuf/protobuf/internal/proto_compile.bzl:383:5: 
************************************************************
cd $(bazel info execution_root) && bazel-out/host/bin/external/com_github_google_protobuf/protoc \ 
--descriptor_set_out=bazel-out/local-fastbuild/genfiles/src/main/project/module/model/my_proto.pb.descriptor_set \ 
--java_out=bazel-out/local-fastbuild/genfiles/src/main/project/module/model/my_proto.pb_java.jar \ 
--plugin=protoc-gen-grpc-java=bazel-out/host/genfiles/external/org_pubref_rules_protobuf/java/protoc_gen_grpc_java \ 
--grpc-java_out=bazel-out/local-fastbuild/genfiles/src/main/project/module/model/my_proto.pb_java.jar \ 
--proto_path=. \ 
src/main/project/module/model/my_proto.proto
************************************************************
src/main/project/module/model/my_proto.pb_java.jar
src/main/project/module/model/my_proto.pb.descriptor_set
************************************************************
.
INFO: Found 19 targets...
ERROR: /home/user/Source/Project/src/main/project/module/model/BUILD:5:1: error executing shell command: 'bazel-out/host/bin/external/com_github_google_protobuf/protoc --descriptor_set_out=bazel-out/local-fastbuild/genfiles/src/main/project/module/model/my_proto.pb.descriptor_set --java_out=bazel-out/loc...' failed: linux-sandbox failed: error executing command /home/user/.cache/bazel/_bazel_user/00bb1210de2173919b75bf7db0a13118/execroot/Project/_bin/linux-sandbox ... (remaining 5 argument(s) skipped).
/bin/bash: bazel-out/host/bin/external/com_github_google_protobuf/protoc: No such file or directory
INFO: Elapsed time: 21.015s, Critical Path: 0.95s

And finally,

$ cd `bazel info execution_root`
$ pwd
/home/user/.cache/bazel/_bazel_user/00bb1210de2173919b75bf7db0a13118/execroot/Project
$ ls bazel-out/host/
genfiles

I'm really quite perplexed. Any help would be appreciated.

bazel info fails on linux

Hi, thank you for an awesome work providing useful examples using Bazel+gRPC in polyglot environment.

After cloning this repository on linux though, bazel info fails for me with:

bazel info
ERROR: /.../rules_protobuf/WORKSPACE:113:1: Cannot redefine repository after any load statement in the WORKSPACE file (for repository 'org_pubref_rules_protobuf').
ERROR: Error evaluating WORKSPACE file.
ERROR: no such package '@local_config_xcode//': error loading package 'external': Could not load //external package.

Am I doing something wrong?

$bazel version

Build label: 0.4.4- (@non-git)
Build target: bazel-out/local-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Feb 10 17:35:16 2017 (1486748116)
Build timestamp: 1486748116

Thanks again.

Python protobuf dep

Using py_binary or py_library with a dependency of a py_proto_compile build doesn't work with the error does not have mandatory provider 'py'.
Forked the repo and working on it - but I really have no idea what's wrong atm :P.

gRPC Gateway w/ Java

Hi All,

I am trying to compile the following protocol buffer into a java library:

syntax = "proto3";
package archon.service;

option java_multiple_files = true;
option java_package = "com.komputent.archon";

import "google/api/annotations.proto";

message LoginRequest {
  string name = 1;
}

message LoginResponse {
  string jwt = 2;
}

service Archon {
    // RPC Methods for Users.
    rpc Login(LoginRequest) returns (LoginResponse) {
        option (google.api.http) = {
            post: "/archon/v1/client/login"
            body: "*"
        };
    }
}

My BUILD file looks like:

java_proto_library(
  name = "archon_java_proto",
  protos = [
      "archon.proto",
  ],
  with_grpc = True,
)

But it says that it is is missing "google/api/annotations.proto". I was curious how to include it?

output can't be checked with cc_proto_library

I have a local repository with my our BUILD file.

new_local_repository(
    name = "pb_schema",
    path = __workspace_dir__ + "/pb_schema",
    build_file = "BUILD.pb_schema",
)

BUILD.pb_schema:

cc_proto_library(
    name = "proto",
    protos = ["a/b/c.proto"],
    deps = ["@protobuf//:cc_wkt_protos"],
    with_grpc = True,
    verbose=2,
)

But BUILD failed with

output 'external/pb_schema/c.pb.h' was not created.
...

The generated files are in external/pb_schema/a/b/c.pb.h

I also tried new_local_repository with path = __workspace_dir__ + "/pb_schema/proto/snapmind",, but it didn't work either

bazel-out/local-fastbuild/genfiles/external/pb_schema/c.grpc.pb.cc:5:45: fatal error: external/pb_schema/c.pb.h: No such file or directory
 #include "external/pb_schema/c.pb.h"

gRPC Gateway failing due to missing pb.gw.go files

gRPC Gateway library failing with proto imports A -> B -> C. Possibly even just A -> B.

โžœ  workspace git:(master) โœ— bazel build //projects/proto/test:test-webhooks-grpc-gateway
WARNING: /home/preston/.cache/bazel/_bazel_preston/7fcd27cc7c3bb4755396ba74e5927be1/external/org_pubref_rules_protobuf/protobuf/internal/proto_compile.bzl:423:5: proto_compile projects/proto/test/BUILD:test-webhooks-grpc-gateway.
WARNING: /home/preston/.cache/bazel/_bazel_preston/7fcd27cc7c3bb4755396ba74e5927be1/external/org_pubref_rules_protobuf/protobuf/internal/proto_compile.bzl:267:5: go_importmap: {"google/api/annotations.proto": "github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api", "projects/proto/test/test-grpc-gateway.proto": "github.com/pubref/rules_protobuf/projects/proto/test/test-webhooks-grpc-gateway", "projects/proto/test/test-resource.proto": "github.com/pubref/rules_protobuf/projects/proto/test/test-webhooks-grpc-gateway", "projects/proto/test/test-webhook-messages.proto": "github.com/pubref/rules_protobuf/projects/proto/test/test-webhooks-grpc-gateway"}.
WARNING: /home/preston/.cache/bazel/_bazel_preston/7fcd27cc7c3bb4755396ba74e5927be1/external/org_pubref_rules_protobuf/protobuf/internal/proto_compile.bzl:390:5: 
************************************************************
cd $(bazel info execution_root) && bazel-out/host/bin/external/com_github_google_protobuf/protoc \ 
--descriptor_set_out=bazel-out/local-fastbuild/genfiles/projects/proto/test/test-webhooks-grpc-gateway.descriptor_set \ 
--plugin=protoc-gen-grpc-gateway=bazel-out/host/bin/external/com_github_grpc_ecosystem_grpc_gateway/protoc-gen-grpc-gateway/protoc-gen-grpc-gateway \ 
--grpc-gateway_out=Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,Mprojects/proto/test/test-grpc-gateway.proto=github.com/pubref/rules_protobuf/projects/proto/test/test-webhooks-grpc-gateway,Mprojects/proto/test/test-resource.proto=github.com/pubref/rules_protobuf/projects/proto/test/test-webhooks-grpc-gateway,Mprojects/proto/test/test-webhook-messages.proto=github.com/pubref/rules_protobuf/projects/proto/test/test-webhooks-grpc-gateway:bazel-out/local-fastbuild/genfiles \ 
--proto_path=external/com_github_google_protobuf/src/ \ 
--proto_path=external/com_github_grpc_ecosystem_grpc_gateway/third_party/googleapis/ \ 
--proto_path=. \ 
projects/proto/test/test-grpc-gateway.proto \ 
projects/proto/test/test-resource.proto \ 
projects/proto/test/test-webhook-messages.proto
************************************************************
projects/proto/test/test-grpc-gateway.pb.gw.go
projects/proto/test/test-resource.pb.gw.go
projects/proto/test/test-webhook-messages.pb.gw.go
projects/proto/test/test-webhooks-grpc-gateway.descriptor_set
************************************************************
.
INFO: Found 1 target...
ERROR: /home/preston/workspace/projects/proto/test/BUILD:24:1: output 'projects/proto/test/test-resource.pb.gw.go' was not created.
ERROR: /home/preston/workspace/projects/proto/test/BUILD:24:1: output 'projects/proto/test/test-webhook-messages.pb.gw.go' was not created.
ERROR: /home/preston/workspace/projects/proto/test/BUILD:24:1: not all outputs were created or valid.
Target //projects/proto/test:test-webhooks-grpc-gateway failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.218s, Critical Path: 0.08s

but if you ls bazel-genfiles/projects/proto/test then you see some files do exist:

โžœ  workspace git:(master) โœ— ls bazel-genfiles/projects/proto/test                          
test-grpc-gateway.pb.go     test-resource.pb.go          test-webhooks-grpc-gateway.descriptor_set     test-webhooks-grpc-gateway.pb.descriptor_set
test-grpc-gateway.pb.gw.go  test-webhook-messages.pb.go  test-webhooks-grpc-gateway.gw.descriptor_set 

The protos are importing like this:

test-grpc-gateway.proto imports test-webhook-messages.proto
test-webhook-messages.proto imports test-resource.proto

(A -> B -> C)

So the build definition is something like:

grpc_gateway_proto_compile(
    name = "test-webhooks-grpc-gateway",
    imports = [
        "external/com_github_google_protobuf/src/",
        "external/com_github_grpc_ecosystem_grpc_gateway/third_party/googleapis/",
    ],
    inputs = [
        "@com_github_google_protobuf//:well_known_protos",
       "@com_github_grpc_ecosystem_grpc_gateway//third_party/googleapis/google/api:go_default_library_protos",
    ],
    protos = [
        "test-grpc-gateway.proto",
        "test-resource.proto",
        "test-webhook-messages.proto",
    ],
    verbose = 1,
)

Same results with grpc_gateway_proto_library.

`importmap` for grpc_gateway_proto_library not applied for gateway

I have a very simple folder structure to test this:

  • $GOPATH/src/myproject
    • WORKSPACE
    • BUILD
    • importmap_test/
      • models/
        • BUILD
        • entity.proto
      • service/
        • BUILD
        • service.proto

The service BUILD file is:

package(default_visibility = ["//visibility:public"])

load("@org_pubref_rules_protobuf//grpc_gateway:rules.bzl", "grpc_gateway_proto_library")

grpc_gateway_proto_library(
    name = "test_service",
    protos = [
        "service.proto",
    ],
    deps = [
        "//importmap_test/models:entity",
        "@com_github_golang_protobuf//:ptypes/empty",
    ],
    importmap = {
      "importmap_test/models/entity.proto": "myproject/importmap_test/models/entity",
    },
    imports = ["external/com_github_google_protobuf/src"],
    verbose = 1,
)

However, when I try and compile this, it results in an error when attempting to build service.pb.gw.go, as it is not able to resolve my imports properly. When inspecting the verbose output, it seems the importmap is not making it's way to the grpc-gateway-out flag.

Here is the verbose output:

WARNING: /private/var/tmp/_bazel_sathyp/cab60e9d7b691e917cf60382fa182992/external/bazel_tools/tools/osx/xcode_configure.bzl:91:5: Invoking xcode-locator failed, return code 1, stderr: .
WARNING: /private/var/tmp/_bazel_sathyp/cab60e9d7b691e917cf60382fa182992/external/org_pubref_rules_protobuf/protobuf/internal/proto_compile.bzl:380:5: 
************************************************************
cd $(bazel info execution_root) && bazel-out/host/bin/external/com_github_google_protobuf/protoc \ 
--descriptor_set_out=bazel-out/local-fastbuild/genfiles/importmap_test/service/test_service.gw.descriptor_set \ 
--plugin=protoc-gen-grpc-gateway=bazel-out/host/bin/external/com_github_grpc_ecosystem_grpc_gateway/protoc-gen-grpc-gateway_bin \ 
--grpc-gateway_out=bazel-out/local-fastbuild/genfiles \ 
--proto_path=external/com_github_google_protobuf/src \ 
--proto_path=. \ 
--proto_path=external/com_github_grpc_ecosystem_grpc_gateway/third_party/googleapis/ \ 
--proto_path=external/com_github_google_protobuf/src/ \ 
importmap_test/service/service.proto
************************************************************
importmap_test/service/service.pb.gw.go
importmap_test/service/test_service.gw.descriptor_set
************************************************************
.
WARNING: /private/var/tmp/_bazel_sathyp/cab60e9d7b691e917cf60382fa182992/external/org_pubref_rules_protobuf/protobuf/internal/proto_compile.bzl:380:5: 
************************************************************
cd $(bazel info execution_root) && bazel-out/host/bin/external/com_github_google_protobuf/protoc \ 
--descriptor_set_out=bazel-out/local-fastbuild/genfiles/importmap_test/service/test_service.pb.descriptor_set \ 
--plugin=protoc-gen-go=bazel-out/host/bin/external/com_github_golang_protobuf/protoc_gen_go \ 
--go_out=plugins=grpc,Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,Mimportmap_test/models/entity.proto=myproject/importmap_test/models/entity,Mimportmap_test/service/service.proto=github.com/pubref/rules_protobuf/importmap_test/service/test_service:bazel-out/local-fastbuild/genfiles \ 
--proto_path=external/com_github_google_protobuf/src \ 
--proto_path=. \ 
--proto_path=external/com_github_grpc_ecosystem_grpc_gateway/third_party/googleapis/ \ 
--proto_path=external/com_github_google_protobuf/src/ \ 
importmap_test/service/service.proto
************************************************************
importmap_test/service/service.pb.go
importmap_test/service/test_service.pb.descriptor_set
************************************************************
.
INFO: Found 3 targets...
ERROR: /Users/sathyp/go/src/myproject/importmap_test/service/BUILD:5:1: null failed: test_service.a.GoCompileFile.params failed: error executing command bazel-out/local-fastbuild/bin/importmap_test/service/bazel-out/local-fastbuild/bin/importmap_test/service/test_service.a.GoCompileFile.params: com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
myproject/bazel-out/local-fastbuild/genfiles/importmap_test/service/service.pb.gw.go:13: can't find import: "importmap_test/models"
INFO: Elapsed time: 0.345s, Critical Path: 0.17s

cant find import package if proto file import google/protobuf/empty.proto

I add import "google/protobuf/empty.proto"; to exmaples/helloworld/grpc_gateway/helloworld.proto, enable grpc_gateway_proto_library in exmaples/helloworld/grpc_gateway/BUILD and run bazel build examples/helloworld/grpc_gateway:all, and there is a weird error:

ERROR: github.com/pubref/rules_protobuf/bazel-out/local-fastbuild/genfiles/examples/helloworld/grpc_gateway/helloworld.pb.go:21: can't find import: "github.com/golang/protobuf/ptypes/empty"

I have github.com/golang/protobuf in my $GOPATH, and I can compile helloworld.pb.go manualy.

What's happend here? Thanks!

exmaples/helloworld/grpc_gateway/helloworld.proto:

syntax = "proto3";

import "google/api/annotations.proto";
import "google/protobuf/empty.proto";

package helloworld;

// The greeting service definition.  The definition is repeated here
// rather than re-using examples/helloworld/proto/helloworld.proto so
// the other implementations / tests don't have to account for the
// annotations import.

service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      post: "/v1/helloworld/sayhello"
      body: "*"
    };
  }
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings
message HelloReply {
  string message = 1;
}

github.com/pubref/rules_protobuf/bazel-out/local-fastbuild/genfiles/examples/helloworld/grpc_gateway/helloworld.pb.go

// Code generated by protoc-gen-go.
// source: examples/helloworld/grpc_gateway/helloworld.proto
// DO NOT EDIT!

/*
Package helloworld is a generated protocol buffer package.

It is generated from these files:
	examples/helloworld/grpc_gateway/helloworld.proto

It has these top-level messages:
	HelloRequest
	HelloReply
*/
package helloworld

import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api"
import _ "github.com/golang/protobuf/ptypes/empty"

import (
	context "golang.org/x/net/context"
	grpc "google.golang.org/grpc"
)

// ...

nodejs jspb.Message.getFieldWithDefault is not a function

0e65d2a causes the nodejs server to fail:

INFO: Running command line: bazel-bin/examples/helloworld/node/server
/private/var/tmp/_bazel_pcj/63330772b4917b139280caef8bb81867/execroot/rules_protobuf/bazel-out/local-fastbuild/bin/examples/helloworld/proto/lib/node_modules/examples-helloworld-proto-node/examples/helloworld/proto/helloworld_pb.js:169
  return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
                                             ^

TypeError: jspb.Message.getFieldWithDefault is not a function
    at proto.helloworld.HelloRequest.getName (/private/var/tmp/_bazel_pcj/63330772b4917b139280caef8bb81867/execroot/rules_protobuf/bazel-out/local-fastbuild/bin/examples/helloworld/proto/lib/node_modules/examples-helloworld-proto-node/examples/helloworld/proto/helloworld_pb.js:169:46)
    at Object.sayHello (/Users/pcj/github/rules_protobuf/examples/helloworld/node/greeter_server.js:13:44)
    at Object.wrapper [as func] (/private/var/tmp/_bazel_pcj/63330772b4917b139280caef8bb81867/external/npm_grpc/lib/node_modules/grpc/node_modules/lodash/index.js:3095:19)
    at /private/var/tmp/_bazel_pcj/63330772b4917b139280caef8bb81867/external/npm_grpc/lib/node_modules/grpc/src/node/src/server.js:485:13

make proto_compile accept additional args?

I think it would be nice to allow users to provide custom arguments to protoc. Currently, there doesn't seem to be a way to do it.

My current use case, I'm trying to generate only a proto descriptor set using the following:

proto_compile(
  name = "person_proto",
  protos = ["person.proto"],
  langs = [],
  args = [
    "--include_imports",
    "--include_source_info",
  ],
)

With the hope that this would result in the following command:
protoc --include_imports --include_source_info person.proto --descriptor_set_out person.descriptor_set

However, I can't figure out a way to make the args attr available to protoc. What do you think about this idea?

Unable to build `cc_proto_library` with GRPC support on Ubuntu

If I try to build a simple cc_proto_library with GRPC support (I'm copy-pasting the example from bzl/cpp/README.md, the build fails because the com_github_grpc_grpc build fails:

[nelhage@monomorphique:~/code/grpc-test]$ bazel build :protolib
INFO: Found 1 target...
ERROR: /home/nelhage/.cache/bazel/_bazel_nelhage/809c45c005e5377cc317259ef3196039/external/com_github_grpc_grpc/BUILD:159:1: C++ compilation of rule '@com_github_grpc_grpc//:grpc' failed: linux-sandbox failed: error executing command /home/nelhage/.cache/bazel/_bazel_nelhage/809c45c005e5377cc317259ef3196039/execroot/grpc-test/_bin/linux-sandbox ... (remaining 61 argument(s) skipped).
In file included from external/com_github_grpc_grpc/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c:36:0:
external/com_github_grpc_grpc/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h:38:35: fatal error: third_party/nanopb/pb.h: No such file or directory
compilation terminated.
Target //:protolib failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 32.042s, Critical Path: 8.64s

I believe this is a symptom of grpc/grpc#6728 but is there some workaround that allows this repository to work? I could vendor nanopb into my own third_party directory, but (a) that's fairly dissatisfying and (b) I'm not clear I won't run into other failures.

Travis CI failing with GCC error

Getting this project on travis CI, fails while trying to build boringssl, a dependency of gRPC++.

ERROR: /home/travis/.cache/bazel/external/boringssl/BUILD:91:1: C++ compilation of rule '@boringssl//:crypto' failed: gcc failed: error executing command 
  (cd /home/travis/.cache/bazel/execroot/rules_protobuf && \
  exec env - \
    PATH=/home/travis/.rvm/gems/ruby-1.9.3-p551/bin:/home/travis/.rvm/gems/ruby-1.9.3-p551@global/bin:/home/travis/.rvm/rubies/ruby-1.9.3-p551/bin:/home/travis/.rvm/bin:/usr/lib/jvm/java-8-oracle/bin:/home/travis/bin:/home/travis/.local/bin:/home/travis/.gimme/versions/go1.4.1.linux.amd64/bin:/usr/local/phantomjs/bin:/home/travis/.nvm/v0.10.36/bin:./node_modules/.bin:/usr/local/maven-3.2.5/bin:/usr/local/clang-3.4/bin:/home/travis/.gimme/versions/go1.4.1.linux.amd64/bin:/usr/local/phantomjs/bin:./node_modules/.bin:/usr/local/maven-3.2.5/bin:/usr/local/clang-3.4/bin:/home/travis/.gimme/versions/go1.4.1.linux.amd64/bin:/usr/local/phantomjs/bin:./node_modules/.bin:/usr/local/maven-3.2.5/bin:/usr/local/clang-3.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
  /usr/bin/gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -Wall -Wl,-z,-relro,-z,now -B/usr/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -MD -MF bazel-out/local-fastbuild/bin/external/boringssl/_objs/crypto/external/boringssl/src/crypto/aes/aes.pic.d -fPIC -iquote external/boringssl -iquote bazel-out/local-fastbuild/genfiles/external/boringssl -iquote external/bazel_tools -iquote bazel-out/local-fastbuild/genfiles/external/bazel_tools -isystem external/boringssl/src/include -isystem bazel-out/local-fastbuild/genfiles/external/boringssl/src/include -isystem external/bazel_tools/tools/cpp/gcc3 -Wa,--noexecstack '-D_XOPEN_SOURCE=700' -Wall -Werror '-Wformat=2' -Wsign-compare -Wmissing-field-initializers -Wwrite-strings -Wshadow -fno-common '-std=c11' -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/boringssl/src/crypto/aes/aes.c -o bazel-out/local-fastbuild/bin/external/boringssl/_objs/crypto/external/boringssl/src/crypto/aes/aes.pic.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
cc1: error: unrecognized command line option '-std=c11'
cc1: error: unrecognized command line option "-Wno-free-nonheap-object" [-Werror]
cc1: all warnings being treated as errors
INFO: Building complete.
INFO: Elapsed time: 148.165s, Critical Path: 7.32s
ERROR: No test targets were found, yet testing was requested.
The command "bazel \
  --output_base=$HOME/.cache/bazel \
  --batch \
  --host_jvm_args=-Xmx500m \
  --host_jvm_args=-Xms500m \
  test \
  examples/... \
  --verbose_failures \
  --test_output=errors \
  --test_strategy=standalone \
  --spawn_strategy=standalone \
  --genrule_strategy=standalone \
  --local_resources=400,1,1.0 \
  $FLAGS
" exited with 1.

@jcanizales I'm trying to get these rules to work in multiple languages, but c++ is not a language that I have much experience. So I have to fake it a bit. This is currently working on my osx workstation. I humbly ask if you can take a look to see how I can configure this to build successfully on travis. Is this something simple?

See From https://travis-ci.org/pubref/rules_protobuf/jobs/149826146

googletest 1.7.0 link no longer valid.

Gtest was originally included by following the example on the bazel website http://bazel.io/docs/cpp.html. Now that link is broken. This will likely cause the test suite to fail.

new_http_archive(
    name = "gtest",
    url = "https://googletest.googlecode.com/files/gtest-1.7.0.zip",
    sha256 = "247ca18dd83f53deb1328be17e4b1be31514cedfc1e3424f672bf11fd7e0d60d",
    build_file = "gtest.BUILD",
)

Cannot build or run tests with Bazel 0.4.4

bazel test //...:all # bazel build //...:all does the same 
ERROR: /private/tmp/rules_protobuf/WORKSPACE:113:1: Cannot redefine repository after any load statement in the WORKSPACE file (for repository 'org_pubref_rules_protobuf').
ERROR: Error evaluating WORKSPACE file.
ERROR: package contains errors: objc.
ERROR: error loading package 'external': Package 'external' contains errors.
INFO: Elapsed time: 6.806s
ERROR: Couldn't start the build. Unable to run tests.
bazel version
Build label: 0.4.4-homebrew
Build target: bazel-out/local-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Feb 2 01:05:15 2017 (1485997515)
Build timestamp: 1485997515
Build timestamp as int: 1485997515

Note: 0.4.5 is latest.

go_proto_library fails when 'imports' is specified.

If you change the rule in examples/helloworld/proto/BUILD to read:

go_proto_library(
    name = "go",
    protos = ["helloworld.proto"],
    imports = ["examples/helloworld/proto"],
    verbose = 0,
    with_grpc = True,
)

then when you run bazel test //examples/helloworld/go/greeter_test, you get the error:

INFO: Found 1 test target...
ERROR: /Users/swsnider/rules_protobuf/examples/helloworld/proto/BUILD:18:1: declared output 'examples/helloworld/proto/helloworld.pb.go' was not created by genrule. This is probably because the genrule actually didn't create this output, or because the output was a directory and the genrule was run remotely (note that only the contents of declared file outputs are copied from genrules run remotely).
ERROR: /Users/swsnider/rules_protobuf/examples/helloworld/proto/BUILD:18:1: not all outputs were created.
Target //examples/helloworld/go/greeter_test:greeter_test failed to build

I notice that the genfiles dir has the generated pb.go files at the top level, rather than inside the correct directory, but this might be a red herring.

Go vendoring duplicate library artifacts (glog, etc)

This problem crops up for folks that vendor all of their go dependencies monorepo-style (Pattern 1 described in bazelbuild/rules_go#16 (comment))

A strawman example: I use "govendor" and check in external dependencies directly into the "vendor" of my repository (Pattern 1). I also have a utility similar to gazelle that generates BUILD files for go libraries that are buildable via "go get".

File tools/artifact/proto/BUILD

load("@org_pubref_rules_protobuf//bzl:go/rules.bzl", "go_proto_library")

go_proto_library(
    name = "go_default_library",
    visibility = ["//visibility:public"],
    protos = ["artifact.proto"],
    with_grpc = False,
)

The package for the protobuf DDL builds without issue.

Unfortunately, when I try to use the proto package as a dependency,

Content for tools/artifact/db/BUILD

load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "go_default_library",
    visibility = ["//visibility:public"],
    srcs = ["store.go"],
    deps = [
        "//tools/artifact/proto:go_default_library",
        "//vendor/github.com/golang/glog:go_default_library",
        "//vendor/google.golang.org/cloud/datastore:go_default_library",
    ],
)

go_test(
    name = "go_tests",
    size = "small",
    srcs = ["store_test.go"],
    library = ":go_default_library",
    deps = [],
)

I get an error

ERROR: /???/tools/artifact/db/BUILD:17:1: error executing shell command: 'rm -rf bazel-out/local-fastbuild/bin/tools/artifact/db/go_tests.dir && mkdir -p bazel-out/local-fastbuild/bin/tools/artifact/db/go_tests.dir && mkdir -p bazel-out/local-fastbuild/bin/tools/artifact...' failed: linux-sandbox failed: error executing command /?????/.cache/bazel/_bazel_bshi/08ef9c7ff335ac2219f037954496dcb0/execroot/experiments.git/_bin/linux-sandbox ... (remaining 5 argument(s) skipped).
ln: failed to create symbolic link 'bazel-out/local-fastbuild/bin/tools/artifact/db/go_tests.dir/github.com/golang/glog.a': File exists

As far as I can tell, this is because rules_protobuf is pulling in glog as a dependency as an external git repository and then pointing to custom BUILD rules. Those build rules in turn are colliding with my declaration of "//vendor/github.com/golang/glog:go_default_library", There currently isn't a way short of forking this repo to adapt the dependencies and target names that are hard coded: https://github.com/pubref/rules_protobuf/blob/master/bzl/go/class.bzl#L118

I don't have a good general solution to prescribe here but wanted to call out the issue.

In /examples `bazel run go/client` fails on linux

This might be a naive question but following the /examples:

  • cpp/server built and run through CLI
  • bazel run go/client fails
ERROR: /home/xxx/.cache/bazel/_bazel_xxx/68bdc85a7d4d2b9ce1849afc06064a21/external/io_bazel_rules_go/go/toolchain/BUILD:5:1: no such package '@io_bazel_rules_go_toolchain//': Not a file: /home/xxx/.cache/bazel/_bazel_xxx/68bdc85a7d4d2b9ce1849afc06064a21/external/golang_linux_amd64/BUILD and referenced by '@io_bazel_rules_go//go/toolchain:toolchain'.
ERROR: Analysis of target '//examples/helloworld/go/client:client' failed; build aborted.
INFO: Elapsed time: 0.133s
ERROR: Build failed. Not running target

There is /home/xxx/.cache/bazel/_bazel_xxx/68bdc85a7d4d2b9ce1849afc06064a21/external/golang_linux_amd64 but indeed there is no BUILD file in there.

Would appreciate if somebody can point to the right docs, in case I'm doing something wrong here.

Difficulty referencing an external proto on linux.

Discussed at https://groups.google.com/d/msg/bazel-discuss/TyI0mMX_fQo/0audY7sTAQAJ with @jhahn21.

Another thing to try is to define a java_proto_library for the wkt_protos and depend on that, such as:

package(default_visibility = ["//visibility:public"])

load("@org_pubref_rules_protobuf//java:rules.bzl", "java_proto_library")

java_proto_library(
    name = "wkt_protos",
    protos = ["@com_github_google_protobuf//:well_known_protos"],
    imports = ['external/com_github_google_protobuf/src'],
)

java_proto_library(
    name = "java",
    protos = ["common.proto"],
    proto_deps = [
        "wkt_protos",
    ],
    imports = ['external/com_github_google_protobuf/src'],
    inputs = ["@com_github_google_protobuf//:well_known_protos"],
)

GRPC shouldn't be required if you don't use it

Simple proto of the form:

load("@com_github_pubref_rules_protobuf//cpp:rules.bzl", "cc_proto_library")

cc_proto_library(
name = "cards_proto_cc",
protos = ["cards.proto"],
)

Should not fail on:
no such package '@com_github_grpc_grpc//'

This dependency should only be sucked in when 'grpc_plugin' is set to something.

Conflict with new_go_repository()

When some of go_proto_repositories likecom_github_golang_protobuf and org_golang_x_net are automatically imported by the dependencies of new_go_repository(), there are conflicts like

ERROR: /usr/local/share/users/jungho.ahn/cache/bazel/_bazel_jungho.ahn/c8d993de066bb9ba420445c3170a1d5a/external/org_pubref_rules_protobuf/go/BUILD:5:1: no such target '@com_github_golang_protobuf//:protoc_gen_go': target 'protoc_gen_go' not declared in package '' defined by /usr/local/share/users/jungho.ahn/cache/bazel/_bazel_jungho.ahn/c8d993de066bb9ba420445c3170a1d5a/external/com_github_golang_protobuf/BUILD and referenced by '@org_pubref_rules_protobuf//go:go'.
ERROR: /home/jungho.ahn/work/snapcraft/snapcraft/snapcraft_serving/proto/BUILD:14:1: no such target '@com_github_golang_protobuf//:proto': target 'proto' not declared in package ''; however, a source directory of this name exists.  (Perhaps add 'exports_files(["proto"])' to /BUILD, or define a filegroup?) defined by /usr/local/share/users/jungho.ahn/cache/bazel/_bazel_jungho.ahn/c8d993de066bb9ba420445c3170a1d5a/external/com_github_golang_protobuf/BUILD and referenced by '//proto:style_deployment_proto_go'.
ERROR: Analysis of target '//proto:style_deployment_proto_go' failed; build aborted.

This is because the BUILD files in protobuf/build_file and go/rules.bzl are using specific library names while the generated Go BUILD files by new_go_repository() are using go_default_library name.

Is there any work around for this?

Update grpc dep to v1.0.4

Trying to build a go_proto_library with_grpc, got:

undefined: grpc.SupportPackageIsVersion4

This was fixed by manually adding:

new_go_repository(
    name = "org_golang_google_grpc",
    commit = "8712952b7d646dbbbc6fb73a782174f3115060f3",
    importpath = "google.golang.org/grpc",
)

to my WORKSPACE.

I believe the issue is that https://github.com/pubref/rules_protobuf/blob/master/go/deps.bzl#L26 is set to "tag": "v1.0.2" (instead of "tag": "v1.0.4" as needed).

From: https://github.com/grpc/grpc-go/releases/tag/v1.0.4

Now the grpc support version is SupportPackageIsVersion4

gRPC version update

The current Java libraries are using gRPC v1.0.1, when gRPC v1.2.0 has recently be released. Some useful improvements include "waitForReady()" support on stubs. What is the expected time for a bump in version of the libraries?

Go support: can't import generated protobuf file output

rules_protobuf go support is being developed on the "go" branch and originally based on @yugui https://github.com/grpc-ecosystem/grpc-gateway/blob/e958c5db30f7b99e1870db42dd5624322f112d0c/grpc-gateway.bzl.

Protocol buffer sources *.pb.go are successfully generated, but other go code that attempts to import the generated files fails:

$ git clone https://github.com/pubref/rules_protobuf
$ cd rules_protobuf
$ git checkout go
$ bazel build --verbose_failures examples/helloworld/go/client
WARNING: /Users/pcj/github/rules_protobuf/bzl/protoc.bzl:176:3: import_map: {"examples/helloworld/go/proto/helloworld.proto": "pubref.org/rules_pubref/examples/helloworld"}.
WARNING: /Users/pcj/github/rules_protobuf/bzl/protoc.bzl:256:5: protoc binary: bazel-out/host/genfiles/third_party/protoc/protoc.
WARNING: /Users/pcj/github/rules_protobuf/bzl/protoc.bzl:258:7:  > arg0: --plugin=protoc-gen-go=bazel-out/host/bin/external/com_github_golang_protobuf/protoc_gen_go.
WARNING: /Users/pcj/github/rules_protobuf/bzl/protoc.bzl:258:7:  > arg1: --go_out=Mexamples/helloworld/go/proto/helloworld.proto=pubref.org/rules_pubref/examples/helloworld,grpc:bazel-out/local-fastbuild/genfiles/.
WARNING: /Users/pcj/github/rules_protobuf/bzl/protoc.bzl:258:7:  > arg2: -I.
WARNING: /Users/pcj/github/rules_protobuf/bzl/protoc.bzl:258:7:  > arg3: examples/helloworld/go/proto/helloworld.proto.
WARNING: /Users/pcj/github/rules_protobuf/bzl/protoc.bzl:260:7:  > input: Artifact:[/Users/pcj/github/rules_protobuf[source]]examples/helloworld/go/proto/helloworld.proto.
WARNING: /Users/pcj/github/rules_protobuf/bzl/protoc.bzl:260:7:  > input: Artifact:[[/private/var/tmp/_bazel_pcj/63330772b4917b139280caef8bb81867/execroot/rules_protobuf]bazel-out/host/bin]external/com_github_golang_protobuf/protoc_gen_go.
WARNING: /Users/pcj/github/rules_protobuf/bzl/protoc.bzl:260:7:  > input: Artifact:[[/private/var/tmp/_bazel_pcj/63330772b4917b139280caef8bb81867/execroot/rules_protobuf]bazel-out/local-fastbuild/genfiles]examples/helloworld/go/proto/helloworld.proto.
WARNING: /Users/pcj/github/rules_protobuf/bzl/protoc.bzl:262:7:  > output: Artifact:[[/private/var/tmp/_bazel_pcj/63330772b4917b139280caef8bb81867/execroot/rules_protobuf]bazel-out/local-fastbuild/genfiles]examples/helloworld/go/proto/helloworld.pb.go.
WARNING: /Users/pcj/github/rules_protobuf/bzl/protoc.bzl:281:5: protoc_gen provided files: set([Artifact:[[/private/var/tmp/_bazel_pcj/63330772b4917b139280caef8bb81867/execroot/rules_protobuf]bazel-out/local-fastbuild/genfiles]examples/helloworld/go/proto/helloworld.pb.go]).
INFO: Found 1 target...
ERROR: /Users/pcj/github/rules_protobuf/examples/helloworld/go/client/BUILD:3:1: error executing shell command: 'rm -rf bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir && mkdir -p bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir && mkdir -p bazel-out/local-fast...' failed: bash failed: error executing command 
  (cd /private/var/tmp/_bazel_pcj/63330772b4917b139280caef8bb81867/execroot/rules_protobuf && \
  exec env - \
    GOARCH=amd64 \
    GOOS=darwin \
  /bin/bash -c '
rm -rf bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir 
&& mkdir -p bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir 
&& mkdir -p bazel-out/localfastbuild/bin/examples/helloworld/go/client/client.a.dir/github.com/golang 
&& ln -s ../../../../../../../../../../bazel-out/local-fastbuild/bin/external/com_github_golang_glog/go_default_library.a bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir/github.com/golang/glog.a 
&& mkdir -p bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir/github.com/golang/protobuf 
&& ln -s ../../../../../../../../../../../bazel-out/local-fastbuild/bin/external/com_github_golang_protobuf/proto.a bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir/github.com/golang/protobuf/proto.a
&& mkdir -p bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir/google.golang.org 
&& ln -s ../../../../../../../../../bazel-out/local-fastbuild/bin/external/org_golang_google_grpc/go_default_library.a bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir/google.golang.org/grpc.a 
&& mkdir -p bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir/golang.org/x/net 
&& ln -s ../../../../../../../../../../../bazel-out/local-fastbuild/bin/external/org_golang_x_net/context.a bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir/golang.org/x/net/context.a 
&& mkdir -p bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir/pubref.org/rules_protobuf/bazel-out/local-fastbuild/genfiles/examples/helloworld/go/proto 
&& ln -s ../../../../../../../../../../../../../../../../../bazel-out/local-fastbuild/genfiles/examples/helloworld/go/proto/helloworld.pb.go bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir/pubref.org/rules_protobuf/bazel-out/local-fastbuild/genfiles/examples/helloworld/go/proto/helloworld.pb.go 
&& mkdir -p bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir/pubref.org/rules_protobuf/examples/helloworld/go/client 
&& ln -s ../../../../../../../../../../../../../../examples/helloworld/go/client/main.go bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir/pubref.org/rules_protobuf/examples/helloworld/go/client/main.go 
&& export GOROOT=$(pwd)/external/golang_darwin_amd64/go/bin/.. 
&& cd  bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a.dir 
&& ../../../../../../../../external/golang_darwin_amd64/go/bin/go tool compile -o ../../../../../../../../bazel-out/local-fastbuild/bin/examples/helloworld/go/client/client.a -pack -I . pubref.org/rules_protobuf/examples/helloworld/go/client/main.go pubref.org/rules_protobuf/bazel-out/local-fastbuild/genfiles/examples/helloworld/go/proto/helloworld.pb.go'): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
pubref.org/rules_protobuf/examples/helloworld/go/client/main.go:42: can't find import: "pubref.org/helloworld/examples/helloworld"
Target //examples/helloworld/go/client:client failed to build
INFO: Elapsed time: 0.225s, Critical Path: 0.10s

error occurs when exec `bazel build examples/helloworld/go/server`

I use bazel 0.4.5, and HEAD(d6f9694) of pubref/rules_protobuf

Build label: 0.4.5-homebrew
Build target: bazel-out/local-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/
BazelServer_deploy.jar
Build time: Thu Mar 16 13:39:33 2017 (1489671573)
Build timestamp: 1489671573
Build timestamp as int: 1489671573

The error message is

ERROR: /private/var/tmp/_bazel_yan/750690edeecb3b8564d9895b168c0e1e/external/io_bazel_ru
les_go/go/toolchain/BUILD:5:1: no such package '@io_bazel_rules_go_toolchain//': Not a f
ile: /private/var/tmp/_bazel_yan/750690edeecb3b8564d9895b168c0e1e/external/golang_darwin
_amd64/BUILD and referenced by '@io_bazel_rules_go//go/toolchain:toolchain'.
ERROR: Analysis of target '//examples/helloworld/go/server:server' failed; build aborted
.
INFO: Elapsed time: 12.022s

I look into this folder golang_darwin_amd64/, and found a file BUILD.bazel. After rename the file to BUILD, I rerun the command and got another error message:

ERROR: /Users/yan/Dropbox/Works/dev/rules_protobuf/examples/helloworld/go/server/BUILD:6
:1: no such package '@org_golang_x_net//context': no such package '@io_bazel_rules_go_re
pository_tools//': Traceback (most recent call last):
        File "/private/var/tmp/_bazel_yan/750690edeecb3b8564d9895b168c0e1e/external/io_b
azel_rules_go/go/def.bzl", line 1136
                _fetch_repository_tools_deps(ctx, goroot, gopath)
        File "/private/var/tmp/_bazel_yan/750690edeecb3b8564d9895b168c0e1e/external/io_b
azel_rules_go/go/def.bzl", line 1105, in _fetch_repository_tools_deps
                ctx.download_and_extract('%s/archive/%s.zip' % (dep.repo,...), <4 more a
rguments>)
java.io.IOException: Prefix buildifier-0ca1d7991357ae7a7555589af88930d82cf07c0a was give
n, but not found in the zip and referenced by '//examples/helloworld/go/server:server'.
ERROR: Analysis of target '//examples/helloworld/go/server:server' failed; build aborted
.
INFO: Elapsed time: 16.362s

Write blog post for grpc.io

Would be good to educate developer community on how to build gRPC-related projects with bazel and rules_protobuf. One way would be a blog post to http://www.grpc.io/posts.

@louiscryan Is this something the gRPC blog would be interested in? If so, I'd plan to draft something up as a markdown document and iterate from there.

Python support requires pip or pypi

In order to support python fully in rules_protobuf, support for pulling dependencies from pip or pypi is required. This is non-trivial for grpc as there is c-compilation involved with package installation. Requires bazelbuild/bazel#699 or similar.

Eclipse build path

I've gotten a proto to build, via java_proto_library, but I'm having trouble linking it to my eclipse project, so that I can code with IDE support. I realize this is a shot in the dark, but do you know how to?

Readme doesn't work in clean WORKSPACE

Hello -
Following the instructions on the README in a clean WORKSPACE, trying to compile cc_proto_library, gives me the error:

Unhandled exception thrown during build; message: topLevelKey: TARGET_PATTERN::cpp
alreadyReported: false
path to cycle:
TARGET_PATTERN::cpp
PACKAGE:
PACKAGE:external
EXTERNAL_PACKAGE:[/Users/samrosenstein/Documents/test-dir]/[WORKSPACE]
cycle:
WORKSPACE_FILE:[/Users/samrosenstein/Documents/test-dir]/[WORKSPACE], 1
SKYLARK_IMPORTS_LOOKUP:com.google.devtools.build.lib.skyframe.SkylarkImportLookupValue$SkylarkImportLookupKey@c19c2438
SKYLARK_IMPORTS_LOOKUP:com.google.devtools.build.lib.skyframe.SkylarkImportLookupValue$SkylarkImportLookupKey@7f55b427
SKYLARK_IMPORTS_LOOKUP:com.google.devtools.build.lib.skyframe.SkylarkImportLookupValue$SkylarkImportLookupKey@245a9b0d
SKYLARK_IMPORTS_LOOKUP:com.google.devtools.build.lib.skyframe.SkylarkImportLookupValue$SkylarkImportLookupKey@75a9ad52
SKYLARK_IMPORTS_LOOKUP:com.google.devtools.build.lib.skyframe.SkylarkImportLookupValue$SkylarkImportLookupKey@66b51997
AST_FILE_LOOKUP:@io_bazel_rules_go//go:def.bzl
PACKAGE_LOOKUP:@io_bazel_rules_go//go
REPOSITORY:@io_bazel_rules_go
REPOSITORY_DIRECTORY:@io_bazel_rules_go

I used the BUILD file for common.proto (:protos) and the common.proto to test.

with_grpc can never be False

Reported by @thaidn in #48:

I can't tell if this is related, but cc_proto_library fails to compile if with_grpc is false:

$bazel build proto:cpp
INFO: Found 1 target...
ERROR: /home/test/blah/proto/BUILD:11:1: C++ compilation of rule '//proto:cpp' failed: linux-sandbox failed: error executing command /home/test/blah/.cache/bazel/_bazel_test/0fb2f33edd989c698a85a6fc0489350b/execroot/k2/_bin/linux-sandbox ... (remaining 47 argument(s) skipped).
In file included from bazel-out/local-fastbuild/genfiles/proto/k2.grpc.pb.cc:6:0:
bazel-out/local-fastbuild/genfiles/proto/k2.grpc.pb.h:12:46: fatal error: grpc++/impl/codegen/async_stream.h: No such file or directory
 #include <grpc++/impl/codegen/async_stream.h>
                                              ^
compilation terminated.
Target //proto:cpp failed to build
# proto/BUILD 
package(default_visibility = ["//visibility:public"])

load("@org_pubref_rules_protobuf//cpp:rules.bzl", "cc_proto_library")
load("@org_pubref_rules_protobuf//java:rules.bzl", "java_proto_library")

filegroup(
    name = "protos",
    srcs = ["myproto.proto"],
)

cc_proto_library(
    name = "cpp",
    protos = [":protos"],
    verbose = 0,
    with_grpc = False,
    imports = [
      "external/com_github_google_protobuf/src/",
    ],
    inputs = [
      "@com_github_google_protobuf//:well_known_protos",
    ],
)

java_proto_library(
    name = "java",
    protos = [":protos"],
    verbose = 0,
    with_grpc = False,
    imports = [
      "external/com_github_google_protobuf/src/",
    ],
    inputs = [
      "@com_github_google_protobuf//:well_known_protos",
    ],
)

bazel build proto:java works just fine though.

Ideas?

PS: thank you for releasing this tool. It has saved me many hours!

Support java_lite_proto_library

I want to use lite proto for some Android project.

I can send a PR, but I need some guidance on where I should look at and change.

Thanks!

go_proto_library fails in 0.4.0

When I have a simple go_proto_library def:

go_proto_library(
  name = "lowlevel",
  protos = ["lowlevel.proto"],
  with_grpc = True,
)

I get the error

ERROR: [REDACTED]/protos/BUILD:5:1: //protos:lowlevel: no such attribute 'protos' in 'go_library' rule.
ERROR: package contains errors: protos.
ERROR: error loading package 'protos': Package 'protos' contains errors.
INFO: Elapsed time: 0.149s
ERROR: Couldn't start the build. Unable to run tests.

When I change the attribute name to srcs, I get the error

INFO: Found 12 targets and 3 test targets...
>>>>> # //protos:lowlevel.pb [action 'ProtoCompile protos/lowlevel.pb.go']
(cd /private/var/tmp/_bazel_swsnider/272ade6b1a91cbd9de45078ef005616e/execroot/[REDACTED] && \
  exec env - \
  bazel-out/host/bin/external/com_github_google_protobuf/protoc '--plugin=protoc-gen-go=bazel-out/host/bin/external/com_github_golang_protobuf/protoc_gen_go' '--go_out=plugins=grpc:bazel-out/local-fastbuild/bin' '--proto_path=.' protos/lowlevel.proto)
ERROR: [REDACTED]/protos/BUILD:5:1: null failed: sandbox-exec failed: error executing command /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_swsnider/272ade6b1a91cbd9de45078ef005616e/bazel-sandbox/ca1b8c74-ce2e-4395-be98-b670584cce87-0.sb ... (remaining 5 argument(s) skipped).
protos/lowlevel.proto: No such file or directory
INFO: Elapsed time: 0.163s, Critical Path: 0.02s

golang protos cannot be filegroup(s) or labels

Due to the current implementation of the go_proto_compile as a macro that calls native.genrule, one cannot use a filegroup as the input to the protos attribute. For example, this does not work:

go_proto_library(
  name = "protos"
  protos = [
    ":my_protos_filegroup",
  ],
)

Instead, the input has to be the explicitly named proto sources in order to predict the output of rule prior to the analysis phase.

go_proto_library(
  name = "protos"
  protos = [
    "request.proto",
    "response.proto",
  ],
)

A better implementation would use a native rule (not genrule), but this does not seem to work with rules_go.

How to set import_prefix in go_proto_library()

Hello,

I have a proto that imports other proto, but has import prefix like

A/x.proto

package A
message X {
 ...
}

A/y.proto

package A

import "A/x.proto"
import "A/..."

message Y {
  X x = 1;
  ...
}

Although I'm trying to use importmap, the generated go for y.proto includes

import _ "A"

which I couldn't map. I could change "A" path with import_prefix by running protoc directly.

How can I pass this option to go_proto_library?

Thanks,

Parse tree too deep

Travis build failing from new closure test for the proto rule in c8bfa53:

external/closure_library/closure/goog/transpile.js:1460: ERROR - Parse tree too deep.
_.dg=function wY(){return this.f.a};_.eg=function xY(){return jY(this).eg()};_.fg=function yY(){return jY(this).fg()};_.gg=function zY(){return this.a.gg()};_.yd=function AY(){return this.f.a};var KE=K9b(118);gQ(614,1,{},DY);var JE=K9b(614);gQ(159,1,{},NY);_.yd=function PY(){return Cd(zd(Ad(Ad(zd(zd(zd(Ad(Ad(zd(zd(Ad(Ad(Ad(Ad(yd(Ad(Ad(Ad(Ad(Ad(Ad(Ad(Ad(zd(zd(zd(zd(zd(Ad(zd(zd(zd(Ad(zd(Ad(Ad(Ad(Ad(Ad(zd(zd(Ad(Ad(zd(zd(zd(zd(zd(zd(zd(zd(zd(zd(zd(zd(zd(Ad(Ad(zd(zd(zd(zd(zd(zd(zd(zd(zd(zd(zd(zd(zd(zd(Ad(zd(zd(Ad(Ad(zd(zd(zd(zd(Ad(zd(Ad(Ad(yd(zd(zd(Ad(yd(zd(zd(Ad(Ad(zd(zd(Ad(zd(Ad(Ad(Ad(Ad(Ad(Ad(Ad(zd(zd(zd(zd(zd(zd(zd(zd(zd(Ad(Ad(zd(zd(zd(zd(zd(Ad(zd(zd(zd(Ad(Ad(Ad(zd(zd(zd(Ad(Ad(Ad(zd(zd(zd(Ad(zd(Ad(Ad(zd(Ad(zd(zd(Ad(Ad(Ad(zd(zd(zd(zd(zd(Ad(zd(zd(zd(zd(zd(zd(Ad(zd(zd(zd(zd(zd(zd(Ad(Ad(Ad(Ad(Ad(zd(zd(Ad(zd(zd(Ad(Ad(zd(zd(zd(Ad(Ad(zd(Ad(zd(Bd(new Dd((E9b(WE),
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ^

https://travis-ci.org/pubref/rules_protobuf/jobs/164838447

Should be fixed by upgrade to bazelbuild/rules_closure@9e92334 but users will have to have at least this version in their workspace.

Using well_known_protos in C++

Hi, I am building C++ code with protos using bazel. I'd like to use any.proto, one of @com_github_google_protobuf//:well_known_protos, but when I build it, I am getting the following error:
Import "google/protobuf/any.proto" was not found or had errors.

My cc_proto_library entry is:

cc_proto_library(
    name = "b_proto_cc",
    protos = [ "a/b.proto", ],
    imports = [
        "external/com_github_google_protobuf/src/",
    ],
    deps = [
        "@com_github_google_protobuf//:cc_wkt_protos",
    ],
)

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.