Skip to content

Commit

Permalink
Fix gRPC example (#267)
Browse files Browse the repository at this point in the history
* Fix gRPC example

## What?
Fixes the `grpc` example after a breaking change in `rules-proto-grpc`
  • Loading branch information
purkhusid authored Nov 17, 2021
1 parent d87e08c commit 7dfb32e
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 54 deletions.
68 changes: 68 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,74 @@ tasks:
test_targets:
- "//..."

grpc_linux_amd64_3.1.407:
platform: ubuntu1804
name: grpc_linux_amd64_3.1.407
working_directory: examples/grpc
test_flags:
- "--host_platform"
- "@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_3.1.407"
- "--platforms"
- "@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_3.1.407"
test_targets:
- "//..."
grpc_windows_amd64_3.1.407:
platform: windows
name: grpc_windows_amd64_3.1.407
working_directory: examples/grpc
test_flags:
- "--host_platform"
- "@io_bazel_rules_dotnet//dotnet/toolchain:windows_amd64_3.1.407"
- "--platforms"
- "@io_bazel_rules_dotnet//dotnet/toolchain:windows_amd64_3.1.407"
test_targets:
- "//..."
grpc_darwin_amd64_3.1.407:
platform: macos
name: grpc_darwin_amd64_3.1.407
working_directory: examples/grpc
test_flags:
- "--host_platform"
- "@io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_3.1.407"
- "--platforms"
- "@io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_3.1.407"
test_targets:
- "//..."

grpc_linux_amd64_5.0.201:
platform: ubuntu1804
name: grpc_linux_amd64_5.0.201
working_directory: examples/grpc
test_flags:
- "--host_platform"
- "@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_5.0.201"
- "--platforms"
- "@io_bazel_rules_dotnet//dotnet/toolchain:linux_amd64_5.0.201"
test_targets:
- "//..."
grpc_windows_amd64_5.0.201:
platform: windows
name: grpc_windows_amd64_5.0.201
working_directory: examples/grpc
test_flags:
- "--host_platform"
- "@io_bazel_rules_dotnet//dotnet/toolchain:windows_amd64_5.0.201"
- "--platforms"
- "@io_bazel_rules_dotnet//dotnet/toolchain:windows_amd64_5.0.201"
test_targets:
- "//..."
grpc_darwin_amd64_5.0.201:
platform: macos
name: grpc_darwin_amd64_5.0.201
working_directory: examples/grpc
test_flags:
- "--host_platform"
- "@io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_5.0.201"
- "--platforms"
- "@io_bazel_rules_dotnet//dotnet/toolchain:darwin_amd64_5.0.201"
test_targets:
- "//..."

type_providers_linux_amd64_3.1.407:
platform: ubuntu1804
name: type_providers_linux_amd64_3.1.407
Expand Down
35 changes: 5 additions & 30 deletions examples/grpc/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "csharp_library", "csharp_xunit_test")
load("@rules_proto_grpc//csharp:defs.bzl", "csharp_grpc_compile")
load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "csharp_xunit_test")
load("@rules_proto_grpc//csharp:defs.bzl", "csharp_grpc_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

proto_library(
Expand All @@ -9,21 +9,10 @@ proto_library(
deps = ["@com_google_protobuf//:any_proto"],
)

csharp_grpc_compile(
name = "service_proto_gen_cs",
visibility = ["//visibility:public"],
deps = [":service_proto"],
)

csharp_library(
csharp_grpc_library(
name = "service_proto.dll",
srcs = [":service_proto_gen_cs"],
deps = [
"@core_sdk_stdlib//:libraryset",
"@google.protobuf//:lib",
"@grpc.core.api//:lib",
"@grpc.core//:lib",
],
protos = [":service_proto"],
visibility = ["//visibility:public"],
)

csharp_xunit_test(
Expand All @@ -32,20 +21,6 @@ csharp_xunit_test(
srcs = [
"SomeServerTest.cs",
],
data = select({
"@bazel_tools//src/conditions:windows": [
"@grpc.core.runtime//:runtimes/win/native/grpc_csharp_ext.x64.dll",
"@grpc.core.runtime//:runtimes/win/native/grpc_csharp_ext.x86.dll",
],
"@bazel_tools//src/conditions:darwin": [
"@grpc.core.runtime//:runtimes/osx/native/libgrpc_csharp_ext.x64.dylib",
"@grpc.core.runtime//:runtimes/osx/native/libgrpc_csharp_ext.x86.dylib",
],
"//conditions:default": [
"@grpc.core.runtime//:runtimes/linux/native/libgrpc_csharp_ext.x64.so",
"@grpc.core.runtime//:runtimes/linux/native/libgrpc_csharp_ext.x86.so",
],
}),
deps = [
":service_proto.dll",
"@grpc.core//:lib",
Expand Down
31 changes: 7 additions & 24 deletions examples/grpc/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ dotnet_repositories()

load(
"@io_bazel_rules_dotnet//dotnet:defs.bzl",
"dotnet_nuget_new",
"dotnet_register_toolchains",
"dotnet_repositories_nugets",
)
Expand All @@ -18,22 +17,14 @@ dotnet_register_toolchains()

dotnet_repositories_nugets()

dotnet_nuget_new(
name = "grpc.core.runtime",
build_file_content = """exports_files(glob(["runtimes/**/*"]), visibility = ["//visibility:public"])""",
package = "grpc.core",
sha256 = "b625817b7e8dfe66e0894b232001b4c2f0e80aa41dc4dccb59d5a452ca36a755",
version = "2.28.1",
)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# GRPC
http_archive(
name = "rules_proto_grpc",
sha256 = "5f0f2fc0199810c65a2de148a52ba0aff14d631d4e8202f41aff6a9d590a471b",
strip_prefix = "rules_proto_grpc-1.0.2",
urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/1.0.2.tar.gz"],
sha256 = "28724736b7ff49a48cb4b2b8cfa373f89edfcb9e8e492a8d5ab60aa3459314c8",
strip_prefix = "rules_proto_grpc-4.0.1",
urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/4.0.1.tar.gz"],
)

load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains")
Expand All @@ -46,21 +37,13 @@ load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")

grpc_deps()

http_archive(
name = "rules_proto",
sha256 = "602e7161d9195e50246177e7c55b2f39950a9cf7366f74ed5f22fd45750cd208",
strip_prefix = "rules_proto-97d8af4dc474595af3900dd85cb3a29ad28cc313",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz",
],
)
load("@rules_proto_grpc//csharp:repositories.bzl", rules_proto_grpc_csharp_repos = "csharp_repos")

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_grpc_csharp_repos()

rules_proto_dependencies()
load("@rules_proto_grpc//csharp/nuget:nuget.bzl", csharp_nuget_rules_proto_grpc_packages = "nuget_rules_proto_grpc_packages")

rules_proto_toolchains()
csharp_nuget_rules_proto_grpc_packages()

# load NUGET deps
load("//:gen/nuget.bzl", "project_dotnet_repositories_nuget")
Expand Down

0 comments on commit 7dfb32e

Please sign in to comment.