Path: blob/main/components/ide-metrics-api/generate.sh
2492 views
#!/bin/bash12if [ -n "$DEBUG" ]; then3set -x4fi56set -o errexit7set -o nounset8set -o pipefail910ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)/../../11COMPONENTS_DIR=$ROOT_DIR/components1213# include protoc bash functions14# shellcheck disable=SC1090,SC109115source "$ROOT_DIR"/scripts/protoc-generator.sh1617THIRD_PARTY_INCLUDES=${PROTOLOC:-$PWD/third_party}18if [ ! -d "$THIRD_PARTY_INCLUDES"/google/api ]; then19echo "missing $THIRD_PARTY_INCLUDES/google/api"20exit 121fi2223# TODO (aledbf): refactor to avoid duplication24local_go_protoc() {25local ROOT_DIR=$126# shellcheck disable=203527protoc \28-I/usr/lib/protoc/include -I"$COMPONENTS_DIR" -I. -I"$THIRD_PARTY_INCLUDES" \29--go_out=go \30--go_opt=paths=source_relative \31--go-grpc_out=go \32--go-grpc_opt=paths=source_relative \33*.proto34}3536go_protoc_gateway() {37# shellcheck disable=203538protoc \39-I/usr/lib/protoc/include -I"$COMPONENTS_DIR" -I. -I"$THIRD_PARTY_INCLUDES" \40--grpc-gateway_out=logtostderr=true,paths=source_relative:go \41*.proto42}4344local_java_protoc() {45protoc \46-I /usr/lib/protoc/include -I"$COMPONENTS_DIR" -I. -I"$THIRD_PARTY_INCLUDES" \47--plugin=protoc-gen-grpc-java=/tmp/protoc-gen-grpc-java \48--grpc-java_out=java/src/main/java \49--java_out=java/src/main/java \50./*.proto51# remove trailing spaces52find "$COMPONENTS_DIR"/ide-metrics-api/java/src/main/java/io/gitpod/idemetrics/api -maxdepth 1 -name "*.java" -exec sed -i -e "s/[[:space:]]*$//" {} \;53}5455install_dependencies56local_go_protoc "$COMPONENTS_DIR"57go_protoc_gateway "$COMPONENTS_DIR"58local_java_protoc "$COMPONENTS_DIR"59update_license606162