Add extension to C# example libraries

This commit is contained in:
Adam Liddell 2021-02-21 22:20:03 +00:00
parent feed723efd
commit 0ce2d6c29c
4 changed files with 52 additions and 18 deletions

View File

@ -180,19 +180,19 @@ nuget_rules_proto_grpc_packages()
load("@rules_proto_grpc//csharp:defs.bzl", "csharp_proto_library")
csharp_proto_library(
name = "person_csharp_proto",
name = "person_csharp_proto.dll",
protos = ["@rules_proto_grpc//example/proto:person_proto"],
deps = ["place_csharp_proto"],
deps = ["place_csharp_proto.dll"],
)
csharp_proto_library(
name = "place_csharp_proto",
name = "place_csharp_proto.dll",
protos = ["@rules_proto_grpc//example/proto:place_proto"],
deps = ["thing_csharp_proto"],
deps = ["thing_csharp_proto.dll"],
)
csharp_proto_library(
name = "thing_csharp_proto",
name = "thing_csharp_proto.dll",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
```
@ -249,14 +249,14 @@ nuget_rules_proto_grpc_packages()
load("@rules_proto_grpc//csharp:defs.bzl", "csharp_grpc_library")
csharp_grpc_library(
name = "thing_csharp_grpc",
name = "thing_csharp_grpc.dll",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
csharp_grpc_library(
name = "greeter_csharp_grpc",
name = "greeter_csharp_grpc.dll",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
deps = ["thing_csharp_grpc"],
deps = ["thing_csharp_grpc.dll"],
)
```

View File

@ -1,12 +1,12 @@
load("@rules_proto_grpc//csharp:defs.bzl", "csharp_grpc_library")
csharp_grpc_library(
name = "thing_csharp_grpc",
name = "thing_csharp_grpc.dll",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
csharp_grpc_library(
name = "greeter_csharp_grpc",
name = "greeter_csharp_grpc.dll",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
deps = ["thing_csharp_grpc"],
deps = ["thing_csharp_grpc.dll"],
)

View File

@ -1,18 +1,18 @@
load("@rules_proto_grpc//csharp:defs.bzl", "csharp_proto_library")
csharp_proto_library(
name = "person_csharp_proto",
name = "person_csharp_proto.dll",
protos = ["@rules_proto_grpc//example/proto:person_proto"],
deps = ["place_csharp_proto"],
deps = ["place_csharp_proto.dll"],
)
csharp_proto_library(
name = "place_csharp_proto",
name = "place_csharp_proto.dll",
protos = ["@rules_proto_grpc//example/proto:place_proto"],
deps = ["thing_csharp_proto"],
deps = ["thing_csharp_proto.dll"],
)
csharp_proto_library(
name = "thing_csharp_proto",
name = "thing_csharp_proto.dll",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)

View File

@ -91,6 +91,40 @@ GRPC_DEPS = [
"@core_sdk_stdlib//:libraryset",
]`)
// For C#, library names need .dll
var csharpProtoLibraryExampleTemplate = mustTemplate(`load("@rules_proto_grpc//{{ .Lang.Dir }}:defs.bzl", "{{ .Rule.Name }}")
{{ .Rule.Name }}(
name = "person_{{ .Lang.Name }}_{{ .Rule.Kind }}.dll",
protos = ["@rules_proto_grpc//example/proto:person_proto"],
deps = ["place_{{ .Lang.Name }}_{{ .Rule.Kind }}.dll"],
)
{{ .Rule.Name }}(
name = "place_{{ .Lang.Name }}_{{ .Rule.Kind }}.dll",
protos = ["@rules_proto_grpc//example/proto:place_proto"],
deps = ["thing_{{ .Lang.Name }}_{{ .Rule.Kind }}.dll"],
)
{{ .Rule.Name }}(
name = "thing_{{ .Lang.Name }}_{{ .Rule.Kind }}.dll",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)`)
var csharpGrpcLibraryExampleTemplate = mustTemplate(`load("@rules_proto_grpc//{{ .Lang.Dir }}:defs.bzl", "{{ .Rule.Name }}")
{{ .Rule.Name }}(
name = "thing_{{ .Lang.Name }}_{{ .Rule.Kind }}.dll",
protos = ["@rules_proto_grpc//example/proto:thing_proto"],
)
{{ .Rule.Name }}(
name = "greeter_{{ .Lang.Name }}_{{ .Rule.Kind }}.dll",
protos = ["@rules_proto_grpc//example/proto:greeter_grpc"],
deps = ["thing_{{ .Lang.Name }}_{{ .Rule.Kind }}.dll"],
)`)
func makeCsharp() *Language {
return &Language{
Dir: "csharp",
@ -124,7 +158,7 @@ func makeCsharp() *Language {
Kind: "proto",
Implementation: csharpProtoLibraryRuleTemplate,
WorkspaceExample: csharpProtoWorkspaceTemplate,
BuildExample: protoLibraryExampleTemplate,
BuildExample: csharpProtoLibraryExampleTemplate,
Doc: "Generates a C# protobuf library using `csharp_library` from `rules_dotnet`. Note that the library name must end in `.dll`",
Attrs: libraryRuleAttrs,
},
@ -133,7 +167,7 @@ func makeCsharp() *Language {
Kind: "grpc",
Implementation: csharpGrpcLibraryRuleTemplate,
WorkspaceExample: csharpGrpcWorkspaceTemplate,
BuildExample: grpcLibraryExampleTemplate,
BuildExample: csharpGrpcLibraryExampleTemplate,
Doc: "Generates a C# protobuf+gRPC library using `csharp_library` from `rules_dotnet`. Note that the library name must end in `.dll`",
Attrs: libraryRuleAttrs,
},