Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/supervisor-api/generate.sh
2492 views
1
#!/bin/bash
2
3
if [ -n "$DEBUG" ]; then
4
set -x
5
fi
6
7
set -o errexit
8
set -o nounset
9
set -o pipefail
10
11
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)/../..
12
COMPONENTS_DIR=$ROOT_DIR/components
13
14
# include protoc bash functions
15
# shellcheck disable=SC1090,SC1091
16
source "$ROOT_DIR"/scripts/protoc-generator.sh
17
18
THIRD_PARTY_INCLUDES=${PROTOLOC:-$PWD/third_party}
19
if [ ! -d "$THIRD_PARTY_INCLUDES"/google/api ]; then
20
echo "missing $THIRD_PARTY_INCLUDES/google/api"
21
exit 1
22
fi
23
24
# TODO (aledbf): refactor to avoid duplication
25
local_go_protoc() {
26
local ROOT_DIR=$1
27
# shellcheck disable=2035
28
protoc \
29
-I/usr/lib/protoc/include -I"$COMPONENTS_DIR" -I. -I"$THIRD_PARTY_INCLUDES" \
30
--go_out=go \
31
--go_opt=paths=source_relative \
32
--go-grpc_out=go \
33
--go-grpc_opt=paths=source_relative \
34
*.proto
35
}
36
37
go_protoc_gateway() {
38
# shellcheck disable=2035
39
protoc \
40
-I/usr/lib/protoc/include -I"$COMPONENTS_DIR" -I. -I"$THIRD_PARTY_INCLUDES" \
41
--grpc-gateway_out=logtostderr=true,paths=source_relative:go \
42
*.proto
43
}
44
45
install_dependencies
46
local_go_protoc "$COMPONENTS_DIR"
47
go_protoc_gateway "$COMPONENTS_DIR"
48
./generate-java.sh
49
update_license
50
51
# remove trailing whitespace
52
find "$COMPONENTS_DIR/supervisor-api/java" -name "*.java" -type f -print0 | xargs -0 pre-commit run trailing-whitespace --files
53
54