rules_proto icon indicating copy to clipboard operation
rules_proto copied to clipboard

Add grpc-gateway support

Open heartless-clown opened this issue 3 years ago • 4 comments

Adds support for protoc-gen-grpc-gateway and protoc-gen-grpc-openapiv2 plugins. Sorry, I accidentally closed #253...

heartless-clown avatar Jun 14 '22 18:06 heartless-clown

CI: https://buildkite.com/bazel/stackb-rules-proto/builds?branch=heartless-clown%3Agrpc-gateway

pcj avatar Jun 15 '22 06:06 pcj

CI finally green, .idea/ removed. Also added grpc-go golden test.

heartless-clown avatar Jun 15 '22 06:06 heartless-clown

IIRC the reason I left the go language out of the example/{person,place,thing}` is that to do it properly one really needs to compile the well-known types from source rather than relying on precompiled files from something like https://github.com/googleapis/go-genproto, which is how the builtin gazelle proto extension hardcodes it (https://github.com/bazelbuild/bazel-gazelle/blob/master/language/proto/known_go_imports.go).

This is suboptimal because those precompiled files were likely generated by a compiler and proto source configuration different than the one being targeted.

This is what the proto_repository and proto_gazelle rules allow one to do. Here's the diff of what that looks like:

diff --git a/BUILD.bazel b/BUILD.bazel
index c9cf7993..22f98437 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -1,5 +1,6 @@
 load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
 load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
+load("//rules:proto_gazelle.bzl", "proto_gazelle")
 
 # ----------------------------------------------------
 # Buildifier
@@ -27,9 +28,13 @@ gazelle_binary(
     visibility = ["//visibility:public"],
 )
 
-gazelle(
+proto_gazelle(
     name = "gazelle",
+    cfgs = ["//example:config.yaml"],
     gazelle = ":gazelle-protobuf",
+    imports = [
+        "@protobufapis//:imports.csv",
+    ],
 )
 
 gazelle(
diff --git a/Makefile b/Makefile
index 14b8f6b7..6f091775 100644
--- a/Makefile
+++ b/Makefile
@@ -23,5 +23,4 @@ site:
 
 .PHONY: test
 test:
-	$(BAZEL) test //example/... //pkg/... //plugin/... //language/... //rules/... //toolchain/... \
-		--deleted_packages=//plugin/grpc-ecosystem/grpc-gateway
+	$(BAZEL) test //example/... //pkg/... //plugin/... //language/... //rules/... //toolchain/...
diff --git a/WORKSPACE b/WORKSPACE
index 214a9ca0..35219592 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -237,3 +237,11 @@ load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories")
 node_repositories()
 
 register_toolchains("//toolchain:nodejs")
+
+# ----------------------------------------------------
+# proto_repository rules
+# ----------------------------------------------------
+
+load("//deps:proto_repositories.bzl", "proto_repositories")
+
+proto_repositories()
diff --git a/deps/proto_repositories.bzl b/deps/proto_repositories.bzl
new file mode 100644
index 00000000..dd5bb108
--- /dev/null
+++ b/deps/proto_repositories.bzl
@@ -0,0 +1,76 @@
+"""
+Third-party proto dependencies
+"""
+
+load("@build_stack_rules_proto//rules/proto:proto_repository.bzl", "proto_repository")
+
+# buildifier: disable=function-docstring-header
+def proto_repositories():
+    proto_repository(
+        name = "protobufapis",
+        build_directives = [
+            "gazelle:proto_language go enable true",
+            "gazelle:exclude google/protobuf/compiler/ruby/**",
+            "gazelle:exclude google/protobuf/compiler/cpp/**",
+            "gazelle:exclude google/protobuf/util/**",
+            "gazelle:exclude google/protobuf/unittest/**",
+        ],
+        deleted_files = [
+            "google/protobuf/any_test.proto",
+            "google/protobuf/map_lite_unittest.proto",
+            "google/protobuf/map_proto2_unittest.proto",
+            "google/protobuf/map_unittest.proto",
+            "google/protobuf/test_messages_proto2.proto",
+            "google/protobuf/test_messages_proto3.proto",
+            "google/protobuf/unittest_arena.proto",
+            "google/protobuf/unittest_custom_options.proto",
+            "google/protobuf/unittest_drop_unknown_fields.proto",
+            "google/protobuf/unittest_embed_optimize_for.proto",
+            "google/protobuf/unittest_empty.proto",
+            "google/protobuf/unittest_enormous_descriptor.proto",
+            "google/protobuf/unittest_import_lite.proto",
+            "google/protobuf/unittest_import_public_lite.proto",
+            "google/protobuf/unittest_import_public.proto",
+            "google/protobuf/unittest_import.proto",
+            "google/protobuf/unittest_lazy_dependencies_custom_option.proto",
+            "google/protobuf/unittest_lazy_dependencies_enum.proto",
+            "google/protobuf/unittest_lazy_dependencies.proto",
+            "google/protobuf/unittest_lite_imports_nonlite.proto",
+            "google/protobuf/unittest_lite.proto",
+            "google/protobuf/unittest_mset_wire_format.proto",
+            "google/protobuf/unittest_mset.proto",
+            "google/protobuf/unittest_no_field_presence.proto",
+            "google/protobuf/unittest_no_generic_services.proto",
+            "google/protobuf/unittest_optimize_for.proto",
+            "google/protobuf/unittest_preserve_unknown_enum.proto",
+            "google/protobuf/unittest_preserve_unknown_enum2.proto",
+            "google/protobuf/unittest_proto3_arena_lite.proto",
+            "google/protobuf/unittest_proto3_arena.proto",
+            "google/protobuf/unittest_proto3_lite.proto",
+            "google/protobuf/unittest_proto3_optional.proto",
+            "google/protobuf/unittest_proto3.proto",
+            "google/protobuf/unittest_well_known_types.proto",
+            "google/protobuf/unittest.proto",
+        ],
+        build_file_expunge = True,
+        build_file_proto_mode = "file",
+        cfgs = ["//example:config.yaml"],
+        sha256 = "bf0e5070b4b99240183b29df78155eee335885e53a8af8683964579c214ad301",
+        strip_prefix = "protobuf-3.14.0/src",
+        urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.14.0.zip"],
+    )
+
+    proto_repository(
+        name = "googleapis",
+        build_directives = [
+            "gazelle:proto_language go enable true",
+        ],
+        build_file_generation = "on",
+        build_file_proto_mode = "file",
+        cfgs = ["//example:config.yaml"],
+        override_go_googleapis = True,
+        sha256 = "b9dbc65ebc738a486265ef7b708e9449bf361541890091983e946557ee0a4bfc",
+        strip_prefix = "googleapis-66759bdf6a5ebb898c2a51c8649aefd1ee0b7ffe",
+        type = "zip",
+        urls = ["https://codeload.github.com/googleapis/googleapis/zip/66759bdf6a5ebb898c2a51c8649aefd1ee0b7ffe"],
+    )
diff --git a/example/BUILD.bazel b/example/BUILD.bazel
index 321afa3f..eb65b969 100644
--- a/example/BUILD.bazel
+++ b/example/BUILD.bazel
@@ -164,3 +164,5 @@
 # gazelle:proto_language node_js rule proto_nodejs_library
 # gazelle:proto_language node_js rule grpc_nodejs_library
 # gazelle:proto_language node_js rule grpc_web_js_library
+
+exports_files(["config.yaml"])
diff --git a/example/config.yaml b/example/config.yaml
index 963d6ffe..4c937ab6 100644
--- a/example/config.yaml
+++ b/example/config.yaml
@@ -13,9 +13,9 @@ plugins:
   - name: protoc-gen-go-grpc
     implementation: grpc:grpc-go:protoc-gen-go-grpc
     deps:
-      - "@org_golang_google_grpc//:go_default_library",
-      - "@org_golang_google_grpc//codes",
-      - "@org_golang_google_grpc//status",
+      - "@org_golang_google_grpc//:go_default_library"
+      - "@org_golang_google_grpc//codes"
+      - "@org_golang_google_grpc//status"
 rules:
   - name: proto_compile
     implementation: stackb:rules_proto:proto_compile
@@ -38,9 +38,6 @@ rules:
     implementation: stackb:rules_proto:proto_go_library
     visibility:
       -  //visibility:public
-    resolves:
-      - "google/protobuf/([a-z]+).proto @org_golang_google_protobuf//types/known/${1}pb"
-      - "google/protobuf/(descriptor|plugin).proto @org_golang_google_protobuf//types/${1}pb"
 languages:
   - name: cpp
     plugins:
diff --git a/example/person/BUILD.bazel b/example/person/BUILD.bazel
index 743afd35..caf87e80 100644
--- a/example/person/BUILD.bazel
+++ b/example/person/BUILD.bazel
@@ -43,6 +43,7 @@ proto_compile(
     outputs = ["person.js"],
     plugins = ["@build_stack_rules_proto//plugin/builtin:closurejs"],
     proto = "person_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_cc_library(
@@ -64,6 +65,7 @@ proto_compile(
     ],
     plugins = ["@build_stack_rules_proto//plugin/builtin:cpp"],
     proto = "person_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_compile(
@@ -72,6 +74,7 @@ proto_compile(
     outputs = ["person.pb.go"],
     plugins = ["@build_stack_rules_proto//plugin/golang/protobuf:protoc-gen-go"],
     proto = "person_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_go_library(
@@ -92,6 +95,7 @@ proto_compile(
     outputs = ["person.srcjar"],
     plugins = ["@build_stack_rules_proto//plugin/builtin:java"],
     proto = "person_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_java_library(
@@ -114,6 +118,7 @@ proto_compile(
     outputs = ["person_pb.js"],
     plugins = ["@build_stack_rules_proto//plugin/builtin:commonjs"],
     proto = "person_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_nodejs_library(
@@ -133,6 +138,7 @@ proto_compile(
         "@build_stack_rules_proto//plugin/builtin:python",
     ],
     proto = "person_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_py_library(
@@ -150,6 +156,7 @@ proto_compile(
     outputs = ["person_scala.srcjar"],
     plugins = ["@build_stack_rules_proto//plugin/scalapb/scalapb:protoc-gen-scala"],
     proto = "person_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_scala_library(
@@ -177,6 +184,7 @@ proto_compile(
     outputs = ["person.ts"],
     plugins = ["@build_stack_rules_proto//plugin/stephenh/ts-proto:protoc-gen-ts-proto"],
     proto = "person_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_ts_library(
diff --git a/example/place/BUILD.bazel b/example/place/BUILD.bazel
index 8805d79b..17a8e65c 100644
--- a/example/place/BUILD.bazel
+++ b/example/place/BUILD.bazel
@@ -42,6 +42,7 @@ proto_compile(
     outputs = ["place.js"],
     plugins = ["@build_stack_rules_proto//plugin/builtin:closurejs"],
     proto = "place_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_cc_library(
@@ -63,6 +64,7 @@ proto_compile(
     ],
     plugins = ["@build_stack_rules_proto//plugin/builtin:cpp"],
     proto = "place_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_compile(
@@ -71,6 +73,7 @@ proto_compile(
     outputs = ["place.pb.go"],
     plugins = ["@build_stack_rules_proto//plugin/golang/protobuf:protoc-gen-go"],
     proto = "place_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_go_library(
@@ -91,6 +94,7 @@ proto_compile(
     outputs = ["place.srcjar"],
     plugins = ["@build_stack_rules_proto//plugin/builtin:java"],
     proto = "place_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_java_library(
@@ -113,6 +117,7 @@ proto_compile(
     outputs = ["place_pb.js"],
     plugins = ["@build_stack_rules_proto//plugin/builtin:commonjs"],
     proto = "place_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_nodejs_library(
@@ -132,6 +137,7 @@ proto_compile(
         "@build_stack_rules_proto//plugin/builtin:python",
     ],
     proto = "place_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_py_library(
@@ -149,6 +155,7 @@ proto_compile(
     outputs = ["place_scala.srcjar"],
     plugins = ["@build_stack_rules_proto//plugin/scalapb/scalapb:protoc-gen-scala"],
     proto = "place_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_scala_library(
@@ -176,6 +183,7 @@ proto_compile(
     outputs = ["place.ts"],
     plugins = ["@build_stack_rules_proto//plugin/stephenh/ts-proto:protoc-gen-ts-proto"],
     proto = "place_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_ts_library(
diff --git a/example/routeguide/BUILD.bazel b/example/routeguide/BUILD.bazel
index 7a7070b8..5cc9e765 100644
--- a/example/routeguide/BUILD.bazel
+++ b/example/routeguide/BUILD.bazel
@@ -91,6 +91,7 @@ proto_compile(
         "@build_stack_rules_proto//plugin/stackb/grpc_js:protoc-gen-grpc-js",
     ],
     proto = "routeguide_proto",
+    visibility = ["//visibility:public"],
 )
 
 grpc_cc_library(
@@ -126,6 +127,7 @@ proto_compile(
         "@build_stack_rules_proto//plugin/grpc/grpc:protoc-gen-grpc-cpp",
     ],
     proto = "routeguide_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_compile(
@@ -157,6 +159,7 @@ proto_compile(
         "@build_stack_rules_proto//plugin/grpc/grpc-go:protoc-gen-go-grpc",
     ],
     proto = "routeguide_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_go_library(
@@ -212,6 +215,7 @@ proto_compile(
         "@build_stack_rules_proto//plugin/grpc/grpc-java:protoc-gen-grpc-java",
     ],
     proto = "routeguide_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_java_library(
@@ -257,6 +261,7 @@ proto_compile(
         "@build_stack_rules_proto//plugin/grpc/grpc-web:protoc-gen-grpc-web",
     ],
     proto = "routeguide_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_nodejs_library(
@@ -285,6 +290,7 @@ proto_compile(
         "@build_stack_rules_proto//plugin/grpc/grpc:protoc-gen-grpc-python",
     ],
     proto = "routeguide_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_py_library(
@@ -328,6 +334,7 @@ proto_compile(
         "@build_stack_rules_proto//plugin/scalapb/scalapb:protoc-gen-scala",
     ],
     proto = "routeguide_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_compile(
@@ -340,6 +347,7 @@ proto_compile(
     outputs = ["routeguide.ts"],
     plugins = ["@build_stack_rules_proto//plugin/stephenh/ts-proto:protoc-gen-ts-proto"],
     proto = "routeguide_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_ts_library(
diff --git a/example/thing/BUILD.bazel b/example/thing/BUILD.bazel
index 7f9c9a51..496a7520 100644
--- a/example/thing/BUILD.bazel
+++ b/example/thing/BUILD.bazel
@@ -13,7 +13,7 @@ proto_library(
     name = "thing_proto",
     srcs = ["thing.proto"],
     visibility = ["//visibility:public"],
-    deps = ["@com_google_protobuf//:timestamp_proto"],
+    deps = ["@protobufapis//google/protobuf:timestamp_proto"],
 )
 
 proto_closure_js_library(
@@ -40,6 +40,7 @@ proto_compile(
     outputs = ["thing.js"],
     plugins = ["@build_stack_rules_proto//plugin/builtin:closurejs"],
     proto = "thing_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_cc_library(
@@ -58,6 +59,7 @@ proto_compile(
     ],
     plugins = ["@build_stack_rules_proto//plugin/builtin:cpp"],
     proto = "thing_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_compile(
@@ -66,6 +68,7 @@ proto_compile(
     outputs = ["thing.pb.go"],
     plugins = ["@build_stack_rules_proto//plugin/golang/protobuf:protoc-gen-go"],
     proto = "thing_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_go_library(
@@ -76,6 +79,7 @@ proto_go_library(
     deps = [
         "@org_golang_google_protobuf//reflect/protoreflect",
         "@org_golang_google_protobuf//runtime/protoimpl",
+        "@protobufapis//google/protobuf:timestamp_go_proto",
     ],
 )
 
@@ -85,6 +89,7 @@ proto_compile(
     outputs = ["thing.srcjar"],
     plugins = ["@build_stack_rules_proto//plugin/builtin:java"],
     proto = "thing_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_java_library(
@@ -101,6 +106,7 @@ proto_compile(
     outputs = ["thing_pb.js"],
     plugins = ["@build_stack_rules_proto//plugin/builtin:commonjs"],
     proto = "thing_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_nodejs_library(
@@ -120,6 +126,7 @@ proto_compile(
         "@build_stack_rules_proto//plugin/builtin:python",
     ],
     proto = "thing_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_py_library(
@@ -134,6 +141,7 @@ proto_compile(
     outputs = ["thing_scala.srcjar"],
     plugins = ["@build_stack_rules_proto//plugin/scalapb/scalapb:protoc-gen-scala"],
     proto = "thing_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_scala_library(
@@ -160,6 +168,7 @@ proto_compile(
     outputs = ["thing.ts"],
     plugins = ["@build_stack_rules_proto//plugin/stephenh/ts-proto:protoc-gen-ts-proto"],
     proto = "thing_proto",
+    visibility = ["//visibility:public"],
 )
 
 proto_ts_library(
diff --git a/language/protobuf/oldtestdata/gogo/BUILD.bazel b/language/protobuf/oldtestdata/gogo/BUILD.bazel
deleted file mode 100644
index 94e332e8..00000000
--- a/language/protobuf/oldtestdata/gogo/BUILD.bazel
+++ /dev/null
@@ -1,7 +0,0 @@
-load("@rules_proto//proto:defs.bzl", "proto_library")
-
-proto_library(
-    name = "test_proto",
-    srcs = ["test.proto"],
-    visibility = ["//visibility:public"],
-)
diff --git a/language/protobuf/oldtestdata/gogo/BUILD.in b/language/protobuf/oldtestdata/gogo/BUILD.in
deleted file mode 100644
index 94d8e991..00000000
--- a/language/protobuf/oldtestdata/gogo/BUILD.in
+++ /dev/null
@@ -1,2 +0,0 @@
-# gazelle:proto_language gogofast plugin gogofast
-# gazelle:proto_language gogofast rule proto_compiled_sources
diff --git a/language/protobuf/oldtestdata/gogo/BUILD.out b/language/protobuf/oldtestdata/gogo/BUILD.out
deleted file mode 100644
index ad3bd82e..00000000
--- a/language/protobuf/oldtestdata/gogo/BUILD.out
+++ /dev/null
@@ -1,18 +0,0 @@
-load("@rules_proto//proto:defs.bzl", "proto_library")
-load("@build_stack_rules_proto//rules:proto_compiled_sources.bzl", "proto_compiled_sources")
-
-# gazelle:proto_language gogofast plugin gogofast
-# gazelle:proto_language gogofast rule proto_compiled_sources
-
-proto_library(
-    name = "test_proto",
-    srcs = ["test.proto"],
-    visibility = ["//visibility:public"],
-)
-
-proto_compiled_sources(
-    name = "test_gogofast_compiled_sources",
-    srcs = ["test.pb.go"],
-    plugins = ["@build_stack_rules_proto//gogo/protobuf:gogofast_plugin"],
-    proto = "test_proto",
-)
diff --git a/language/protobuf/oldtestdata/gogo/WORKSPACE b/language/protobuf/oldtestdata/gogo/WORKSPACE
deleted file mode 100644
index e69de29b..00000000
diff --git a/language/protobuf/oldtestdata/gogo/test.proto b/language/protobuf/oldtestdata/gogo/test.proto
deleted file mode 100644
index 8031ee33..00000000
--- a/language/protobuf/oldtestdata/gogo/test.proto
+++ /dev/null
@@ -1,19 +0,0 @@
-syntax = "proto3";
-
-message BoolValue {
-  bool value = 1;
-}
-
-enum PayloadType {
-  COMPRESSABLE = 0;
-}
-
-message Payload {
-  PayloadType type = 1;
-  bytes body = 2;
-}
-
-message EchoStatus {
-  int32 code = 1;
-  string message = 2;
-}
diff --git a/language/protobuf/oldtestdata/java/BUILD.bazel b/language/protobuf/oldtestdata/java/BUILD.bazel
deleted file mode 100644
index 94e332e8..00000000
--- a/language/protobuf/oldtestdata/java/BUILD.bazel
+++ /dev/null
@@ -1,7 +0,0 @@
-load("@rules_proto//proto:defs.bzl", "proto_library")
-
-proto_library(
-    name = "test_proto",
-    srcs = ["test.proto"],
-    visibility = ["//visibility:public"],
-)
diff --git a/language/protobuf/oldtestdata/java/BUILD.in b/language/protobuf/oldtestdata/java/BUILD.in
deleted file mode 100644
index 6e6afa68..00000000
--- a/language/protobuf/oldtestdata/java/BUILD.in
+++ /dev/null
@@ -1,3 +0,0 @@
-# gazelle:proto_language java plugin java_proto
-# gazelle:proto_language java plugin java_grpc
-# gazelle:proto_language java rule proto_compile
diff --git a/language/protobuf/oldtestdata/java/BUILD.out b/language/protobuf/oldtestdata/java/BUILD.out
deleted file mode 100644
index 6f987354..00000000
--- a/language/protobuf/oldtestdata/java/BUILD.out
+++ /dev/null
@@ -1,19 +0,0 @@
-load("@rules_proto//proto:defs.bzl", "proto_library")
-load("@build_stack_rules_proto//rules:proto_compile.bzl", "proto_compile")
-
-# gazelle:proto_language java plugin java_proto
-# gazelle:proto_language java plugin java_grpc
-# gazelle:proto_language java rule proto_compile
-
-proto_library(
-    name = "test_proto",
-    srcs = ["test.proto"],
-    visibility = ["//visibility:public"],
-)
-
-proto_compile(
-    name = "test_java_compile",
-    outputs = ["test.srcjar"],
-    plugins = ["@build_stack_rules_proto//protocolbuffers/protobuf:java_plugin"],
-    proto = "test_proto",
-)
diff --git a/language/protobuf/oldtestdata/java/WORKSPACE b/language/protobuf/oldtestdata/java/WORKSPACE
deleted file mode 100644
index e69de29b..00000000
diff --git a/language/protobuf/oldtestdata/java/test.proto b/language/protobuf/oldtestdata/java/test.proto
deleted file mode 100644
index 8031ee33..00000000
--- a/language/protobuf/oldtestdata/java/test.proto
+++ /dev/null
@@ -1,19 +0,0 @@
-syntax = "proto3";
-
-message BoolValue {
-  bool value = 1;
-}
-
-enum PayloadType {
-  COMPRESSABLE = 0;
-}
-
-message Payload {
-  PayloadType type = 1;
-  bytes body = 2;
-}
-
-message EchoStatus {
-  int32 code = 1;
-  string message = 2;
-}
diff --git a/pkg/rule/rules_go/go_library.go b/pkg/rule/rules_go/go_library.go
index c78169dd..69086a7a 100644
--- a/pkg/rule/rules_go/go_library.go
+++ b/pkg/rule/rules_go/go_library.go
@@ -263,7 +263,7 @@ func (s *goLibraryRule) Imports(c *config.Config, r *rule.Rule, f *rule.File) []
 
 // Resolve implements part of the RuleProvider interface.
 func (s *goLibraryRule) Resolve(c *config.Config, ix *resolve.RuleIndex, r *rule.Rule, imports []string, from label.Label) {
-	protoc.ResolveDepsAttr("deps", true)(c, ix, r, imports, from)
+	protoc.ResolveDepsAttr("deps", false)(c, ix, r, imports, from)
 
 	// need to make one more pass to possibly move deps into embeds.  There may
 	// be dependencies *IN OTHER PACKAGES* that have the same importpath; in
diff --git a/rules/private/proto_repository_tools_srcs.bzl b/rules/private/proto_repository_tools_srcs.bzl
index 47e06218..10b634e2 100644
--- a/rules/private/proto_repository_tools_srcs.bzl
+++ b/rules/private/proto_repository_tools_srcs.bzl
@@ -42,8 +42,6 @@ PROTO_REPOSITORY_TOOLS_SRCS = [
     "@build_stack_rules_proto//language/example:BUILD.bazel",
     "@build_stack_rules_proto//language/example:example.go",
     "@build_stack_rules_proto//language/protobuf:BUILD.bazel",
-    "@build_stack_rules_proto//language/protobuf/oldtestdata/gogo:BUILD.bazel",
-    "@build_stack_rules_proto//language/protobuf/oldtestdata/java:BUILD.bazel",
     "@build_stack_rules_proto//language/protobuf:protobuf.go",
     "@build_stack_rules_proto//pkg:BUILD.bazel",
     "@build_stack_rules_proto//pkg/goldentest:BUILD.bazel",
@@ -85,8 +83,11 @@ PROTO_REPOSITORY_TOOLS_SRCS = [
     "@build_stack_rules_proto//pkg/plugin/grpc/grpcjava:protoc-gen-grpc-java.go",
     "@build_stack_rules_proto//pkg/plugin/grpc/grpcnode:BUILD.bazel",
     "@build_stack_rules_proto//pkg/plugin/grpc/grpcnode:protoc-gen-grpc-node.go",
+    "@build_stack_rules_proto//pkg/plugin/grpc/grpcweb:BUILD.bazel",
+    "@build_stack_rules_proto//pkg/plugin/grpc/grpcweb:protoc-gen-grpc-web.go",
     "@build_stack_rules_proto//pkg/plugin/grpcecosystem/grpcgateway:BUILD.bazel",
     "@build_stack_rules_proto//pkg/plugin/grpcecosystem/grpcgateway:protoc-gen-grpc-gateway.go",
+    "@build_stack_rules_proto//pkg/plugin/grpcecosystem/grpcgateway:protoc-gen-grpc-openapiv2.go",
     "@build_stack_rules_proto//pkg/plugin/scalapb/scalapb:BUILD.bazel",
     "@build_stack_rules_proto//pkg/plugin/scalapb/scalapb:protoc_gen_scala.go",
     "@build_stack_rules_proto//pkg/plugin/stackb/grpc_js:BUILD.bazel",
@@ -165,6 +166,7 @@ PROTO_REPOSITORY_TOOLS_SRCS = [
     "@build_stack_rules_proto//plugin/grpc/grpc-go:BUILD.bazel",
     "@build_stack_rules_proto//plugin/grpc/grpc-java:BUILD.bazel",
     "@build_stack_rules_proto//plugin/grpc/grpc-node:BUILD.bazel",
+    "@build_stack_rules_proto//plugin/grpc/grpc-web:BUILD.bazel",
     "@build_stack_rules_proto//plugin/grpc-ecosystem/grpc-gateway:BUILD.bazel",
     "@build_stack_rules_proto//plugin/scalapb/scalapb:BUILD.bazel",
     "@build_stack_rules_proto//plugin/stackb/grpc_js:BUILD.bazel",

Now, gazelle is able to resolve the corresponding go dependency:

proto_go_library(
    name = "thing_go_proto",
    srcs = ["thing.pb.go"],
    importpath = "github.com/stackb/rules_proto/example/thing",
    visibility = ["//visibility:public"],
    deps = [
        "@org_golang_google_protobuf//reflect/protoreflect",
        "@org_golang_google_protobuf//runtime/protoimpl",
+       "@protobufapis//google/protobuf:timestamp_go_proto",
    ],
)

Thinking about whether to make this "dogfooding of proto_gazelle" a separate PR. For now, need to get some sleep.

pcj avatar Jun 15 '22 07:06 pcj

I'd prefer making a separate PR for utilizing //rules/proto:proto_repository.bzl internally. If you disagree, please let me know, I'll move changes from #260 here.

heartless-clown avatar Jun 17 '22 12:06 heartless-clown

Closing due to age, but let's re-open if still actively used.

pcj avatar Feb 17 '24 22:02 pcj