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

go_proto_library should have implicit dependencies on Well Known Types #944

Closed
jayconrod opened this issue Oct 19, 2017 · 0 comments
Closed

Comments

@jayconrod
Copy link
Contributor

Suppose you have a proto that imports google/protobuf/duration.proto. Gazelle will generate rules like this:

proto_library(
    name = "foo_proto",
    srcs = ["foo.proto"],
    visibility = ["//visibility:public"],
    deps = ["@com_google_protobuf//:duration_proto"],
)

go_proto_library(
    name = "foo_go_proto",
    importpath = "example.com/repo/foo",
    proto = ":foo_proto",
    visibility = ["//visibility:public"],
    deps = ["@com_github_golang_protobuf//ptypes/duration:go_default_library"],
)

The dependency on @com_github_golang_protobuf//ptypes/duration:go_default_library is added by a special case for the Well Known Types. This is necessary because there isn't currently a way to import protos in different repositories. We also use the pregenerated .pb.go files for these libraries because it's difficult to build these automatically without any tweaking.

These dependencies prevent gogoproto from being used, since that plugin has its prebuilt code for these libraries in a different repository. We could add more special cases to Gazelle to handle this, but ultimately, Gazelle shouldn't have to know which plugin you're using. The toolchain should handle this instead.

The toolchain could add implicit dependencies on go_libraries for the Well Known Types appropriate for whichever plugin is being used. In go_proto_library rules, you would not need to write these dependencies. This would be analogous to implicit dependencies on Go standard library packages. The Well Known Types are a kind of standard library for protos after all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant