File: generate.sh

package info (click to toggle)
gh 2.46.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,548 kB
  • sloc: sh: 227; makefile: 117
file content (35 lines) | stat: -rwxr-xr-x 935 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

set -e

if ! protoc --version; then
  echo 'ERROR: protoc is not on your PATH'
  exit 1
fi
if ! protoc-gen-go --version; then
  echo 'ERROR: protoc-gen-go is not on your PATH'
  exit 1
fi
if ! protoc-gen-go-grpc --version; then
  echo 'ERROR: protoc-gen-go-grpc is not on your PATH'
fi

function generate {
  local dir="$1"
  local proto="$2"

  local contract="$dir/$proto"

  protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative "$contract" --experimental_allow_proto3_optional
  echo "Generated protocol buffers for $contract"

  services=$(grep -Eo "service .+ {" <$contract | awk '{print $2 "Server"}')
  moq -out "$contract.mock.go" "$dir" "$services"
  echo "Generated mock protocols for $contract"
}

generate jupyter jupyter_server_host_service.v1.proto
generate codespace codespace_host_service.v1.proto
generate ssh ssh_server_host_service.v1.proto

echo 'Done!'