-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·84 lines (76 loc) · 3.14 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·84 lines (76 loc) · 3.14 KB
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
80
81
82
83
84
# Compile for blue-sdk-go.
echo "Compiling proto files..." && buf generate
# Compile gRPC Connect services (buf.gen.connect.yaml).
# To add a new Connect service, append a new --path flag below (e.g. --path mynewservice/v1).
echo "Compiling gRPC Connect services..."
buf generate --template buf.gen.connect.yaml \
--path vortex/v1
# Fix import paths in connect-generated files: the go_package option in each .proto
# points to github.com/alphauslabs/blueapi (not importable), so rewrite to blue-sdk-go.
# Using perl -pi -e for cross-platform compatibility (macOS + Linux CI).
find generated/go -name '*.connect.go' | xargs perl -pi -e 's|alphauslabs/blueapi/(\w+)"|alphauslabs/blue-sdk-go/$1/v1"|g'
# Compile services for blue-sdk-python; with grpc.
echo "Compiling Python GRPC services..."
mkdir -p generated/py/alphausblue
python3 -m grpc_tools.protoc -I . --python_out=./generated/py/alphausblue --grpc_python_out=./generated/py/alphausblue \
./org/v1/*.proto \
./kvstore/v1/*.proto \
./iam/v1/*.proto \
./admin/v1/*.proto \
./flags/v1/*.proto \
./cost/v1/*.proto \
./billing/v1/*.proto \
./operations/v1/*.proto \
./cover/v1/*.proto \
./pricing/v1/*.proto \
./flow/v1/*.proto \
./prism/v1/*.proto \
./vortex/v1/*.proto \
./gc/v1/*.proto \
./luster/v1/*.proto \
./preferences/v1/*.proto
# Compile ./api/* for blue-sdk-python; without grpc.
echo "Compiling Python SDK data..."
python3 -m grpc_tools.protoc -I . --python_out=./generated/py/alphausblue \
$(for v in $(find ./api -type d); do echo -n "$v/*.proto "; done)
echo "Replacing implicit relative imports with absolute imports..."
for package in $(find generated/py/alphausblue -mindepth 1 -maxdepth 1 -type d -printf "%f "); do
echo "Found package ${package}. Beginning replacement"
find generated/py/alphausblue/. -name '*.py' -exec sed -i -e "s/from ${package}/from alphausblue.${package}/g" {} \;
done
echo "Creating Python package files..."
find generated/py/alphausblue/. -type d -exec touch {}/__init__.py \;
echo "Generating OpenAPI docs..."
protoc -I . --openapiv2_out ./openapiv2 --openapiv2_opt logtostderr=true --openapiv2_opt allow_merge=true \
./org/v1/*.proto \
./iam/v1/*.proto \
./admin/v1/*.proto \
./flags/v1/*.proto \
./cost/v1/*.proto \
./billing/v1/*.proto \
./operations/v1/*.proto \
./cover/v1/*.proto \
./pricing/v1/*.proto \
./flow/v1/*.proto \
./prism/v1/*.proto \
./vortex/v1/*.proto \
./gc/v1/*.proto \
./luster/v1/*.proto \
./preferences/v1/*.proto
echo "Generating html docs..."
protoc --doc_out=./generated/ --doc_opt=html,index.html \
./org/v1/*.proto \
./iam/v1/*.proto \
./admin/v1/*.proto \
./flags/v1/*.proto \
./cost/v1/*.proto \
./billing/v1/*.proto \
./operations/v1/*.proto \
./cover/v1/*.proto \
./pricing/v1/*.proto \
./flow/v1/*.proto \
./prism/v1/*.proto \
./vortex/v1/*.proto \
./gc/v1/*.proto \
./luster/v1/*.proto \
./preferences/v1/*.proto