frostfs-api-go-pogpp/prepare.sh
Alex Vanin 60e9c3d0d3 Update structure with grpc subdir
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-09-18 10:40:48 +03:00

39 lines
808 B
Bash
Executable file

#!/bin/bash
prefix=v2
if [ -z "$1" ]; then
echo "usage: ./prepare.sh path/to/neofs-api"
exit 1
fi
API_GO_PATH=$(pwd)
API_PATH=$1
mkdir $API_GO_PATH/$prefix 2>/dev/null
# MOVE FILES FROM API REPO
cd $API_PATH
ARGS=$(find ./ -name '*.proto' -not -path './vendor/*')
for file in $ARGS; do
dir=$(dirname $file)
mkdir -p $API_GO_PATH/$prefix/$dir/grpc
cp -r $dir/* $API_GO_PATH/$prefix/$dir/grpc
done
# MODIFY FILES
cd $API_GO_PATH/$prefix
ARGS2=$(find ./ -name '*.proto')
for file in $ARGS2; do
echo $file
sed -i "s/import\ \"\(.*\)\/\(.*\)\.proto\";/import\ \"$prefix\/\1\/grpc\/\2\.proto\";/" $file
done
cd $API_GO_PATH
# COMPILE
make protoc
# REMOVE PROTO DEFINITIONS
ARGS=$(find ./$prefix -name '*.proto' -not -path './vendor/*')
for file in $ARGS; do
rm $file
done