mirror of
https://github.com/outbackdingo/matchbox.git
synced 2026-01-27 18:19:36 +00:00
* Get/build protoc and protoc-gen-go binaries under tools so they do not interfere with any user installations * Ensure protoc and protoc-gen-go versions are pinned
31 lines
805 B
Bash
Executable File
31 lines
805 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Generate Go protocol buffer code from proto definitions
|
|
|
|
set -eu
|
|
|
|
# Add tools to the PATH so binaries are the correct version
|
|
export PATH=$PWD/tools:$PATH
|
|
|
|
# Check location and tools
|
|
if ! [[ "$0" =~ "scripts/codegen" ]]; then
|
|
echo "must be run from repository root"
|
|
exit 255
|
|
fi
|
|
|
|
if ! [[ $(protoc --version) =~ "3.0.0" ]]; then
|
|
echo "could not find protoc 3.0.0"
|
|
exit 255
|
|
fi
|
|
|
|
# protobuf subpackages end in "pb"
|
|
PBUFS=$(go list ./... | grep -v /vendor | grep 'pb$')
|
|
|
|
# change into each protobuf directory
|
|
for pkg in $PBUFS ; do
|
|
abs_path=${GOPATH}/src/${pkg}
|
|
echo Generating $abs_path
|
|
pushd ${abs_path} > /dev/null
|
|
# generate protocol buffers, make other .proto files available to import
|
|
protoc --go_out=plugins=grpc:. -I=.:"${GOPATH}/src/" *.proto
|
|
popd > /dev/null
|
|
done |