Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ensonic opened this issue Apr 30, 2018 · 0 comments
Closed

Comments

@ensonic
Copy link
Contributor

ensonic commented Apr 30, 2018

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.

@ensonic ensonic changed the title the bazel rules generates non working import path. the protoc_gen_swagger bazel rule generates non working import path. Apr 30, 2018
ensonic added a commit to ensonic/grpc-gateway that referenced this issue Apr 30, 2018
Instead of generating a list of import paths based on the difnames of the
imported protos, generate maps to the package local names. This is needed to
handle the case of packages containing a proto with the same name.

An example here is the annotation.proto in this module.

Fixes grpc-ecosystem#633
ensonic added a commit to ensonic/grpc-gateway that referenced this issue Apr 30, 2018
Instead of generating a list of import paths based on the difnames of the
imported protos, generate maps to the package local names. This is needed to
handle the case of packages containing a proto with the same name.

An example here is the annotation.proto in this module.

Fixes grpc-ecosystem#633
ensonic added a commit to ensonic/grpc-gateway that referenced this issue Apr 30, 2018
Instead of generating a list of import paths based on the difnames of the
imported protos, generate maps to the package local names. This is needed to
handle the case of packages containing a proto with the same name.

An example here is the annotation.proto in this module.

Fixes grpc-ecosystem#633
ensonic added a commit to ensonic/grpc-gateway that referenced this issue May 7, 2018
Instead of generating a list of import paths based on the difnames of the
imported protos, generate maps to the package local names. This is needed to
handle the case of packages containing a proto with the same name.

An example here is the annotation.proto in this module.

Fixes grpc-ecosystem#633
ensonic added a commit to ensonic/grpc-gateway that referenced this issue May 7, 2018
Instead of generating a list of import paths based on the difnames of the
imported protos, generate maps to the package local names. This is needed to
handle the case of packages containing a proto with the same name.

An example here is the annotation.proto in this module.

Fixes grpc-ecosystem#633
achew22 pushed a commit that referenced this issue May 7, 2018
Instead of generating a list of import paths based on the difnames of the
imported protos, generate maps to the package local names. This is needed to
handle the case of packages containing a proto with the same name.

An example here is the annotation.proto in this module.

Fixes #633
adasari pushed a commit to adasari/grpc-gateway that referenced this issue Apr 9, 2020
Instead of generating a list of import paths based on the difnames of the
imported protos, generate maps to the package local names. This is needed to
handle the case of packages containing a proto with the same name.

An example here is the annotation.proto in this module.

Fixes grpc-ecosystem#633
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant