Hi bazel-discuss and protobuf,

I am bringing in protobuf as an external bazel repository:

git_repository(
    name = "protobuf_repo",
    commit = "32daf513ced8d51e8de6cc8d800cfc972c4df5d6",
    init_submodules = True,
    remote = "https://github.com/google/protobuf.git";,
)

and using the protobuf_java target as a dependency in my bazel java
libraries. This fails generating the following message:

...
>>>>> # @protobuf_repo//:gen_well_known_protos_java [action 'Executing
genrule @protobuf_repo//:gen_well_known_protos_java']

(cd /private/var/tmp/_bazel_rohit/a10731376421707628e091029859af4a/beam && \

  exec env - \

    PATH='<snip>' \

    TMPDIR=/var/folders/p2/yz_3gtqd4z9d15l2ptzcjbsm0000gn/T/ \

  /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh;
bazel-out/host/bin/external/protobuf_repo/protoc
--java_out=bazel-out/local_darwin-fastbuild/genfiles/external/protobuf_repo/wellknown.jar
-Isrc external/protobuf_repo/src/google/protobuf/any.proto
external/protobuf_repo/src/google/protobuf/api.proto
external/protobuf_repo/src/google/protobuf/compiler/plugin.proto
external/protobuf_repo/src/google/protobuf/descriptor.proto
external/protobuf_repo/src/google/protobuf/duration.proto
external/protobuf_repo/src/google/protobuf/empty.proto
external/protobuf_repo/src/google/protobuf/field_mask.proto
external/protobuf_repo/src/google/protobuf/source_context.proto
external/protobuf_repo/src/google/protobuf/struct.proto
external/protobuf_repo/src/google/protobuf/timestamp.proto
external/protobuf_repo/src/google/protobuf/type.proto
external/protobuf_repo/src/google/protobuf/wrappers.proto  && mv
bazel-out/local_darwin-fastbuild/genfiles/external/protobuf_repo/wellknown.jar
bazel-out/local_darwin-fastbuild/genfiles/external/protobuf_repo/wellknown.srcjar')

ERROR: 
/private/var/tmp/_bazel_rohit/a10731376421707628e091029859af4a/external/protobuf_repo/BUILD:461:1:
Couldn't build file external/protobuf_repo/wellknown.srcjar: Executing
genrule @protobuf_repo//:gen_well_known_protos_java failed: bash failed:
error executing command /bin/bash -c ... (remaining 1 argument(s) skipped):
com.google.devtools.build.lib.shell.BadExitStatusException: Process exited
with status 1.

src: warning: directory does not exist.

external/protobuf_repo/src/google/protobuf/any.proto: File does not reside
within any path specified using --proto_path (or -I).  You must specify a
--proto_path which encompasses this file.  Note that the proto_path must be
an exact prefix of the .proto file names -- protoc is too dumb to figure
out when two paths (e.g. absolute and relative) are equivalent (it's harder
than you think).

The warning has the clue, and if I were to replace the import path (-Isrc)
with -Iexternal/protobuf_repo/src. Is there an equivalent of bazel
workspace_root that can be used for the cmd in this genrule in
protobuf/BUILD?
genrule(
    name = "gen_well_known_protos_java",
    srcs = WELL_KNOWN_PROTOS,
    outs = [
        "wellknown.srcjar",
    ],
    cmd = "$(location :protoc) --java_out=$(@D)/wellknown.jar" +
          " -Isrc $(SRCS) " +
          " && mv $(@D)/wellknown.jar $(@D)/wellknown.srcjar",
    tools = [":protoc"],
)

Thanks,
Rohit Saboo

-- 
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