Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ endif
.PHONY: check-protoc
check-protoc:
./_tools/install-protoc-maybe.sh
.PHONY: check-gogofaster
check-gogofaster:
./_tools/install-gogofaster-maybe.sh
.PHONY: protogen
protogen: check-protoc
$(GOCMD) get github.com/gogo/protobuf/protoc-gen-gogofaster
protogen: check-protoc check-gogofaster
./_tools/protogen_golang.sh
pip3 install $(PIP_ARGS) grpcio_tools==1.13.0
./_tools/protogen_python.sh
55 changes: 55 additions & 0 deletions _tools/install-gogofaster-maybe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
#
# Checks protoc-gen-gogofaster installed in local 'protoc_dir' dir.
# If it's absent installs it in 'protoc_dir' from GH release.

GOGO_PROTOBUF_VER=1.2.0

protoc_dir="./protoc"
protoc_bin_dir=${protoc_dir}/bin

gogo_protobuf_release_url=https://github.com/gogo/protobuf/archive/v${GOGO_PROTOBUF_VER}.zip
gogo_protobuf_zip_path=${protoc_dir}/protobuf-${GOGO_PROTOBUF_VER}.zip
gogo_protobuf_base_dir=${protoc_dir}/src/github.com/gogo
gogo_protobuf_src_dir=${gogo_protobuf_base_dir}/protobuf
gogofaster_package=${gogo_protobuf_src_dir}/protoc-gen-gogofaster
gogofaster_bin_path=${protoc_bin_dir}/protoc-gen-gogofaster

# Since 'protoc-gen-gogofaster' does not expose its version, it must be reinstalled
if [[ -f ${gogofaster_bin_path} ]]; then
echo "Removing old gogofaster ${gogofaster_bin_path}"
rm ${gogofaster_bin_path}
fi

echo "Installing gogofaster v${GOGO_PROTOBUF_VER}"

mkdir -p ${protoc_bin_dir}
if [[ ! -f ${gogo_protobuf_zip_path} ]]; then
wget ${gogo_protobuf_release_url} -O ${gogo_protobuf_zip_path}
if [[ "$?" -ne 0 ]]; then
echo "Failed to download protoc release from ${gogo_protobuf_release_url}"
exit 2
fi
fi

mkdir -p ${gogo_protobuf_base_dir}
unzip -aoq ${gogo_protobuf_zip_path} -d ${gogo_protobuf_base_dir}
if [[ "$?" -ne 0 ]]; then
echo "Failed to unzip release from ${gogo_protobuf_zip_path}"
exit 2
else
rm -rf ${gogo_protobuf_src_dir}
mv ${gogo_protobuf_src_dir}-${GOGO_PROTOBUF_VER} ${gogo_protobuf_src_dir}
fi

export GOPATH=`pwd`/${protoc_dir}
go build -o ${gogofaster_bin_path} ${gogofaster_package}
if [[ "$?" -ne 0 ]]; then
echo "Failed to install ${gogofaster_package} into ${gogofaster_bin_path}"
exit 2
fi

if ! rm -rf "${gogo_protobuf_src_dir}" ; then
echo "Failed to delete ${gogo_protobuf_src_dir}"
exit 2
fi
4 changes: 2 additions & 2 deletions _tools/install-protoc-maybe.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Checks Protobuf compiler version.
# If absent, installs one in protoc_dir from GH release.
# Checks Protobuf compiler installed in local 'protoc_dir' dir.
# If it's absent or not the expected version, installs it in 'protoc_dir' from GH release.

PROTOC_VER="3.6.0"
OS="$(uname)"
Expand Down
9 changes: 7 additions & 2 deletions _tools/protogen_golang.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
#!/bin/bash
#
# Generates Protobuf + gRCP for Golang
# Assumes 'protoc' and 'protoc-gen-gogofaster' binaries are installed
# Assumes 'protoc' and 'protoc-gen-gogofaster' binaries are installed in local './protoc/bin' dir

PROTOC="./protoc/bin/protoc"
GOGOFASTER="./protoc/bin/protoc-gen-gogofaster"
sdk="lookout/sdk"
src="proto"
dst="golang"


[[ -f $PROTOC ]] >/dev/null 2>&1 || { echo "Protobuf compiler is required but not found in ${PROTOC}" >&2; exit 1; }

[[ -f $GOGOFASTER ]] >/dev/null 2>&1 || { echo "protoc-gen-gogofaster is required but not found in ${GOGOFASTER}" >&2; exit 1; }

if ! mkdir -p "${dst}" ; then
echo "Failed to create ${dst}"
exit 2
fi

# 'protoc-gen-gogofaster' must be under $PATH to be found by 'protoc'
export PATH=./protoc/bin:$PATH

"${PROTOC}" -I proto \
--gogofaster_out=plugins=grpc,\
Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,\
Expand Down
22 changes: 11 additions & 11 deletions pb/event.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pb/service_analyzer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions pb/service_data.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.