Skip to content

Commit

Permalink
[WIP] Generate C# bindings
Browse files Browse the repository at this point in the history
Just experimenting!

Signed-off-by: James Taylor <jamest@uk.ibm.com>
  • Loading branch information
jt-nti committed Jun 4, 2024
1 parent f257e2a commit 48363b7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
/bindings/go-apiv2/**/*.pb.go
/bindings/java/src
/bindings/node/src
/bindings/csharp/package/Hyperledger.Fabric.Protos
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ PROTOC_GEN_GRPC_JAVA_VERSION := 1.63.0
PROTOC_GEN_JS_VERSION := 3.21.2
GRPC_TOOLS_VERSION := 1.12.4
TS_PROTOC_GEN_VERSION := 0.15.0
GRPC_CSHARP_PLUGIN_VERSION := 2.64.0

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

# GRPC_CSHARP_PLUGIN points to the marker file for the installed version.
#
# If GRPC_CSHARP_PLUGIN_VERSION is changed, the binary will be re-downloaded.
#
# TODO: no arm mac version
GRPC_CSHARP_PLUGIN := $(CACHE_VERSIONS)/grpc_csharp_plugin/$(GRPC_CSHARP_PLUGIN_VERSION)
$(GRPC_CSHARP_PLUGIN):
@rm -f $(CACHE_BIN)/grpc_csharp_plugin
@mkdir -p $(CACHE_BIN)
$(eval GRPC_CSHARP_PLUGIN_TMP := $(shell mktemp -d))
curl -sSL \
"https://www.nuget.org/api/v2/package/Grpc.Tools/$(GRPC_CSHARP_PLUGIN_VERSION)" \
-o "$(GRPC_CSHARP_PLUGIN_TMP)/grpc.tools.$(GRPC_CSHARP_PLUGIN_VERSION).nupkg"
unzip -o "$(GRPC_CSHARP_PLUGIN_TMP)/grpc.tools.$(GRPC_CSHARP_PLUGIN_VERSION).nupkg" -d "$(GRPC_CSHARP_PLUGIN_TMP)" tools/macosx_x64/grpc_csharp_plugin
mv "$(GRPC_CSHARP_PLUGIN_TMP)/tools/macosx_x64/grpc_csharp_plugin" "$(CACHE_BIN)"
chmod +x "$(CACHE_BIN)/grpc_csharp_plugin"
@rm -rf $(GRPC_CSHARP_PLUGIN_TMP)
@rm -rf $(dir $(GRPC_CSHARP_PLUGIN))
@mkdir -p $(dir $(GRPC_CSHARP_PLUGIN))
@touch $(GRPC_CSHARP_PLUGIN)

.DEFAULT_GOAL := all

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

.PHONY: deps
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)
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)

.PHONY: lint
lint: https
Expand Down
10 changes: 10 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ version: v2
managed:
enabled: true
override:
- file_option: csharp_namespace_prefix
value: Hyperledger.Fabric
- file_option: java_multiple_files
value: true
- file_option: java_package_prefix
Expand Down Expand Up @@ -102,6 +104,14 @@ managed:
path: peer/transaction.proto
value: org.hyperledger.fabric.protos.peer
plugins:
- protoc_builtin: csharp
out: bindings/csharp/package/Hyperledger.Fabric.Protos
opt:
- base_namespace=
- local: grpc_csharp_plugin
out: bindings/csharp/package/Hyperledger.Fabric.Protos
opt:
- base_namespace=
- local: protoc-gen-doc
out: docs
opt:
Expand Down

0 comments on commit 48363b7

Please sign in to comment.