Skip to content

Commit 7edda34

Browse files
committed
[WIP] Generate C# bindings
Just experimenting! Signed-off-by: James Taylor <[email protected]>
1 parent f257e2a commit 7edda34

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
/bindings/go-apiv2/**/*.pb.go
1616
/bindings/java/src
1717
/bindings/node/src
18+
/bindings/csharp/src

Makefile

+23-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ PROTOC_GEN_GRPC_JAVA_VERSION := 1.63.0
3737
PROTOC_GEN_JS_VERSION := 3.21.2
3838
GRPC_TOOLS_VERSION := 1.12.4
3939
TS_PROTOC_GEN_VERSION := 0.15.0
40+
GRPC_CSHARP_PLUGIN_VERSION := 2.64.0
4041

4142
# This is the commit hash for the https://github.com/googleapis/googleapis repo
4243
GRPC_STATUS_VERSION := f36c65081b19e0758ef5696feca27c7dcee5475e
@@ -215,6 +216,27 @@ $(TS_PROTOC_GEN):
215216
@mkdir -p $(dir $(TS_PROTOC_GEN))
216217
@touch $(TS_PROTOC_GEN)
217218

219+
# GRPC_CSHARP_PLUGIN points to the marker file for the installed version.
220+
#
221+
# If GRPC_CSHARP_PLUGIN_VERSION is changed, the binary will be re-downloaded.
222+
#
223+
# TODO: no arm mac version
224+
GRPC_CSHARP_PLUGIN := $(CACHE_VERSIONS)/grpc_csharp_plugin/$(GRPC_CSHARP_PLUGIN_VERSION)
225+
$(GRPC_CSHARP_PLUGIN):
226+
@rm -f $(CACHE_BIN)/grpc_csharp_plugin
227+
@mkdir -p $(CACHE_BIN)
228+
$(eval GRPC_CSHARP_PLUGIN_TMP := $(shell mktemp -d))
229+
curl -sSL \
230+
"https://www.nuget.org/api/v2/package/Grpc.Tools/$(GRPC_CSHARP_PLUGIN_VERSION)" \
231+
-o "$(GRPC_CSHARP_PLUGIN_TMP)/grpc.tools.$(GRPC_CSHARP_PLUGIN_VERSION).nupkg"
232+
unzip -o "$(GRPC_CSHARP_PLUGIN_TMP)/grpc.tools.$(GRPC_CSHARP_PLUGIN_VERSION).nupkg" -d "$(GRPC_CSHARP_PLUGIN_TMP)" tools/macosx_x64/grpc_csharp_plugin
233+
mv "$(GRPC_CSHARP_PLUGIN_TMP)/tools/macosx_x64/grpc_csharp_plugin" "$(CACHE_BIN)"
234+
chmod +x "$(CACHE_BIN)/grpc_csharp_plugin"
235+
@rm -rf $(GRPC_CSHARP_PLUGIN_TMP)
236+
@rm -rf $(dir $(GRPC_CSHARP_PLUGIN))
237+
@mkdir -p $(dir $(GRPC_CSHARP_PLUGIN))
238+
@touch $(GRPC_CSHARP_PLUGIN)
239+
218240
.DEFAULT_GOAL := all
219241

220242
.PHONY: all
@@ -223,7 +245,7 @@ all: lint javabindings nodebindings
223245
# deps allows us to install deps without running any checks.
224246

225247
.PHONY: deps
226-
deps: $(BUF) $(PROTOC) $(PROTOC_GEN_DOC) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) $(PROTOC_GEN_GRPC_JAVA) $(PROTOC_GEN_JS) $(GRPC_TOOLS) $(TS_PROTOC_GEN)
248+
deps: $(BUF) $(PROTOC) $(PROTOC_GEN_DOC) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) $(PROTOC_GEN_GRPC_JAVA) $(PROTOC_GEN_JS) $(GRPC_TOOLS) $(TS_PROTOC_GEN) $(GRPC_CSHARP_PLUGIN)
227249

228250
.PHONY: lint
229251
lint: https

bindings/csharp/NuGet.Config

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
5+
<clear />
6+
<add key="NuGet.org (v3)" value="https://api.nuget.org/v3/index.json" />
7+
</packageSources>
8+
</configuration>

bindings/csharp/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# fabric-protos
2+
3+
C# bindings for [Hyperledger Fabric protocol buffers](https://github.com/hyperledger/fabric-protos)
4+
5+
## Usage
6+
7+
TBC

buf.gen.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ version: v2
22
managed:
33
enabled: true
44
override:
5+
- file_option: csharp_namespace_prefix
6+
value: Hyperledger.Fabric.Protos
57
- file_option: java_multiple_files
68
value: true
79
- file_option: java_package_prefix
@@ -102,6 +104,14 @@ managed:
102104
path: peer/transaction.proto
103105
value: org.hyperledger.fabric.protos.peer
104106
plugins:
107+
- protoc_builtin: csharp
108+
out: bindings/csharp/src
109+
opt:
110+
- base_namespace=
111+
- local: grpc_csharp_plugin
112+
out: bindings/csharp/src
113+
opt:
114+
- base_namespace=
105115
- local: protoc-gen-doc
106116
out: docs
107117
opt:

0 commit comments

Comments
 (0)