Skip to content

Commit 0b028e2

Browse files
committed
Adds experimental csharp support
1 parent ed02dca commit 0b028e2

File tree

6 files changed

+51
-3
lines changed

6 files changed

+51
-3
lines changed

bzl/classes.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
load("//bzl:base/class.bzl", BASE = "CLASS")
22
load("//bzl:cpp/class.bzl", CPP = "CLASS")
3+
load("//bzl:csharp/class.bzl", CSHARP = "CLASS")
34
load("//bzl:go/class.bzl", GO = "CLASS")
45
load("//bzl:python/class.bzl", PYTHON = "CLASS")
56
load("//bzl:ruby/class.bzl", RUBY = "CLASS")
@@ -10,6 +11,7 @@ load("//bzl:grpc_gateway/class.bzl", GATEWAY = "CLASS")
1011
CLASSES = {
1112
BASE.name: BASE,
1213
CPP.name: CPP,
14+
CSHARP.name: CSHARP,
1315
GATEWAY.name: GATEWAY,
1416
JAVA.name: JAVA,
1517
JAVANANO.name: JAVANANO,

bzl/csharp/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
| --- | --- |
66
| `csharp_proto_library` | Generates and compiles protobuf source files. |
77

8-
Support for C# is limited to the proto_compile rule. Semantics are
9-
identical to `cc_proto_compile`.
8+
**Experimental*. Support for C# is limited to the proto_compile rule.
9+
Semantics are identical to `cc_proto_compile`.

bzl/csharp/class.bzl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
load("//bzl:base/class.bzl", BASE = "CLASS")
2+
3+
def csharp_library(**kwargs):
4+
"""Dummy implementation."""
5+
pass
6+
7+
8+
CLASS = struct(
9+
parent = BASE,
10+
name = "csharp",
11+
12+
protobuf = struct(
13+
file_extensions = ["_pb.rb"],
14+
compile_deps = [],
15+
),
16+
17+
library = csharp_library,
18+
)

bzl/csharp/rules.bzl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
load("//bzl:base/rules.bzl", "proto_library")
2+
load("//bzl:protoc.bzl", "implement")
3+
load("//bzl:csharp/class.bzl", CSHARP = "CLASS")
4+
5+
SPEC = [CSHARP]
6+
7+
csharp_proto_compile = implement(SPEC)
8+
9+
def csharp_proto_library(name, **kwargs):
10+
proto_library(name,
11+
proto_compile = csharp_proto_compile,
12+
spec = SPEC,
13+
**kwargs)

bzl/rules.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def protobuf_repositories(
88
overrides = {},
99
verbose = 0,
1010
with_cpp=False,
11+
with_csharp=False,
1112
with_go=False,
1213
with_java=False,
1314
with_javanano=False,
@@ -48,6 +49,8 @@ def protobuf_repositories(
4849

4950
if with_cpp:
5051
classes += ["cpp"]
52+
if with_csharp:
53+
classes += ["csharp"]
5154
if with_python:
5255
classes += ["python"]
5356
if with_go:

examples/proto/BUILD

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package(default_visibility = ["//visibility:public"])
33
load("//bzl:cpp/rules.bzl", "cc_proto_library")
44
load("//bzl:go/rules.bzl", "go_proto_library")
55
load("//bzl:ruby/rules.bzl", "ruby_proto_library")
6+
load("//bzl:csharp/rules.bzl", "csharp_proto_library")
67

78
filegroup(
89
name = "protos",
@@ -23,10 +24,21 @@ cc_proto_library(
2324
verbose = 1,
2425
)
2526

26-
# This must be called with ':rb.pb' due to lack of implementing library rule for the moment.
27+
# Work-in-progress. This must be called with ':rb.pb' due to lack of
28+
# implementing library rule for the moment.
2729
#
2830
ruby_proto_library(
2931
name = "rb",
3032
protos = [":protos"],
3133
verbose = 1,
3234
)
35+
36+
# Work-in-progress. This must be called with ':cs.pb' due to lack of
37+
# implementing library rule for the moment. It also gets placed in
38+
# the outdir directly rather than the package dir.
39+
#
40+
# csharp_proto_library(
41+
# name = "csharp",
42+
# protos = [":protos"],
43+
# verbose = 1,
44+
# )

0 commit comments

Comments
 (0)