Skip to content

Commit c03cd3e

Browse files
authored
Merge pull request #20 from wcs1only/automate-proto-files
Automate pulling .proto files from dapr runtime (#19)
2 parents 81e206e + fc3a982 commit c03cd3e

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

Makefile

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,44 @@ PROTOC = protoc
88
GRPC_CPP_PLUGIN = grpc_cpp_plugin
99
GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`
1010

11+
OBJ_FILES = src/dapr/proto/common/v1/common.pb.o src/dapr/proto/runtime/v1/dapr.pb.o src/dapr/proto/runtime/v1/dapr.grpc.pb.o src/dapr/proto/runtime/v1/appcallback.pb.o src/dapr/proto/runtime/v1/appcallback.grpc.pb.o
12+
13+
PROTO_FILES = dapr/proto/runtime/v1/dapr.proto dapr/proto/runtime/v1/appcallback.proto dapr/proto/common/v1/common.proto
14+
1115
PROTOS_PATH = .
1216

17+
DAPR_TARGET ?= master
18+
1319
vpath %.proto $(PROTOS_PATH)
1420

1521
all: system-check libdapr.so
1622

17-
libdapr.so : ./src/dapr/proto/common/v1/common.pb.o ./src/dapr/proto/runtime/v1/dapr.pb.o ./src/dapr/proto/runtime/v1/dapr.grpc.pb.o ./src/dapr/proto/runtime/v1/appcallback.pb.o ./src/dapr/proto/runtime/v1/appcallback.grpc.pb.o
23+
libdapr.so : $(OBJ_FILES)
1824
-mkdir -p ./out
1925
$(CXX) -shared -Wl,-soname,libdapr.so.0 -o ./out/libdapr.0.2.0.so ./src/dapr/proto/runtime/v1/*.o ./src/dapr/proto/common/v1/*.o
2026

21-
%.o : %.cc
27+
%.o: %.cc
2228
$(CXX) -c -fPIC -I./src $< -o $@
2329

24-
.PRECIOUS: %.grpc.pb.cc
25-
%.grpc.pb.cc: %.proto
30+
.PRECIOUS: src/%.grpc.pb.cc
31+
src/%.grpc.pb.cc: %.proto
2632
$(PROTOC) -I $(PROTOS_PATH) --grpc_out=./src/ --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $<
2733

28-
.PRECIOUS: %.pb.cc
29-
%.pb.cc: %.proto
34+
.PRECIOUS: src/%.pb.cc
35+
src/%.pb.cc: %.proto
36+
mkdir -p ./src
3037
$(PROTOC) -I $(PROTOS_PATH) --cpp_out=./src/ $<
3138

3239
clean:
3340
rm -f ./src/dapr/proto/common/v1/*.o ./src/dapr/proto/runtime/v1/*.o
3441
rm -rf ./out
3542

43+
refresh_proto_files:
44+
for file in $(PROTO_FILES); do \
45+
curl -o $$file https://raw.githubusercontent.com/dapr/dapr/$(DAPR_TARGET)/$$file; \
46+
done
47+
48+
3649
# The following is to test your system and ensure a smoother experience.
3750
# They are by no means necessary to actually compile a grpc-enabled software.
3851

README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@ Alpha quality.
1010
2. Install [VSCode](https://code.visualstudio.com/download)
1111
3. Install [VSCode Remote - Container extension](https://code.visualstudio.com/docs/remote/containers)
1212

13-
### Generate gRPC client
13+
### To refresh .proto files from upstream dapr
1414

15-
1. Copy dapr.proto from https://github.com/dapr/dapr/tree/master/pkg/proto/dapr to [proto](./proto)
16-
2. Copy daprclient.proto from https://github.com/dapr/dapr/tree/master/pkg/proto/daprclient to [proto](./proto)
17-
3. Generate client
15+
1. Rebuild and commit generated API
1816
```bash
19-
make ./dapr/proto/common/v1/common.pb.cc
20-
make ./dapr/proto/runtime/v1/dapr.grpc.pb.cc
21-
make ./dapr/proto/runtime/v1/dapr.pb.cc
22-
make ./dapr/proto/runtime/v1/appcallback.grpc.pb.cc
23-
make ./dapr/proto/runtime/v1/appcallback.pb.cc
17+
export DAPR_TARGET=<runtime_release_tag>
18+
make refresh_proto_files && make && git add src/dapr/proto/*/v1/*{.cc,.h} dapr/proto/*/v1/*.proto
19+
git commit -m "Updating to dapr runtime $DAPR_TARGET"
2420
```
21+
2. Submit a PR with the changes
2522

2623
### Build library
2724

0 commit comments

Comments
 (0)