Skip to content
This repository has been archived by the owner on Jun 17, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ewhauser committed Apr 3, 2023
2 parents 3da167e + 6308ec2 commit f170102
Show file tree
Hide file tree
Showing 183 changed files with 17,837 additions and 9,064 deletions.
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build:bazelci --deleted_packages=docs
build --incompatible_strict_action_env
# workaround for scala
build --incompatible_java_common_parameters=false
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BAZEL := bazel
BAZEL := bzl

.PHONY: tidy
tidy: deps
Expand All @@ -15,7 +15,7 @@ deps:
cp -f ./bazel-bin/deps/*.bzl deps/
chmod 0644 deps/*.bzl
$(BAZEL) run //:buildifier -- deps/

.PHONY: site
site:
$(BAZEL) build //example/golden:*
Expand All @@ -24,3 +24,10 @@ site:
.PHONY: test
test:
$(BAZEL) test //example/... //pkg/... //plugin/... //language/... //rules/... //toolchain/... \
--deleted_packages=//plugin/grpc-ecosystem/grpc-gateway

.PHONY: get
get:
$(BAZEL) run @go_sdk//:bin/go -- get github.com/bazelbuild/bazel-gazelle@v0.27.0
$(BAZEL) run @go_sdk//:bin/go -- mod download github.com/bazelbuild/buildtools
$(BAZEL) run @go_sdk//:bin/go -- mod vendor
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,16 @@ Bazel starlark rules for building protocol buffers +/- gRPC :sparkles:.
```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Branch: master
# Commit: 7c95feba87ae269d09690fcebb18c77d8b8bcf6a
# Date: 2021-11-16 02:17:58 +0000 UTC
# URL: https://github.com/stackb/rules_proto/commit/7c95feba87ae269d09690fcebb18c77d8b8bcf6a
#
# V2 (#193)
# Size: 885598 (886 kB)
# Release: v2.0.1
# TargetCommitish: master
# Date: 2022-10-20 02:38:27 +0000 UTC
# URL: https://github.com/stackb/rules_proto/releases/tag/v2.0.1
# Size: 2071295 (2.1 MB)
http_archive(
name = "build_stack_rules_proto",
sha256 = "1190c296a9f931343f70e58e5f6f9ee2331709be4e17001bb570e41237a6c497",
strip_prefix = "rules_proto-7c95feba87ae269d09690fcebb18c77d8b8bcf6a",
urls = ["https://github.com/stackb/rules_proto/archive/7c95feba87ae269d09690fcebb18c77d8b8bcf6a.tar.gz"],
sha256 = "ac7e2966a78660e83e1ba84a06db6eda9a7659a841b6a7fd93028cd8757afbfb",
strip_prefix = "rules_proto-2.0.1",
urls = ["https://github.com/stackb/rules_proto/archive/v2.0.1.tar.gz"],
)
```

Expand Down
31 changes: 11 additions & 20 deletions deps/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -156,35 +156,26 @@ proto_dependency(
visibility = ["//visibility:public"],
)

# Branch: master
# Commit: 425d85daecb9aeffa1ae24b83df7b97b534dcf05
# Date: 2021-10-29 00:25:25 +0000 UTC
# URL: https://github.com/bazelbuild/bazel-gazelle/commit/425d85daecb9aeffa1ae24b83df7b97b534dcf05
#
# Stardoc generates repository.md (#1123)
#
# * Stardoc generates repository.md
#
# This is a mirror of the content in repository.rst, allowing us to manually inspect the delta between them.
# As soon as we are satisfied that the generated content is correct, we'll delete repository.rst and update any links to it.
#
# Technique: copied doc strings out of existing rst file into the starlark files. Transcribed rst syntax to markdown.
#
# * Replace repository.rst content with link to markdown version
# Size: 1416940 (1.4 MB)
# Release: v0.27.0
# TargetCommitish: master
# Date: 2022-09-14 16:04:23 +0000 UTC
# URL: https://github.com/bazelbuild/bazel-gazelle/releases/tag/v0.27.0
# Size: 1568477 (1.6 MB)
proto_dependency(
name = "bazel_gazelle",
patch_args = ["-p1"],
patches = ["@build_stack_rules_proto//third_party:bazel-gazelle-PR1274.patch"],
patches = ["@build_stack_rules_proto//third_party:bazel-gazelle-revert-1152.patch"],
repository_rule = "http_archive",
sha256 = "cb05501bd37e2cbfdea8e23b28e5a7fe4ff4f12cef30eeb1924a0b8c3c0cea61",
strip_prefix = "bazel-gazelle-425d85daecb9aeffa1ae24b83df7b97b534dcf05",
urls = ["https://github.com/bazelbuild/bazel-gazelle/archive/425d85daecb9aeffa1ae24b83df7b97b534dcf05.tar.gz"],
sha256 = "fdfa7f0969e997d26378dd283fab89379403bd4379051da81f7268d5c04398f7",
strip_prefix = "bazel-gazelle-06b821c9b085f3d7c21af06a33a990513351431c",
urls = ["https://github.com/bazelbuild/bazel-gazelle/archive/06b821c9b085f3d7c21af06a33a990513351431c.tar.gz"],
deps = [":io_bazel_rules_go"],
)

proto_dependency(
name = "com_google_protobuf",
patch_args = ["-p1"],
patches = ["@build_stack_rules_proto//third_party:com_google_protobuf.deploy-env.patch"],
repository_rule = "http_archive",
sha256 = "8b28fdd45bab62d15db232ec404248901842e5340299a57765e48abe8a80d930",
strip_prefix = "protobuf-3.20.1",
Expand Down
8 changes: 4 additions & 4 deletions deps/core_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def bazel_gazelle():
_maybe(
http_archive,
name = "bazel_gazelle",
sha256 = "cb05501bd37e2cbfdea8e23b28e5a7fe4ff4f12cef30eeb1924a0b8c3c0cea61",
strip_prefix = "bazel-gazelle-425d85daecb9aeffa1ae24b83df7b97b534dcf05",
sha256 = "fdfa7f0969e997d26378dd283fab89379403bd4379051da81f7268d5c04398f7",
strip_prefix = "bazel-gazelle-06b821c9b085f3d7c21af06a33a990513351431c",
urls = [
"https://github.com/bazelbuild/bazel-gazelle/archive/425d85daecb9aeffa1ae24b83df7b97b534dcf05.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/archive/06b821c9b085f3d7c21af06a33a990513351431c.tar.gz",
],
patches = [
"@build_stack_rules_proto//third_party:bazel-gazelle-PR1274.patch",
"@build_stack_rules_proto//third_party:bazel-gazelle-revert-1152.patch",
],
patch_args = [
"-p1",
Expand Down
6 changes: 6 additions & 0 deletions deps/grpc_core_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ def com_google_protobuf():
urls = [
"https://github.com/protocolbuffers/protobuf/archive/v3.20.1.tar.gz",
],
patches = [
"@build_stack_rules_proto//third_party:com_google_protobuf.deploy-env.patch",
],
patch_args = [
"-p1",
],
)

def rules_jvm_external():
Expand Down
6 changes: 6 additions & 0 deletions deps/grpc_node_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ def com_google_protobuf():
urls = [
"https://github.com/protocolbuffers/protobuf/archive/v3.20.1.tar.gz",
],
patches = [
"@build_stack_rules_proto//third_party:com_google_protobuf.deploy-env.patch",
],
patch_args = [
"-p1",
],
)

def rules_jvm_external():
Expand Down
6 changes: 6 additions & 0 deletions deps/protobuf_core_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,10 @@ def com_google_protobuf():
urls = [
"https://github.com/protocolbuffers/protobuf/archive/v3.20.1.tar.gz",
],
patches = [
"@build_stack_rules_proto//third_party:com_google_protobuf.deploy-env.patch",
],
patch_args = [
"-p1",
],
)
41 changes: 24 additions & 17 deletions example/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -71,30 +71,37 @@
# gazelle:proto_language java rule grpc_java_library

## Scala ##
# gazelle:proto_plugin scala implementation scalapb:scalapb:protoc-gen-scala
# gazelle:proto_plugin scala option grpc
# gazelle:proto_plugin scala deps @com_google_protobuf//:protobuf_java
# gazelle:proto_plugin scala deps @maven_scala//:com_thesamet_scalapb_lenses_2_12
# gazelle:proto_plugin scala deps @maven_scala//:com_thesamet_scalapb_scalapb_runtime_2_12
# gazelle:proto_plugin scala deps @maven_scala//:com_thesamet_scalapb_scalapb_runtime_grpc_2_12
# gazelle:proto_plugin scala deps @maven_scala//:io_grpc_grpc_api
# gazelle:proto_plugin scala deps @maven_scala//:io_grpc_grpc_stub
# gazelle:proto_plugin scala deps @maven_scala//:io_grpc_grpc_protobuf

# gazelle:proto_plugin akka-grpc implementation akka:akka-grpc:protoc-gen-akka-grpc
# gazelle:proto_plugin akka-grpc deps @maven_akka//:com_lightbend_akka_grpc_akka_grpc_runtime_2_12
# gazelle:proto_plugin akka-grpc deps @maven_akka//:com_typesafe_akka_akka_actor_2_12
# gazelle:proto_plugin akka-grpc deps @maven_akka//:com_typesafe_akka_akka_http_core_2_12
# gazelle:proto_plugin akka-grpc deps @maven_akka//:com_typesafe_akka_akka_stream_2_12
# gazelle:proto_plugin protoc-gen-scala implementation scalapb:scalapb:protoc-gen-scala
# gazelle:proto_plugin protoc-gen-scala-grpc implementation scalapb:scalapb:protoc-gen-scala
# gazelle:proto_plugin protoc-gen-scala-grpc label @build_stack_rules_proto//plugin/scalapb/scalapb:protoc-gen-scala-grpc
# gazelle:proto_plugin protoc-gen-scala-grpc option grpc
# gazelle:proto_plugin protoc-gen-akka-grpc implementation akka:akka-grpc:protoc-gen-akka-grpc

# gazelle:proto_rule proto_scala_library implementation stackb:rules_proto:proto_scala_library
# gazelle:proto_rule proto_scala_library option --plugins=protoc-gen-scala
# gazelle:proto_rule proto_scala_library deps @maven_scala//:com_google_protobuf_protobuf_java
# gazelle:proto_rule proto_scala_library deps @maven_scala//:com_thesamet_scalapb_lenses_2_12
# gazelle:proto_rule proto_scala_library deps @maven_scala//:com_thesamet_scalapb_scalapb_runtime_2_12
# gazelle:proto_rule proto_scala_library visibility //visibility:public

# gazelle:proto_rule grpc_scala_library implementation stackb:rules_proto:grpc_scala_library
# gazelle:proto_rule grpc_scala_library option --plugins=protoc-gen-scala-grpc,protoc-gen-akka-grpc
# gazelle:proto_rule grpc_scala_library deps @maven_scala//:com_google_protobuf_protobuf_java
# gazelle:proto_rule grpc_scala_library deps @maven_scala//:com_thesamet_scalapb_lenses_2_12
# gazelle:proto_rule grpc_scala_library deps @maven_scala//:com_thesamet_scalapb_scalapb_runtime_2_12
# gazelle:proto_rule grpc_scala_library deps @maven_scala//:com_thesamet_scalapb_scalapb_runtime_grpc_2_12
# gazelle:proto_rule grpc_scala_library deps @maven_akka//:com_lightbend_akka_grpc_akka_grpc_runtime_2_12_2_1_3
# gazelle:proto_rule grpc_scala_library deps @maven_akka//:com_typesafe_akka_akka_actor_2_12
# gazelle:proto_rule grpc_scala_library deps @maven_akka//:com_typesafe_akka_akka_http_core_2_12
# gazelle:proto_rule grpc_scala_library deps @maven_akka//:com_typesafe_akka_akka_stream_2_12
# gazelle:proto_rule grpc_scala_library deps @maven_scala//:io_grpc_grpc_api
# gazelle:proto_rule grpc_scala_library deps @maven_scala//:io_grpc_grpc_protobuf
# gazelle:proto_rule grpc_scala_library deps @maven_scala//:io_grpc_grpc_stub
# gazelle:proto_rule grpc_scala_library visibility //visibility:public

# gazelle:proto_language scala plugin scala
# gazelle:proto_language scala plugin akka-grpc
# gazelle:proto_language scala plugin protoc-gen-scala
# gazelle:proto_language scala plugin protoc-gen-scala-grpc
# gazelle:proto_language scala plugin protoc-gen-akka-grpc
# gazelle:proto_language scala rule proto_compile
# gazelle:proto_language scala rule proto_scala_library
# gazelle:proto_language scala rule grpc_scala_library
Expand Down
11 changes: 7 additions & 4 deletions example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,27 @@ rules:
- name: proto_compile
implementation: stackb:rules_proto:proto_compile
visibility:
- //visibility:public
- //visibility:public
- name: proto_cc_library
implementation: stackb:rules_proto:proto_cc_library
visibility:
- //visibility:public
- //visibility:public
deps:
- "@com_google_protobuf//:protobuf"
- name: grpc_cc_library
implementation: stackb:rules_proto:grpc_cc_library
visibility:
- //visibility:public
- //visibility:public
deps:
- "@com_github_grpc_grpc//:grpc++"
- "@com_github_grpc_grpc//:grpc++_reflection"
- name: proto_go_library
implementation: stackb:rules_proto:proto_go_library
visibility:
- //visibility:public
- //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:
Expand Down
6 changes: 6 additions & 0 deletions example/golden/testdata/proto_repository/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
# proto_repository
# ----------------------------------------------------

# gazelle:repository go_repository name=org_golang_google_protobuf importpath=google.golang.org/protobuf
# gazelle:repository go_repository name=org_golang_x_net importpath=golang.org/x/net
# gazelle:repository go_repository name=org_golang_x_sys importpath=golang.org/x/sys
# gazelle:repository go_repository name=org_golang_x_text importpath=golang.org/x/text
# gazelle:repository go_repository name=org_golang_x_xerrors importpath=golang.org/x/xerrors

load("@build_stack_rules_proto//rules/proto:proto_repository.bzl", "proto_repository")

proto_repository(
Expand Down
14 changes: 9 additions & 5 deletions example/golden/testdata/proto_repository/config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
starlarkPlugins:
# protoc-gen-java duplicates the functionality of the
# builtin 'java' one, we have it here to test that it can
# be loaded via the YAML config.
# The format is IMPLEMENTATION_FILENAME%PLUGIN_NAME.
- starlark/plugins.star%protoc-gen-java
plugins:
- name: protoc-gen-go
implementation: golang:protobuf:protoc-gen-go
deps:
- "@org_golang_google_protobuf//reflect/protoreflect"
- "@org_golang_google_protobuf//runtime/protoimpl"

- name: protoc-gen-go-grpc
implementation: grpc:grpc-go:protoc-gen-go-grpc
deps:
Expand All @@ -14,13 +19,13 @@ plugins:

- name: java
implementation: builtin:java

- name: protoc-gen-java
implementation: starlark/plugins.star%protoc-gen-java
- name: protoc-gen-grpc-java
implementation: grpc:grpc-java:protoc-gen-grpc-java

- name: python
implementation: builtin:python

- name: protoc-gen-grpc-python
implementation: grpc:grpc:protoc-gen-grpc-python

Expand All @@ -44,7 +49,6 @@ rules:
- "//visibility:public"
deps:
- "@com_google_protobuf//:protobuf_java"

- name: grpc_java_library
implementation: stackb:rules_proto:grpc_java_library
visibility:
Expand All @@ -58,7 +62,6 @@ rules:
- "//visibility:public"
deps:
- "@tms_py_deps_protobuf//:pkg"

- name: grpc_py_library
implementation: stackb:rules_proto:grpc_py_library
visibility:
Expand All @@ -80,6 +83,7 @@ languages:
enabled: false
plugins:
- java
- protoc-gen-java
- protoc-gen-grpc-java
rules:
- proto_compile
Expand Down
28 changes: 28 additions & 0 deletions example/golden/testdata/proto_repository/starlark/plugins.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""starlark plugin definitions"""

def _configure_protoc_gen_java(ctx):
"""_configure_protoc_gen_java prepares the PluginConfiguration for a fictitious protoc java plugin.
Args:
ctx (protoc.PluginContext): The context object.
Returns:
config (PluginConfiguration): The configured PluginConfiguration object.
"""

srcjar = ctx.proto_library.base_name + ".srcjar"
if ctx.rel:
srcjar = "/".join(ctx.rel, srcjar)

config = protoc.PluginConfiguration(
label = "@build_stack_rules_proto//plugin/builtin:java",
outputs = [srcjar],
out = srcjar,
options = ctx.plugin_config.options,
)

return config

protoc.Plugin(
name = "protoc-gen-java",
configure = _configure_protoc_gen_java,
)
1 change: 1 addition & 0 deletions example/golden/testdata/starlark_java/BUILD.out
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ java_library(

proto_compile(
name = "example_java_compile",
outs = {"@build_stack_rules_proto//plugin/builtin:java": "example.srcjar"},
outputs = ["example.srcjar"],
plugins = ["@build_stack_rules_proto//plugin/builtin:java"],
proto = "example_proto",
Expand Down
Loading

0 comments on commit f170102

Please sign in to comment.