Git Product home page Git Product logo

Comments (9)

pcj avatar pcj commented on July 27, 2024

The expected generated file is currently based on the protofile basename rather than the short_path, but this should be a supported use case.

from rules_protobuf.

pcj avatar pcj commented on July 27, 2024

Should be fixed by cc4556c. Can you confirm and close issue if it works for you?

from rules_protobuf.

junghoahnsc avatar junghoahnsc commented on July 27, 2024

I got the following error:

RROR: /usr/local/share/users/jungho.ahn/cache/bazel/_bazel_jungho.ahn/c8d993de066bb9ba420445c3170a1d5a/external/pb_schema/BUILD:17:1: in proto_compile rule @pb_schema//:snapcraft_proto.pb:
Traceback (most recent call last):
        File "/usr/local/share/users/jungho.ahn/cache/bazel/_bazel_jungho.ahn/c8d993de066bb9ba420445c3170a1d5a/external/pb_schema/BUILD", line 17
            proto_compile(name = 'snapcraft_proto.pb')
        File "/usr/local/share/users/jungho.ahn/cache/bazel/_bazel_jungho.ahn/c8d993de066bb9ba420445c3170a1d5a/external/org_pubref_rules_protobuf/protobuf/internal/proto_compile.bzl", line 512, in _proto_compile_impl
            _build_output_files(run, builder)
        File "/usr/local/share/users/jungho.ahn/cache/bazel/_bazel_jungho.ahn/c8d993de066bb9ba420445c3170a1d5a/external/org_pubref_rules_protobuf/protobuf/internal/proto_compile.bzl", line 186, in _build_output_files
            ctx.new_file("/".join(path))
external/pb_schema/./pb_schema/snapmind/snapcraft.pb.h.
ERROR: Analysis of target '@pb_schema//:snapcraft_proto' failed; build aborted.

WORKSPACE:

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

BUILD:

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

cc_proto_library(
     name = "snapcraft_proto",
     protos = ["snapmind/snapcraft.proto"],
     verbose = 2,
     with_grpc = True,
     deps = ["@protobuf//:cc_wkt_protos"],
)

from rules_protobuf.

pcj avatar pcj commented on July 27, 2024

OK, it'll look at it again :) There are two uses cases here, I guess I just solved for the first one:

  1. Invoking protos = ["snapmind/snapcraft.proto"] in own WORKSPACE.
  2. Invoking protos = ["snapmind/snapcraft.proto"] in an external WORKSPACE (like your example).

from rules_protobuf.

pcj avatar pcj commented on July 27, 2024

Want to try 4a76440? It's not merged on master. Has a test example that you can refer to as well.

from rules_protobuf.

junghoahnsc avatar junghoahnsc commented on July 27, 2024

Thanks for the fix. It works!

BTW, when two local repositories have the same paths, how can I distinguish them in #include?
E.g., repository A and B has proto/a/b.proto and I'd like to include A's proto/a/b.pb.h.

I tried #include "external/A/proto/a/b.pb.h". It seems to find it, but I got some unrelated errors like

In file included from model_server/server.cc:16:0:
bazel-out/local-fastbuild/genfiles/external/pb_schema/proto/snapcraft/snapcraft.grpc.pb.h:126:84: error: 'grpc::ServerUnaryStreamer' has not been declared
     virtual ::grpc::Status StreamedStylize(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::snapcraft::StylizationRequest,::snapcraft::StylizationResponse>* server_unary_streamer) = 0;

from rules_protobuf.

pcj avatar pcj commented on July 27, 2024

What does your cc_library rule look like? Does it depend on both A and B's proto_library rule?

from rules_protobuf.

junghoahnsc avatar junghoahnsc commented on July 27, 2024

For now, the cc_library depends on only A. But I'm just curious when cc_library depends on both.

from rules_protobuf.

pcj avatar pcj commented on July 27, 2024

I have not tried it, but I would imagine that one would have to disambiguate the names somehow. Since the name of #include file would be the same (does not incorporate the workspace name A|B), would be confusing.

In that case perhaps a genrule to cp the proto file to a new namespace might work.

Glad to hear the fix worked. Thanks for your testing and feedback.

from rules_protobuf.

Related Issues (20)

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.