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

Issue understanding relative proto resolution #1839

Open
NPellet opened this issue Jul 8, 2024 · 0 comments
Open

Issue understanding relative proto resolution #1839

NPellet opened this issue Jul 8, 2024 · 0 comments

Comments

@NPellet
Copy link

NPellet commented Jul 8, 2024

What version of gazelle are you using?

0.36.0

What version of rules_go are you using?

0.47.0

What version of Bazel are you using?

6.5.0

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

OSX M1

What did you do?

We have a monorepo with the directory:

/path/to/proto/files/protoc-gen-openapiv2/options

inside of which, the files

annotations.proto

syntax = "proto3";

package grpc.gateway.protoc_gen_openapiv2.options;
import "google/protobuf/descriptor.proto";
import "protoc-gen-openapiv2/options/openapiv2.proto";
option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options";

and

openapiv2.proto

syntax = "proto3";
package grpc.gateway.protoc_gen_openapiv2.options;
import "google/protobuf/struct.proto";
option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options";

When running bazel the BUILD file ends up being

load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

proto_library(
    name = "options_proto",
    srcs = [
        "annotations.proto",
        "openapiv2.proto",
    ],
    visibility = ["//visibility:public"],
    deps = [
        "//protoc-gen-openapiv2/options:options_proto",            <== Can't work !
        "@com_google_protobuf//:descriptor_proto",
        "@com_google_protobuf//:struct_proto",
    ],
)

go_proto_library(
    name = "options_go_proto",
    importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options",
    proto = ":options_proto",
    visibility = ["//visibility:public"],
    deps = ["//protoc-gen-openapiv2/options:openapiv2_proto"],       <== Can't work !
)

go_library(
    name = "options",
    embed = [":options_go_proto"],
    importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options",
    visibility = ["//visibility:public"],
)

alias(
    name = "go_default_library",
    actual = ":options",
    visibility = ["//visibility:public"],
)

Because we resolve the dependencies relative (we'd like to keep it like that because we can just copy/paste proto files), the dependencies "//protoc-gen-openapiv2/options:options_proto" can't be resolved.

What did you expect to see?

Dependencies listed as "//path/to/proto/files/protoc-gen-openapiv2/options:options_proto"

What did you see instead?

"//protoc-gen-openapiv2/options:options_proto"

Same for any library that consume this proto files with relative paths.

So my question boils down to which gazelle can I use to make the relative imports work ? There are a bunch of options, I think I've tried them all, but haven't figured out the right combination yet.

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