Skip to content

the protoc_gen_swagger bazel rule generates non working import path. #633

Closed
@ensonic

Description

@ensonic

The new bazel rules use generate an inlcude path based on the dirnames of the sources. This will not be able to disambiguate e.g. the annotation.proto from google apis with the annotations.proto in this package.

The path we get from the rule looks like this:

-Iexternal/com_google_protobuf/src
-Iexternal/com_github_googleapis_googleapis
-I.
-Iexternal/com_google_protobuf/src/google/protobuf
-Iexternal/com_google_protobuf/src/google/protobuf/compiler
-Iexternal/com_github_googleapis_googleapis/google/api
-Ibazel-out/k8-opt/genfiles/external/com_google_protobuf/google/protobuf
-Iexternal/grpc_ecosystem_grpc_gateway/protoc-gen-swagger/options

what the proto_library rules in bazel do looks like this:

'-Igoogle/api/annotations.proto=external/com_github_googleapis_googleapis/google/api/annotations.proto'
'-Igoogle/api/http.proto=external/com_github_googleapis_googleapis/google/api/http.proto'
'-Igoogle/protobuf/descriptor.proto=bazel-out/k8-opt/genfiles/external/com_google_protobuf/google/protobuf/descriptor.proto'
'-Igoogle/protobuf/empty.proto=bazel-out/k8-opt/genfiles/external/com_google_protobuf/google/protobuf/empty.proto'
'-Igoogle/protobuf/field_mask.proto=bazel-out/k8-opt/genfiles/external/com_google_protobuf/google/protobuf/field_mask.proto'
'-Igoogle/protobuf/timestamp.proto=bazel-out/k8-opt/genfiles/external/com_google_protobuf/google/protobuf/timestamp.proto' 
'-Iprotoc-gen-swagger/options/annotations.proto=external/grpc_ecosystem_grpc_gateway/protoc-gen-swagger/options/annotations.proto'
'-Iprotoc-gen-swagger/options/openapiv2.proto=external/grpc_ecosystem_grpc_gateway/protoc-gen-swagger/options/openapiv2.proto'
'-Igoogle/protobuf/any.proto=bazel-out/k8-opt/genfiles/external/com_google_protobuf/google/protobuf/any.proto'

The releated bazel implementation is here:
https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java#L581

I'll see if I can fix the rule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions