Apply yet more buildifier fixes

This commit is contained in:
Adam Liddell 2021-02-14 20:14:48 +00:00
parent 247cba9a4d
commit 7012cefcf8
116 changed files with 465 additions and 210 deletions

View File

@ -1,16 +1,16 @@
workspace(name = "rules_proto_grpc")
load("//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains")
#
# Toolchains
#
load("//:repositories.bzl", "rules_proto_grpc_toolchains")
rules_proto_grpc_toolchains()
#
# Core
#
load("//:repositories.bzl", "rules_proto_grpc_repos")
rules_proto_grpc_repos()
@ -28,8 +28,7 @@ load("//android:repositories.bzl", "android_repos")
android_repos()
load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS", "grpc_java_repositories")
maven_install(
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS,
@ -44,8 +43,6 @@ load("@maven//:compat.bzl", "compat_repositories")
compat_repositories()
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
grpc_java_repositories()
load("@build_bazel_rules_android//android:sdk_repository.bzl", "android_sdk_repository")
@ -75,7 +72,7 @@ rules_closure_toolchains()
# Load rules_go before running grpc_deps in C++, since that depends on a very old version of
# rules_go
#
load("//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()
@ -330,7 +327,7 @@ swift_rules_dependencies()
#
# Misc
#
load("@bazel_gazelle//:deps.bzl", "go_repository")
load("@bazel_gazelle//:deps.bzl", "go_repository") # buildifier: disable=same-origin-load
go_repository(
name = "com_github_urfave_cli",

View File

@ -65,8 +65,7 @@ load("@rules_proto_grpc//android:repositories.bzl", rules_proto_grpc_android_rep
rules_proto_grpc_android_repos()
load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS", "grpc_java_repositories")
maven_install(
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS,
@ -81,8 +80,6 @@ load("@maven//:compat.bzl", "compat_repositories")
compat_repositories()
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
grpc_java_repositories()
```
@ -125,8 +122,7 @@ load("@rules_proto_grpc//android:repositories.bzl", rules_proto_grpc_android_rep
rules_proto_grpc_android_repos()
load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS", "grpc_java_repositories")
maven_install(
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS,
@ -141,8 +137,6 @@ load("@maven//:compat.bzl", "compat_repositories")
compat_repositories()
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
grpc_java_repositories()
load("@build_bazel_rules_android//android:sdk_repository.bzl", "android_sdk_repository")
@ -196,8 +190,7 @@ load("@rules_proto_grpc//android:repositories.bzl", rules_proto_grpc_android_rep
rules_proto_grpc_android_repos()
load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS", "grpc_java_repositories")
maven_install(
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS,
@ -212,8 +205,6 @@ load("@maven//:compat.bzl", "compat_repositories")
compat_repositories()
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
grpc_java_repositories()
load("@build_bazel_rules_android//android:sdk_repository.bzl", "android_sdk_repository")

View File

@ -1,3 +1,5 @@
"""Generated definition of android_grpc_library."""
load("//android:android_grpc_compile.bzl", "android_grpc_compile")
load("@build_bazel_rules_android//android:rules.bzl", "android_library")

View File

@ -1,3 +1,5 @@
"""Generated definition of android_proto_library."""
load("//android:android_proto_compile.bzl", "android_proto_compile")
load("@build_bazel_rules_android//android:rules.bzl", "android_library")

View File

@ -1,3 +1,4 @@
load("@rules_android//android:rules.bzl", "android_binary")
load("//android:defs.bzl", "android_grpc_library")
android_grpc_library(

View File

@ -1,3 +1,5 @@
"""Common dependencies for rules_proto_grpc Android rules."""
load(
"//:repositories.bzl",
"build_bazel_rules_android",
@ -6,7 +8,7 @@ load(
"rules_proto_grpc_repos",
)
def android_repos(**kwargs):
def android_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
io_grpc_grpc_java(**kwargs)
rules_jvm_external(**kwargs)

View File

@ -1,3 +1,5 @@
"""Generated definition of closure_proto_library."""
load("//closure:closure_proto_compile.bzl", "closure_proto_compile")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")

View File

@ -2,8 +2,6 @@ load(
"@io_bazel_rules_closure//closure:defs.bzl",
"closure_js_binary",
"closure_js_library",
"closure_js_test",
# "closure_proto_library",
)
load("//closure:defs.bzl", "closure_proto_library")

View File

@ -1,9 +1,11 @@
"""Common dependencies for rules_proto_grpc Closure rules."""
load(
"//:repositories.bzl",
"io_bazel_rules_closure",
"rules_proto_grpc_repos",
)
def closure_repos(**kwargs):
def closure_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
io_bazel_rules_closure(**kwargs)

View File

@ -1,3 +1,6 @@
"""Generated definition of cpp_grpc_library."""
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//cpp:cpp_grpc_compile.bzl", "cpp_grpc_compile")
def cpp_grpc_library(**kwargs):
@ -9,7 +12,7 @@ def cpp_grpc_library(**kwargs):
)
# Create cpp library
native.cc_library(
cc_library(
name = kwargs.get("name"),
srcs = [name_pb],
deps = GRPC_DEPS + (kwargs.get("deps", []) if "protos" in kwargs else []),

View File

@ -1,3 +1,6 @@
"""Generated definition of cpp_proto_library."""
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//cpp:cpp_proto_compile.bzl", "cpp_proto_compile")
def cpp_proto_library(**kwargs):
@ -9,7 +12,7 @@ def cpp_proto_library(**kwargs):
)
# Create cpp library
native.cc_library(
cc_library(
name = kwargs.get("name"),
srcs = [name_pb],
deps = PROTO_DEPS + (kwargs.get("deps", []) if "protos" in kwargs else []),

View File

@ -1,12 +1,13 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("//cpp:defs.bzl", "cpp_grpc_library")
package(default_visibility = ["//visibility:public"])
cpp_grpc_library(
name = "routeguide",
protos = ["//example/proto:routeguide_proto"],
)
package(default_visibility = ["//visibility:public"])
cc_test(
name = "feature_test",
size = "small",

View File

@ -1,7 +1,9 @@
"""Common dependencies for rules_proto_grpc C++ rules."""
load(
"//:repositories.bzl",
"rules_proto_grpc_repos",
)
def cpp_repos(**kwargs):
def cpp_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)

View File

@ -1,3 +1,5 @@
"""Generated definition of csharp_grpc_library."""
load("//csharp:csharp_grpc_compile.bzl", "csharp_grpc_compile")
load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "core_library")

View File

@ -1,3 +1,5 @@
"""Generated definition of csharp_proto_library."""
load("//csharp:csharp_proto_compile.bzl", "csharp_proto_compile")
load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "core_library")

View File

@ -1,3 +1,5 @@
"""Generated nuget packages"""
load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "nuget_package")
# Backwards compatibility definitions
@ -13,8 +15,8 @@ def no_op():
pass
def nuget_rules_proto_grpc_packages():
"""Nuget packages"""
no_op()
### Generated by the tool
nuget_package(
name = "system.buffers",

View File

@ -55,3 +55,6 @@ fi
# Patch missing Grpc.Core runtimes into nuget_package
cat "${OUTPUT_DIR}/${FILE_NAME}" | python3 -c "import sys; patch = open('${OUTPUT_DIR}/${FILE_NAME}.patch').read(); sys.stdout.write(sys.stdin.read().replace('Grpc.Core.xml\",', 'Grpc.Core.xml\",' + patch))" | sponge "${OUTPUT_DIR}/${FILE_NAME}"
# Patch in buildifier fixes
cat "${OUTPUT_DIR}/${FILE_NAME}" | python3 -c "import sys; sys.stdout.write('\"\"\"Generated nuget packages\"\"\"\n\n' + sys.stdin.read().replace('def nuget_rules_proto_grpc_packages():', 'def nuget_rules_proto_grpc_packages():\n \"\"\"Nuget packages\"\"\"'))" | sponge "${OUTPUT_DIR}/${FILE_NAME}"

View File

@ -1,9 +1,11 @@
"""Common dependencies for rules_proto_grpc C# rules."""
load(
"//:repositories.bzl",
"io_bazel_rules_dotnet",
"rules_proto_grpc_repos",
)
def csharp_repos(**kwargs):
def csharp_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
io_bazel_rules_dotnet(**kwargs)

View File

@ -1,3 +1,5 @@
"""Generated definition of d_proto_library."""
load("//d:d_proto_compile.bzl", "d_proto_compile")
load("@io_bazel_rules_d//d:d.bzl", "d_library")

View File

@ -1,5 +1,4 @@
load("//d:defs.bzl", "d_proto_compile")
load("@io_bazel_rules_d//d:d.bzl", "d_library")
d_proto_compile(
name = "routeguide",

View File

@ -1,3 +1,5 @@
"""Common dependencies for rules_proto_grpc D rules."""
load(
"//:repositories.bzl",
"com_github_dcarp_protobuf_d",
@ -5,7 +7,7 @@ load(
"rules_proto_grpc_repos",
)
def d_repos(**kwargs):
def d_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
com_github_dcarp_protobuf_d(**kwargs)
io_bazel_rules_d(**kwargs)

View File

@ -1,3 +1,5 @@
"""Top level definition exports for rules_proto_grpc."""
load("//internal:compile.bzl", _proto_compile_aspect_attrs = "proto_compile_aspect_attrs", _proto_compile_aspect_impl = "proto_compile_aspect_impl", _proto_compile_attrs = "proto_compile_attrs", _proto_compile_impl = "proto_compile_impl")
load("//internal:plugin.bzl", _proto_plugin = "proto_plugin")
load("//internal:providers.bzl", _ProtoCompileInfo = "ProtoCompileInfo", _ProtoLibraryAspectNodeInfo = "ProtoLibraryAspectNodeInfo", _ProtoPluginInfo = "ProtoPluginInfo")

View File

@ -20,8 +20,7 @@ load("@rules_proto_grpc//android:repositories.bzl", rules_proto_grpc_android_rep
rules_proto_grpc_android_repos()
load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS", "grpc_java_repositories")
maven_install(
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS,
@ -36,6 +35,4 @@ load("@maven//:compat.bzl", "compat_repositories")
compat_repositories()
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
grpc_java_repositories()

View File

@ -20,8 +20,7 @@ load("@rules_proto_grpc//android:repositories.bzl", rules_proto_grpc_android_rep
rules_proto_grpc_android_repos()
load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS", "grpc_java_repositories")
maven_install(
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS,
@ -36,8 +35,6 @@ load("@maven//:compat.bzl", "compat_repositories")
compat_repositories()
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
grpc_java_repositories()
load("@build_bazel_rules_android//android:sdk_repository.bzl", "android_sdk_repository")

View File

@ -22,8 +22,7 @@ load("@rules_proto_grpc//android:repositories.bzl", rules_proto_grpc_android_rep
rules_proto_grpc_android_repos()
load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS", "grpc_java_repositories")
maven_install(
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS,
@ -38,8 +37,6 @@ load("@maven//:compat.bzl", "compat_repositories")
compat_repositories()
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
grpc_java_repositories()
load("@build_bazel_rules_android//android:sdk_repository.bzl", "android_sdk_repository")

View File

@ -15,7 +15,7 @@ rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()

View File

@ -15,7 +15,7 @@ rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()

View File

@ -15,7 +15,7 @@ rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()

View File

@ -15,7 +15,7 @@ rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()

View File

@ -15,7 +15,7 @@ rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()

View File

@ -15,7 +15,7 @@ rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()

View File

@ -15,7 +15,7 @@ rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()

View File

@ -20,8 +20,7 @@ load("@rules_proto_grpc//java:repositories.bzl", rules_proto_grpc_java_repos = "
rules_proto_grpc_java_repos()
load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS", "grpc_java_repositories")
maven_install(
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS,
@ -36,6 +35,4 @@ load("@maven//:compat.bzl", "compat_repositories")
compat_repositories()
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
grpc_java_repositories()

View File

@ -1,3 +1,5 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
proto_library(
name = "person_proto",
srcs = ["person.proto"],

View File

@ -1,4 +1,4 @@
load("//example/routeguide:routeguide_test.bzl", "routeguide_test", "routeguide_test_matrix")
load("//example/routeguide:routeguide_test.bzl", "routeguide_test_matrix")
#
# This generates a set of routeguide_test rules, one for each combination of
@ -10,6 +10,7 @@ load("//example/routeguide:routeguide_test.bzl", "routeguide_test", "routeguide_
#
routeguide_test_matrix(
name = "routeguide_matrix",
clients = [
"//cpp/example/routeguide:client",
"//csharp/example/routeguide:client.exe",

View File

@ -1,3 +1,7 @@
"""Definition of the routeguide test and matrix rules."""
load("//internal:common.bzl", "get_parent_dirname")
def _routeguide_test_impl(ctx):
# Build test execution script
ctx.actions.write(ctx.outputs.executable, """set -x # Print commands
@ -68,13 +72,21 @@ routeguide_test = rule(
test = True,
)
def get_parent_dirname(label):
if label.startswith("//"):
label = label[2:]
return label.partition("/")[0]
def routeguide_test_matrix(name = "", clients = [], servers = [], database = "//example/proto:routeguide_features", tagmap = {}):
"""
Build a matrix of tests that checks every client against every server.
def routeguide_test_matrix(clients = [], servers = [], database = "//example/proto:routeguide_features", tagmap = {}):
"""Build a matrix of tests that checks every client against every server"""
Args:
name: The rule name, unused.
clients: The list of available routeguide clients.
servers: The list of available routeguide servers.
database: The features list to provide to the test.
tagmap: The dict of tags to apply to specific languages or tests ("lang" or "lang_lang").
Returns:
Nothing.
"""
port = 50051
for server in servers:
server_name = get_parent_dirname(server)

View File

@ -18,7 +18,7 @@ Generates Go protobuf `.go` artifacts
### `WORKSPACE`
```starlark
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()
@ -78,7 +78,7 @@ Generates Go protobuf+gRPC `.go` artifacts
### `WORKSPACE`
```starlark
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()
@ -133,7 +133,7 @@ Generates a Go protobuf library using `go_library` from `rules_go`
### `WORKSPACE`
```starlark
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()
@ -190,7 +190,7 @@ Generates a Go protobuf+gRPC library using `go_library` from `rules_go`
### `WORKSPACE`
```starlark
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()

View File

@ -1,3 +1,5 @@
"""Generated definition of go_grpc_library."""
load("//go:go_proto_library.bzl", "PROTO_DEPS")
load("//go:go_grpc_compile.bzl", "go_grpc_compile")
load("@io_bazel_rules_go//go:def.bzl", "go_library")

View File

@ -1,3 +1,5 @@
"""Generated definition of go_proto_library."""
load("//go:go_proto_compile.bzl", "go_proto_compile")
load("@io_bazel_rules_go//go:def.bzl", "go_library")

View File

@ -1,3 +1,5 @@
"""Common dependencies for rules_proto_grpc Go rules."""
load(
"//:repositories.bzl",
"io_bazel_rules_go",
@ -5,7 +7,7 @@ load(
)
load("@bazel_gazelle//:deps.bzl", "go_repository")
def go_repos(**kwargs):
def go_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
io_bazel_rules_go(**kwargs)

View File

@ -15,7 +15,7 @@ Generates grpc-gateway `.go` files
### `WORKSPACE`
```starlark
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()
@ -69,7 +69,7 @@ Generates grpc-gateway OpenAPI v2 `.json` files
### `WORKSPACE`
```starlark
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()
@ -123,7 +123,7 @@ Generates grpc-gateway library files
### `WORKSPACE`
```starlark
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()

View File

@ -1,5 +1,5 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//grpc-gateway:defs.bzl", "gateway_grpc_library", "gateway_openapiv2_compile")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
proto_library(
name = "api_proto",

View File

@ -1,6 +1,7 @@
"""Generated definition of gateway_grpc_library."""
load("//grpc-gateway:gateway_grpc_compile.bzl", "gateway_grpc_compile")
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//go:go_proto_library.bzl", "PROTO_DEPS")
load("//go:go_grpc_library.bzl", "GRPC_DEPS")
def gateway_grpc_library(**kwargs):

View File

@ -1,3 +1,5 @@
"""Common dependencies for rules_proto_grpc grpc-gateway rules."""
load(
"//:repositories.bzl",
"bazel_gazelle",
@ -7,7 +9,7 @@ load(
)
load("@bazel_gazelle//:deps.bzl", "go_repository")
def gateway_repos(**kwargs):
def gateway_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
io_bazel_rules_go(**kwargs)
bazel_gazelle(**kwargs)

View File

@ -1,8 +1,10 @@
"""Generated definition of closure_grpc_library."""
load("//grpc-web:closure_grpc_compile.bzl", "closure_grpc_compile")
load("//closure:closure_proto_compile.bzl", "closure_proto_compile")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")
def closure_grpc_library(**kwargs):
def closure_grpc_library(**kwargs): # buildifier: disable=function-docstring
# Compile protos
name_pb = kwargs.get("name") + "_pb"
name_pb_grpc = kwargs.get("name") + "_pb_grpc"

View File

@ -1,3 +1,5 @@
"""Common dependencies for rules_proto_grpc gRPC web rules."""
load(
"//:repositories.bzl",
"com_github_grpc_grpc_web",
@ -7,6 +9,6 @@ load(
"closure_repos",
)
def grpc_web_repos(**kwargs):
def grpc_web_repos(**kwargs): # buildifier: disable=function-docstring
closure_repos(**kwargs)
com_github_grpc_grpc_web(**kwargs)

View File

@ -1,3 +1,5 @@
"""Common generic rules used by rules_proto_grpc."""
_rust_keywords = [
"as",
"break",
@ -42,18 +44,20 @@ _objc_upper_segments = {
}
def capitalize(s):
"""Capitalize a string - only first letter
"""
Capitalize a string - only first letter
Args:
s (string): The input string to be capitalized.
s (string): The input string to be capitalized.
Returns:
(string): The capitalized string.
(string): The capitalized string.
"""
return s[0:1].upper() + s[1:]
def pascal_objc(s):
"""Convert pascal_case -> PascalCase
"""
Convert pascal_case -> PascalCase
Objective C uses pascal case, but there are e exceptions that it uppercases
the entire segment: url, http, and https.
@ -61,9 +65,11 @@ def pascal_objc(s):
https://github.com/protocolbuffers/protobuf/blob/54176b26a9be6c9903b375596b778f51f5947921/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc#L91
Args:
s (string): The input string to be capitalized.
s (string): The input string to be capitalized.
Returns:
(string): The capitalized string.
Returns: (string): The capitalized string.
"""
segments = []
for segment in s.split("_"):
@ -76,31 +82,36 @@ def pascal_objc(s):
return "".join(segments)
def pascal_case(s):
"""Convert pascal_case -> PascalCase
"""
Convert pascal_case -> PascalCase
Args:
s (string): The input string to be capitalized.
Returns:
(string): The capitalized string.
"""
return "".join([capitalize(part) for part in s.split("_")])
def rust_keyword(s):
"""Check if arg is a rust keyword and append '_pb' if true.
"""
Check if arg is a rust keyword and append '_pb' if true.
Args:
s (string): The input string to be capitalized.
Returns:
(string): The appended string.
"""
return s + "_pb" if s in _rust_keywords else s
def python_path(s):
"""Convert a path string to a python import compatible path as is generated
by the python plugin. Python import paths cannot contain dashes, so these
are replaced by underscores.
"""
Convert a path string to a python import compatible path as is generated by the python plugin.
Python import paths cannot contain dashes, so these are replaced by underscores.
See https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/python/python_generator.cc#L89-L95
Args:
@ -108,21 +119,35 @@ def python_path(s):
Returns:
(string): The converted string.
"""
return s.replace("-", "_")
def php_path(s):
"""Convert a path string to a php path as is generated by the php plugin.
"""
Convert a path string to a php path as is generated by the php plugin.
Args:
s (string): The input string to be converted.
Returns:
(string): The converted string.
"""
return "/".join([capitalize(c) for c in s.split("/")])
def get_int_attr(attr, name):
"""
Get an attr as an int from a string, with fallbacks.
Args:
attr: The attr object from ctx.
name: The attr name to load.
Returns:
The attr value as an int.
"""
value = getattr(attr, name)
if value == "":
return 0
@ -131,7 +156,8 @@ def get_int_attr(attr, name):
return int(value)
def get_output_filename(src_file, pattern, proto_info):
"""Build the predicted filename for file generated by the given plugin.
"""
Build the predicted filename for file generated by the given plugin.
A 'proto_plugin' rule allows one to define the predicted outputs. For
flexibility, we allow special tokens in the output filename that get
@ -142,12 +168,13 @@ def get_output_filename(src_file, pattern, proto_info):
read as 'take the basename and pipe that through the pascal function'.
Args:
src_file: the .proto <File>
pattern: the input pattern string
proto_info: The <ProtoInfo> object
src_file: the .proto <File>
pattern: the input pattern string
proto_info: The <ProtoInfo> object
Returns:
the replaced string
The replaced string
"""
# Get proto path and strip extension
@ -205,16 +232,18 @@ def get_output_filename(src_file, pattern, proto_info):
return filename
def copy_file(ctx, src_file, dest_path, sibling = None):
"""Copy a file to a new path destination
"""
Copy a file to a new path destination
Args:
ctx: the <ctx> object
src_file: the source file <File>
dest_path: the destination path of the file
sibling: a file to use as a sibling to declare_file <File>
ctx: the <ctx> object
src_file: the source file <File>
dest_path: the destination path of the file
sibling: a file to use as a sibling to declare_file <File>
Returns:
<Generated File> for the copied file
<Generated File> for the copied file
"""
dest_file = ctx.actions.declare_file(dest_path, sibling = sibling)
ctx.actions.run_shell(
@ -231,6 +260,14 @@ def descriptor_proto_path(proto, proto_info):
Convert a proto File to the path within the descriptor file.
Adapted from https://github.com/bazelbuild/rules_go
Args:
proto: The proto file.
proto_info: The ProtoInfo provider the file is from.
Returns:
The path to the proto file, as seen when making the descriptor.
"""
# Strip proto_source_root
@ -246,7 +283,15 @@ def descriptor_proto_path(proto, proto_info):
def strip_path_prefix(path, prefix):
"""
Strip a prefix from a path if it exists and any remaining prefix slashes
Strip a prefix from a path if it exists and any remaining prefix slashes.
Args:
path: The path string to strip.
prefix: The prefix to remove.
Returns:
The stripped path. If the prefix is not present, this will be the same as the input.
"""
if path.startswith(prefix):
path = path[len(prefix):]
@ -256,9 +301,16 @@ def strip_path_prefix(path, prefix):
def parse_version(version_str):
"""
Parse the bazel version string, returning a tuple
Parse the bazel version string, returning a tuple.
Derived from https://github.com/tensorflow/tensorflow/blob/master/tensorflow/version_check.bzl
Args:
version_str: The version string to parse.
Returns:
The tuple of version elements.
"""
# Extract just the semver part
@ -270,9 +322,16 @@ def parse_version(version_str):
# Check that a specific bazel version is being used.
def check_bazel_minimum_version(minimum_bazel_version):
"""
Check that the bazel version meets or exceeds the required version
Check that the bazel version meets or exceeds the required version.
Derived from https://github.com/tensorflow/tensorflow/blob/master/tensorflow/version_check.bzl
Args:
minimum_bazel_version: The minimum supported version
Returns:
Nothing
"""
# Check for bazel versions that did not support version checking
@ -281,7 +340,7 @@ def check_bazel_minimum_version(minimum_bazel_version):
# Check for non-release versions
if not native.bazel_version:
print("Bazel is not a release version, rules_proto_grpc requires at least {}".format(minimum_bazel_version))
print("Bazel is not a release version, rules_proto_grpc requires at least {}".format(minimum_bazel_version)) # buildifier: disable=print
return
# Check version strings
@ -296,7 +355,16 @@ def check_bazel_minimum_version(minimum_bazel_version):
)
def get_package_root(ctx):
"""Get the full path to the package output directory, relative to workspace root"""
"""
Get the full path to the package output directory, relative to workspace root.
Args:
ctx: The Bazel rule execution context object.
Returns:
The full path.
"""
package_root = ctx.bin_dir.path
if ctx.label.workspace_root:
package_root += "/" + ctx.label.workspace_root
@ -304,3 +372,18 @@ def get_package_root(ctx):
package_root += "/" + ctx.label.package
return package_root
def get_parent_dirname(label):
"""
Get the name of the parent directory of a label.
Args:
label: The label to get the parent directory of.
Returns:
The name of the parent directory.
"""
if label.startswith("//"):
label = label[2:]
return label.partition("/")[0]

View File

@ -1,3 +1,5 @@
"""Compilation rules definition for rules_proto_grpc."""
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
load(
"//internal:common.bzl",
@ -37,6 +39,21 @@ proto_compile_aspect_attrs = {
}
def common_compile(ctx, proto_infos):
"""
Common implementation of protoc setup and compilation action generation.
Args:
ctx: The Bazel rule execution context object.
proto_infos: The ProtoInfo providers to load direct sources from.
Returns:
Struct with fields:
- output_root: The root of the generated files, relative to workspace root
- output_files: Any files generated by the plugins
- output_dirs: ANy directories generated by the plugins
"""
###
### Setup common state
###
@ -138,7 +155,7 @@ def common_compile(ctx, proto_infos):
if verbose > 2:
print(
'Skipping plugin "{}" for "{}" as all proto files have been excluded'.format(plugin.name, ctx.label),
)
) # buildifier: disable=print
continue
# Append current plugin outputs to global outputs before looking at per-plugin outputs; these are manually added
@ -282,7 +299,7 @@ def common_compile(ctx, proto_infos):
# Amend command with debug options
if verbose > 0:
print("{}:".format(mnemonic), protoc.path, args)
print("{}:".format(mnemonic), protoc.path, args) # buildifier: disable=print
if verbose > 1:
command += " && echo '\n##### SANDBOX AFTER RUNNING PROTOC' && find . -type f "
@ -293,13 +310,13 @@ def common_compile(ctx, proto_infos):
if verbose > 3:
command = "env && " + command
for f in inputs:
print("INPUT:", f.path)
print("INPUT:", f.path) # buildifier: disable=print
for f in protos:
print("TARGET PROTO:", f.path)
print("TARGET PROTO:", f.path) # buildifier: disable=print
for f in tools:
print("TOOL:", f.path)
print("TOOL:", f.path) # buildifier: disable=print
for f in plugin_outputs:
print("EXPECTED OUTPUT:", f.path)
print("EXPECTED OUTPUT:", f.path) # buildifier: disable=print
# Run protoc
ctx.actions.run_shell(
@ -322,6 +339,19 @@ def common_compile(ctx, proto_infos):
)
def proto_compile_impl(ctx):
"""
Common implementation function for lang_*_compile rules.
Args:
ctx: The Bazel rule execution context object.
Returns:
Providers:
- ProtoCompileInfo
- DefaultInfo
"""
if ctx.attr.protos and ctx.attr.deps:
fail("Inputs provided to both 'protos' and 'deps' attrs of target {}. Use exclusively 'protos' or 'deps'".format(ctx.label))
@ -339,7 +369,7 @@ def proto_compile_impl(ctx):
elif ctx.attr.deps:
# TODO: add link to below
print("Inputs provided to 'deps' attr of target {}. Consider replacing with 'protos' attr to avoid transitive compilation".format(ctx.label))
print("Inputs provided to 'deps' attr of target {}. Consider replacing with 'protos' attr to avoid transitive compilation".format(ctx.label)) # buildifier: disable=print
# Aggregate all output files and dirs created by the aspect as it has walked the deps. Legacy behaviour
output_files_dicts = [dep[ProtoLibraryAspectNodeInfo].output_files for dep in ctx.attr.deps]
@ -412,7 +442,7 @@ def proto_compile_impl(ctx):
if ctx.attr.verbose > 2:
command_parts = ["echo '\n##### SANDBOX BEFORE MERGING DIRECTORIES'", "find . -type l"] + command_parts
if ctx.attr.verbose > 0:
print("Directory merge command: {}".format(" && ".join(command_parts)))
print("Directory merge command: {}".format(" && ".join(command_parts))) # buildifier: disable=print
# Copy directories and files to shared output directory in one action
ctx.actions.run_shell(
@ -473,6 +503,19 @@ def proto_compile_impl(ctx):
]
def proto_compile_aspect_impl(target, ctx):
"""
Common implementation function for lang_*_compile aspects.
Args:
target: The aspect target.
ctx: The Bazel rule execution context object.
Returns:
Providers:
- ProtoLibraryAspectNodeInfo
"""
# Load ProtoInfo of the current node
if ProtoInfo not in target: # Skip non-proto targets, which we may get intermingled prior to deps deprecation
return []

View File

@ -1,3 +1,5 @@
"""Plugin rules definition for rules_proto_grpc."""
load("//internal:providers.bzl", "ProtoPluginInfo")
def _proto_plugin_impl(ctx):

View File

@ -1,3 +1,5 @@
"""Provider definitions for rules_proto_grpc."""
ProtoPluginInfo = provider(fields = {
"name": "The proto plugin name",
"options": "A list of options to pass to the compiler for this plugin",

View File

@ -148,8 +148,7 @@ load("@rules_proto_grpc//java:repositories.bzl", rules_proto_grpc_java_repos = "
rules_proto_grpc_java_repos()
load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS")
load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS", "grpc_java_repositories")
maven_install(
artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS,
@ -164,8 +163,6 @@ load("@maven//:compat.bzl", "compat_repositories")
compat_repositories()
load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories")
grpc_java_repositories()
```

View File

@ -1,3 +1,4 @@
load("@rules_java//java:defs.bzl", "java_binary")
load("//java:defs.bzl", "java_grpc_library")
java_grpc_library(

View File

@ -1,3 +1,6 @@
"""Generated definition of java_grpc_library."""
load("@rules_java//java:defs.bzl", "java_library")
load("//java:java_grpc_compile.bzl", "java_grpc_compile")
def java_grpc_library(**kwargs):
@ -9,7 +12,7 @@ def java_grpc_library(**kwargs):
)
# Create java library
native.java_library(
java_library(
name = kwargs.get("name"),
srcs = [name_pb],
deps = GRPC_DEPS + (kwargs.get("deps", []) if "protos" in kwargs else []),

View File

@ -1,3 +1,6 @@
"""Generated definition of java_proto_library."""
load("@rules_java//java:defs.bzl", "java_library")
load("//java:java_proto_compile.bzl", "java_proto_compile")
def java_proto_library(**kwargs):
@ -9,7 +12,7 @@ def java_proto_library(**kwargs):
)
# Create java library
native.java_library(
java_library(
name = kwargs.get("name"),
srcs = [name_pb],
deps = PROTO_DEPS + (kwargs.get("deps", []) if "protos" in kwargs else []),

View File

@ -1,3 +1,5 @@
"""Common dependencies for rules_proto_grpc Java rules."""
load(
"//:repositories.bzl",
"io_grpc_grpc_java",
@ -5,7 +7,7 @@ load(
"rules_proto_grpc_repos",
)
def java_repos(**kwargs):
def java_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
io_grpc_grpc_java(**kwargs)
rules_jvm_external(**kwargs)

View File

@ -1,3 +1,5 @@
"""Generated definition of nodejs_grpc_library."""
load("//nodejs:nodejs_grpc_compile.bzl", "nodejs_grpc_compile")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")

View File

@ -1,3 +1,5 @@
"""Generated definition of nodejs_proto_library."""
load("//nodejs:nodejs_proto_compile.bzl", "nodejs_proto_compile")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")

View File

@ -1,9 +1,11 @@
"""Common dependencies for rules_proto_grpc NodeJS rules."""
load(
"//:repositories.bzl",
"build_bazel_rules_nodejs",
"rules_proto_grpc_repos",
)
def nodejs_repos(**kwargs):
def nodejs_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
build_bazel_rules_nodejs(**kwargs)

View File

@ -1,3 +1,6 @@
"""Generated definition of objc_proto_library."""
load("@rules_cc//cc:defs.bzl", "objc_library")
load("//objc:objc_proto_compile.bzl", "objc_proto_compile")
def objc_proto_library(**kwargs):
@ -9,7 +12,7 @@ def objc_proto_library(**kwargs):
)
# Create objc library
native.objc_library(
objc_library(
name = kwargs.get("name"),
srcs = [name_pb],
deps = PROTO_DEPS + (kwargs.get("deps", []) if "protos" in kwargs else []),

View File

@ -1,7 +1,9 @@
"""Common dependencies for rules_proto_grpc Objective-C rules."""
load(
"//:repositories.bzl",
"rules_proto_grpc_repos",
)
def objc_repos(**kwargs):
def objc_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)

View File

@ -1,7 +1,9 @@
"""Common dependencies for rules_proto_grpc PHP rules."""
load(
"//:repositories.bzl",
"rules_proto_grpc_repos",
)
def php_repos(**kwargs):
def php_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)

View File

@ -1,3 +1,5 @@
"""Toolchain definitions for rules_proto_grpc."""
def _protoc_toolchain_impl(ctx):
return [platform_common.ToolchainInfo(
protoc_target = ctx.attr.protoc,

View File

@ -1,3 +1,4 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
load("//python:defs.bzl", "python_grpc_library")
python_grpc_library(

View File

@ -1,3 +1,5 @@
"""Generated definition of python_grpc_library."""
load("//python:python_grpc_compile.bzl", "python_grpc_compile")
load("@rules_python//python:defs.bzl", "py_library")

View File

@ -1,3 +1,5 @@
"""Generated definition of python_grpclib_library."""
load("//python:python_grpclib_compile.bzl", "python_grpclib_compile")
load("@rules_python//python:defs.bzl", "py_library")

View File

@ -1,3 +1,5 @@
"""Generated definition of python_proto_library."""
load("//python:python_proto_compile.bzl", "python_proto_compile")
load("@rules_python//python:defs.bzl", "py_library")

View File

@ -1,3 +1,5 @@
"""Common dependencies for rules_proto_grpc Python rules."""
load(
"//:repositories.bzl",
"rules_proto_grpc_repos",
@ -5,7 +7,7 @@ load(
"subpar",
)
def python_repos(**kwargs):
def python_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
subpar(**kwargs)
six(**kwargs)

View File

@ -1,3 +1,5 @@
"""Common dependencies for rules_proto_grpc."""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//internal:common.bzl", "check_bazel_minimum_version")
@ -299,9 +301,9 @@ def _generic_dependency(name, **kwargs):
sha256 = kwargs.get(name + "_sha256", dep["sha256"])
# Fix GitHub naming quirk in path
strippedRef = ref
if strippedRef.startswith("v"):
strippedRef = ref[1:]
stripped_ref = ref
if stripped_ref.startswith("v"):
stripped_ref = ref[1:]
# Generate URLs
urls = [
@ -312,7 +314,7 @@ def _generic_dependency(name, **kwargs):
if name not in existing_rules:
http_archive(
name = name,
strip_prefix = dep["repo"] + "-" + strippedRef,
strip_prefix = dep["repo"] + "-" + stripped_ref,
urls = urls,
sha256 = sha256,
**{k: v for k, v in dep.items() if k in ["build_file", "patch_cmds"]}
@ -322,14 +324,14 @@ def _generic_dependency(name, **kwargs):
print("Dependency '{}' has already been declared with a different rule kind. Found {}, expected http_archive".format(
name,
existing_rules[name]["kind"],
))
)) # buildifier: disable=print
elif existing_rules[name]["urls"] != tuple(urls):
if ENABLE_VERSION_NAGS:
print("Dependency '{}' has already been declared with a different version. Found urls={}, expected {}".format(
name,
existing_rules[name]["urls"],
tuple(urls),
))
)) # buildifier: disable=print
elif dep["type"] == "http":
if name not in existing_rules:
@ -340,14 +342,14 @@ def _generic_dependency(name, **kwargs):
print("Dependency '{}' has already been declared with a different rule kind. Found {}, expected http_archive".format(
name,
existing_rules[name]["kind"],
))
)) # buildifier: disable=print
elif existing_rules[name]["urls"] != tuple(dep["urls"]):
if ENABLE_VERSION_NAGS:
print("Dependency '{}' has already been declared with a different version. Found urls={}, expected {}".format(
name,
existing_rules[name]["urls"],
tuple(dep["urls"]),
))
)) # buildifier: disable=print
elif dep["type"] == "local":
if name not in existing_rules:
@ -358,14 +360,14 @@ def _generic_dependency(name, **kwargs):
print("Dependency '{}' has already been declared with a different rule kind. Found {}, expected local_repository".format(
name,
existing_rules[name]["kind"],
))
)) # buildifier: disable=print
elif existing_rules[name]["path"] != dep["path"]:
if ENABLE_VERSION_NAGS:
print("Dependency '{}' has already been declared with a different version. Found path={}, expected {}".format(
name,
existing_rules[name]["path"],
dep["urls"],
))
)) # buildifier: disable=print
else:
fail("Unknown dependency type {}".format(dep))
@ -381,7 +383,8 @@ def _generic_dependency(name, **kwargs):
#
# Toolchains
#
def rules_proto_grpc_toolchains():
def rules_proto_grpc_toolchains(name = ""):
"""Register the rules_proto_grpc toolchains."""
check_bazel_minimum_version(MINIMUM_BAZEL_VERSION)
native.register_toolchains(str(Label("//protobuf:protoc_toolchain")))
@ -389,6 +392,7 @@ def rules_proto_grpc_toolchains():
# Core
#
def rules_proto_grpc_repos(**kwargs):
"""Load the rules_proto_grpc common dependencies.""" # buildifier: disable=function-docstring-args
check_bazel_minimum_version(MINIMUM_BAZEL_VERSION)
rules_proto(**kwargs)

View File

@ -1,5 +1,5 @@
load("//ruby:defs.bzl", "ruby_grpc_library")
load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_binary", "ruby_library")
load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_binary")
ruby_grpc_library(
name = "routeguide",

View File

@ -1,9 +1,11 @@
"""Common dependencies for rules_proto_grpc Ruby rules."""
load(
"//:repositories.bzl",
"bazelruby_rules_ruby",
"rules_proto_grpc_repos",
)
def ruby_repos(**kwargs):
def ruby_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
bazelruby_rules_ruby(**kwargs)

View File

@ -1,3 +1,5 @@
"""Generated definition of ruby_grpc_library."""
load("//ruby:ruby_grpc_compile.bzl", "ruby_grpc_compile")
load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_library")
@ -10,7 +12,6 @@ def ruby_grpc_library(**kwargs):
)
# Create ruby library
print(native.package_name())
ruby_library(
name = kwargs.get("name"),
srcs = [name_pb],

View File

@ -1,3 +1,5 @@
"""Generated definition of ruby_proto_library."""
load("//ruby:ruby_proto_compile.bzl", "ruby_proto_compile")
load("@bazelruby_rules_ruby//ruby:defs.bzl", "ruby_library")
@ -10,7 +12,6 @@ def ruby_proto_library(**kwargs):
)
# Create ruby library
print(native.package_name())
ruby_library(
name = kwargs.get("name"),
srcs = [name_pb],

View File

@ -1,3 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_import")
load("//:defs.bzl", "proto_plugin")
proto_plugin(

View File

@ -1,5 +1,5 @@
load("//rust:rust_grpc_library.bzl", "GRPC_DEPS", "rust_grpc_library")
load("@rules_rust//rust:rust.bzl", "rust_binary", "rust_library")
load("@rules_rust//rust:rust.bzl", "rust_binary")
rust_grpc_library(
name = "routeguide",

View File

@ -62,6 +62,8 @@ rust_library(
)
# Additional content from ../../third_party/BUILD.bazel.raze_grpc_sys
load("@rules_cc//cc:defs.bzl", "cc_library")
# Manually build the bindings and link to the Bazel built version of gPRC
rust_library(
name = "grpc_bindings",

View File

@ -1,3 +1,5 @@
"""Common dependencies for rules_proto_grpc Rust rules."""
load(
"//:repositories.bzl",
"rules_proto_grpc_repos",
@ -8,7 +10,7 @@ load(
"raze_fetch_remote_crates",
)
def rust_repos(**kwargs):
def rust_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
rules_rust(**kwargs)
raze_fetch_remote_crates()

View File

@ -1,8 +1,10 @@
"""Generated definition of rust_grpc_library."""
load("//rust:rust_grpc_compile.bzl", "rust_grpc_compile")
load("//rust:rust_proto_lib.bzl", "rust_proto_lib")
load("@rules_rust//rust:rust.bzl", "rust_library")
def rust_grpc_library(**kwargs):
def rust_grpc_library(**kwargs): # buildifier: disable=function-docstring
# Compile protos
name_pb = kwargs.get("name") + "_pb"
name_lib = kwargs.get("name") + "_lib"

View File

@ -1,3 +1,5 @@
"""Rule to build a RustProtoLibInfo and lib.rs for generated proto sources."""
load("//defs.bzl", "ProtoCompileInfo")
RustProtoLibInfo = provider(fields = {

View File

@ -1,8 +1,10 @@
"""Generated definition of rust_proto_library."""
load("//rust:rust_proto_compile.bzl", "rust_proto_compile")
load("//rust:rust_proto_lib.bzl", "rust_proto_lib")
load("@rules_rust//rust:rust.bzl", "rust_library")
def rust_proto_library(**kwargs):
def rust_proto_library(**kwargs): # buildifier: disable=function-docstring
# Compile protos
name_pb = kwargs.get("name") + "_pb"
name_lib = kwargs.get("name") + "_lib"

View File

@ -1,3 +1,5 @@
"""Common dependencies for rules_proto_grpc Scala rules."""
load(
"//:repositories.bzl",
"com_github_scalapb_scalapb",
@ -6,7 +8,7 @@ load(
"rules_proto_grpc_repos",
)
def scala_repos(**kwargs):
def scala_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
io_grpc_grpc_java(**kwargs)
com_github_scalapb_scalapb(**kwargs)

View File

@ -1,8 +1,10 @@
"""Generated definition of scala_grpc_library."""
load("//scala:scala_grpc_compile.bzl", "scala_grpc_compile")
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library")
load("@io_bazel_rules_scala//scala_proto:default_dep_sets.bzl", "DEFAULT_SCALAPB_COMPILE_DEPS", "DEFAULT_SCALAPB_GRPC_DEPS")
load("@io_bazel_rules_scala//scala_proto:default_dep_sets.bzl", "DEFAULT_SCALAPB_COMPILE_DEPS", "DEFAULT_SCALAPB_GRPC_DEPS") # buildifier: disable=load
def scala_grpc_library(**kwargs):
def scala_grpc_library(**kwargs): # buildifier: disable=function-docstring
# Compile protos
name_pb = kwargs.get("name") + "_pb"
scala_grpc_compile(

View File

@ -1,8 +1,10 @@
"""Generated definition of scala_proto_library."""
load("//scala:scala_proto_compile.bzl", "scala_proto_compile")
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library")
load("@io_bazel_rules_scala//scala_proto:default_dep_sets.bzl", "DEFAULT_SCALAPB_COMPILE_DEPS", "DEFAULT_SCALAPB_GRPC_DEPS")
load("@io_bazel_rules_scala//scala_proto:default_dep_sets.bzl", "DEFAULT_SCALAPB_COMPILE_DEPS", "DEFAULT_SCALAPB_GRPC_DEPS") # buildifier: disable=load
def scala_proto_library(**kwargs):
def scala_proto_library(**kwargs): # buildifier: disable=function-docstring
# Compile protos
name_pb = kwargs.get("name") + "_pb"
scala_proto_compile(

View File

@ -1,3 +1,5 @@
"""Common dependencies for rules_proto_grpc Swift rules."""
load(
"//:repositories.bzl",
"build_bazel_rules_swift",
@ -11,7 +13,7 @@ load(
"rules_proto_grpc_repos",
)
def swift_repos(**kwargs):
def swift_repos(**kwargs): # buildifier: disable=function-docstring
rules_proto_grpc_repos(**kwargs)
build_bazel_rules_swift(**kwargs)
com_github_grpc_grpc_swift(**kwargs)

View File

@ -1,3 +1,5 @@
"""Generated definition of swift_grpc_library."""
load("//swift:swift_grpc_compile.bzl", "swift_grpc_compile")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

View File

@ -1,3 +1,5 @@
"""Generated definition of swift_proto_library."""
load("//swift:swift_proto_compile.bzl", "swift_proto_compile")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

View File

@ -1,7 +1,9 @@
package(default_visibility = ["//visibility:private"])
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_test")
load("@rules_proto_grpc//python:defs.bzl", "python_proto_library")
package(default_visibility = ["//visibility:private"])
# Use the strip_import_prefix attribute with an absolute path
proto_library(

View File

@ -1,7 +1,9 @@
package(default_visibility = ["//visibility:private"])
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_test")
load("@rules_proto_grpc//python:defs.bzl", "python_proto_library")
package(default_visibility = ["//visibility:private"])
# Use both strip_import_prefix and import_prefix attributes
proto_library(

View File

@ -1,7 +1,9 @@
package(default_visibility = ["//visibility:private"])
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_cc//cc:defs.bzl", "cc_test")
load("@rules_proto_grpc//cpp:defs.bzl", "cpp_proto_library")
package(default_visibility = ["//visibility:private"])
# Use the same base proto in two different trees. The rules should not tread
# on each other and try to write the same file.

View File

@ -1,7 +1,9 @@
package(default_visibility = ["//visibility:private"])
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_test")
load("@rules_proto_grpc//php:defs.bzl", "php_grpc_compile")
package(default_visibility = ["//visibility:private"])
# Test that plugins that use output_directory behave correctly when no files are written to the output directory
# See https://github.com/rules-proto-grpc/rules_proto_grpc/issues/39

View File

@ -1,7 +1,9 @@
package(default_visibility = ["//visibility:private"])
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_test")
load("@rules_proto_grpc//python:defs.bzl", "python_proto_library")
package(default_visibility = ["//visibility:private"])
# Test that exclusions are correctly being applied
proto_library(

View File

@ -1,7 +1,9 @@
package(default_visibility = ["//visibility:private"])
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_test")
load("@rules_proto_grpc//python:defs.bzl", "python_proto_library")
package(default_visibility = ["//visibility:private"])
# Test that generated proto files are handled correctly
genrule(

View File

@ -1,7 +1,8 @@
package(default_visibility = ["//visibility:private"])
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_proto_grpc//go:defs.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test")
load("@io_bazel_rules_go//go:def.bzl", "go_test")
package(default_visibility = ["//visibility:private"])
# Test that importpath on go_proto_library works

View File

@ -15,7 +15,7 @@ rules_proto_dependencies()
rules_proto_toolchains()
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go")
load("@rules_proto_grpc//:repositories.bzl", "bazel_gazelle", "io_bazel_rules_go") # buildifier: disable=same-origin-load
io_bazel_rules_go()

View File

@ -1,7 +1,9 @@
package(default_visibility = ["//visibility:private"])
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_test")
load("@rules_proto_grpc//python:defs.bzl", "python_proto_library")
package(default_visibility = ["//visibility:private"])
# Use the import_prefix attribute
proto_library(

View File

@ -1,7 +1,9 @@
package(default_visibility = ["//visibility:private"])
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_test")
load("@rules_proto_grpc//objc:defs.bzl", "objc_proto_compile")
package(default_visibility = ["//visibility:private"])
# Test that Objective-C files are correctly capitalised
proto_library(

View File

@ -1,7 +1,9 @@
package(default_visibility = ["//visibility:private"])
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_test")
load("@rules_proto_grpc//python:python_grpc_library.bzl", "python_grpc_library")
package(default_visibility = ["//visibility:private"])
# Test that python 3 dependencies protobuf and grpc are importable
proto_library(

View File

@ -1,7 +1,9 @@
package(default_visibility = ["//visibility:private"])
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_test")
load("@rules_proto_grpc//python:defs.bzl", "python_proto_library")
package(default_visibility = ["//visibility:private"])
# Test that outputs are correctly predicted for python plugin when using proto
# files in paths with dashes. These are converted to underscores by the python
# protoc plugin as dashes cannot be used in an import name.

View File

@ -1,7 +1,9 @@
package(default_visibility = ["//visibility:private"])
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_test")
load("@rules_proto_grpc//python:defs.bzl", "python_grpc_library")
package(default_visibility = ["//visibility:private"])
# Test that python dependencies protobuf and grpc are available
proto_library(

View File

@ -1,3 +1,5 @@
load("@rules_python//python:defs.bzl", "py_test")
package(default_visibility = ["//visibility:private"])
# Test that the README example http_archive call works. The WORKSPACE for this

View File

@ -1,7 +1,9 @@
package(default_visibility = ["//visibility:private"])
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_test")
load("@rules_proto_grpc//python:defs.bzl", "python_proto_library")
package(default_visibility = ["//visibility:private"])
# Use the strip_import_prefix attribute with a relative path
proto_library(

Some files were not shown because too many files have changed in this diff Show More