forked from TrueCloudLab/frostfs-api-go
Add script to prepare multiversion structure
This commit is contained in:
parent
ad0213d256
commit
ed7879a89e
2 changed files with 48 additions and 1 deletions
2
Makefile
2
Makefile
|
@ -47,7 +47,7 @@ docgen: deps
|
|||
done
|
||||
|
||||
# Regenerate proto files:
|
||||
protoc: deps
|
||||
protoc:
|
||||
@echo "${B}${G}⇒ Cleanup old files ${R}"
|
||||
@find . -type f -name '*.pb.go' -not -path './vendor/*' -exec rm {} \;
|
||||
|
||||
|
|
47
prepare.sh
Executable file
47
prepare.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/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
|
||||
|
||||
# MOVE FILES FROM API REPO
|
||||
cd $API_PATH
|
||||
ARGS=$(find ./ -name '*.proto')
|
||||
for file in $ARGS; do
|
||||
dir=$(dirname $file)
|
||||
cp -r $dir $API_GO_PATH
|
||||
done
|
||||
cd $API_GO_PATH
|
||||
|
||||
# MODIFY FILES
|
||||
for file in $ARGS; do
|
||||
TYPES=$(grep '^import' $file | sed 's/import\ \"\(.*\)\/.*/\1/' | sort | uniq)
|
||||
PKG=$(grep '^package' $file | sed 's/package\ \(.*\);/\1/')
|
||||
|
||||
TYPES=( "${TYPES[@]}" "${PKG[@]}") # merge two arrays
|
||||
TYPES=$(printf "%s\n" "${TYPES[@]}" | sort | uniq) # left only uniq elemetns
|
||||
|
||||
for t in $TYPES; do
|
||||
sed -i "s/$t\./$t\.$prefix\./" $file
|
||||
sed -i "s/$t\//$t\/$prefix\//" $file
|
||||
done
|
||||
|
||||
sed -i "s/^package\(.*\);/package\1.$prefix;/" $file
|
||||
sed -i "s/go_package\(.*\)\";$/go_package\1\/$prefix\";/" $file
|
||||
|
||||
dir=$(dirname $file)
|
||||
mkdir $dir/v2 2>/dev/null
|
||||
mv $file $dir/v2
|
||||
done
|
||||
|
||||
# COMPILE
|
||||
make protoc
|
||||
|
||||
# REMOVE PROTO FILES
|
||||
# TO BE DONE AS NEOFS-API WILL BE STABLE
|
Loading…
Reference in a new issue