frostfs-sdk-go/prepare.sh
Pavel Pogodaev 6ce73790ea
All checks were successful
DCO / DCO (pull_request) Successful in 38s
Tests and linters / Tests (pull_request) Successful in 1m13s
Tests and linters / Lint (pull_request) Successful in 2m36s
[#276] Merge repo with frostfs-api-go
Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
2024-10-22 14:05:12 +00:00

39 lines
888 B
Bash
Executable file

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