forked from open-telemetry/opentelemetry-demo
-
Notifications
You must be signed in to change notification settings - Fork 37
/
ide-gen-proto.sh
executable file
·79 lines (68 loc) · 2.27 KB
/
ide-gen-proto.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
# This script is used to generate protobuf files for all services.
# Useful to ensure code can compile without Docker, and provide hints for IDEs.
# Several dev tools including: cargo, protoc, python grpcio-tools, and rebar3 may be required to run this script.
base_dir=$(pwd)
gen_proto_dotnet() {
echo "Generating .NET protobuf files for $1"
cd "$base_dir"/src/"$1" || return
mkdir -p ./src/protos/
cp -r "$base_dir"/pb/ ./src/protos/
cd "$base_dir" || return
}
gen_proto_elixir() {
echo "Generating Elixir protobuf files for $1"
cd "$base_dir"/src/"$1" || return
mkdir -p proto
cp "$base_dir"/pb/demo.proto ./proto/demo.proto
rebar3 grpc_regen
cd "$base_dir" || return
}
gen_proto_go() {
echo "Generating Go protobuf files for $1"
cd "$base_dir"/src/"$1" || return
protoc -I ../../pb ./../../pb/demo.proto --go_out=./ --go-grpc_out=./
cd "$base_dir" || return
}
gen_proto_js() {
echo "Generating Javascript protobuf files for $1"
cd "$base_dir"/src/"$1" || return
cp "$base_dir"/pb/demo.proto .
cd "$base_dir" || return
}
gen_proto_python() {
echo "Generating Python protobuf files for $1"
cd "$base_dir"/src/"$1" || return
python3 -m grpc_tools.protoc -I=../../pb --python_out=./ --grpc_python_out=./ ./../../pb/demo.proto
cd "$base_dir" || return
}
gen_proto_rust() {
echo "Generating Rust protobuf files for $1"
cd "$base_dir"/src/"$1" || return
mkdir -p proto
cp "$base_dir"/pb/demo.proto proto/demo.proto
cargo build
cd "$base_dir" || return
}
gen_proto_ts() {
echo "Generating Typescript protobuf files for $1"
cd "$base_dir"/src/"$1" || return
cp -r "$base_dir"/pb .
mkdir -p ./protos
protoc -I ./pb --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_opt=esModuleInterop=true --ts_proto_out=./protos --ts_proto_opt=outputServices=grpc-js demo.proto
cd "$base_dir" || return
}
gen_proto_dotnet accountingservice
# gen_proto_java adservice
gen_proto_dotnet cartservice
gen_proto_go checkoutservice
# gen_proto_cpp currencyservice
# gen_proto_ruby emailservice
gen_proto_ts frontend
gen_proto_js paymentservice
gen_proto_go productcatalogservice
# gen_proto_php quoteservice
gen_proto_python recommendationservice
gen_proto_rust shippingservice