File: generate.sh

package info (click to toggle)
gh 2.23.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 18,040 kB
  • sloc: asm: 6,813; ansic: 258; sh: 100; makefile: 96
file content (35 lines) | stat: -rwxr-xr-x 899 bytes parent folder | download
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"
  echo "Generated protocol buffers for $contract"

  services=$(cat "$contract" | grep -Eo "service .+ {" | 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!'